diff --git a/sdk/automation/azure-mgmt-automation/README.md b/sdk/automation/azure-mgmt-automation/README.md index ebc50aba1731..115c463e20bd 100644 --- a/sdk/automation/azure-mgmt-automation/README.md +++ b/sdk/automation/azure-mgmt-automation/README.md @@ -1,28 +1,61 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Automation 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_ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_ -# Usage +## Getting started +### Prerequisites -To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) - -For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) -Code samples for this package can be found at [Automation](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. -Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) +- Python 3.8+ is required to use this package. +- [Azure subscription](https://azure.microsoft.com/free/) +### Install the package -# Provide Feedback +```bash +pip install azure-mgmt-automation +pip install azure-identity +``` + +### Authentication + +By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configure of following environment variables. + +- `AZURE_CLIENT_ID` for Azure client ID. +- `AZURE_TENANT_ID` for Azure tenant ID. +- `AZURE_CLIENT_SECRET` for Azure client secret. + +In addition, Azure subscription ID can be configured via environment variable `AZURE_SUBSCRIPTION_ID`. + +With above configuration, client can be authenticated by following code: + +```python +from azure.identity import DefaultAzureCredential +from azure.mgmt.automation import AutomationClient +import os + +sub_id = os.getenv("AZURE_SUBSCRIPTION_ID") +client = AutomationClient(credential=DefaultAzureCredential(), subscription_id=sub_id) +``` + +## Examples + +Code samples for this package can be found at: +- [Search Automation](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com +- [Azure Python Mgmt SDK Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) + + +## Troubleshooting + +## Next steps + +## Provide Feedback 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-automation%2FREADME.png) diff --git a/sdk/automation/azure-mgmt-automation/_meta.json b/sdk/automation/azure-mgmt-automation/_meta.json index 7bf91d868f55..883863d1056c 100644 --- a/sdk/automation/azure-mgmt-automation/_meta.json +++ b/sdk/automation/azure-mgmt-automation/_meta.json @@ -1,11 +1,11 @@ { - "commit": "23b62d4e4dab07dccda851cfe50f6c6afb705a3b", + "commit": "1afef7bcdd41383e1df1bd5b825dab7da139b945", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.2.7", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.15.0", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/automation/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.2.7 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/automation/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.15.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/automation/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_automation_client.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_automation_client.py index 04362ae49337..014394b5b729 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_automation_client.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_automation_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from ._configuration import AutomationClientConfiguration @@ -43,6 +46,7 @@ NodeReportsOperations, ObjectDataTypesOperations, Operations, + PowerShell72ModuleOperations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, Python2PackageOperations, @@ -149,6 +153,8 @@ class AutomationClient( :vartype object_data_types: azure.mgmt.automation.operations.ObjectDataTypesOperations :ivar fields: FieldsOperations operations :vartype fields: azure.mgmt.automation.operations.FieldsOperations + :ivar power_shell72_module: PowerShell72ModuleOperations operations + :vartype power_shell72_module: azure.mgmt.automation.operations.PowerShell72ModuleOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.automation.operations.Operations :ivar python2_package: Python2PackageOperations operations @@ -201,7 +207,25 @@ def __init__( **kwargs: Any ) -> None: self._config = AutomationClientConfiguration(credential=credential, subscription_id=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 = 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) @@ -269,6 +293,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) self.fields = FieldsOperations(self._client, self._config, self._serialize, self._deserialize) + self.power_shell72_module = PowerShell72ModuleOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.python2_package = Python2PackageOperations(self._client, self._config, self._serialize, self._deserialize) self.python3_package = Python3PackageOperations(self._client, self._config, self._serialize, self._deserialize) @@ -292,7 +319,7 @@ def __init__( ) self.variable = VariableOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -312,14 +339,14 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "AutomationClient": + def __enter__(self) -> Self: self._client.__enter__() return self - def __exit__(self, *exc_details) -> None: + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_configuration.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_configuration.py index 1224b5cc6c68..1c318645d2dd 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_configuration.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_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 AutomationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AutomationClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AutomationClient. Note that all parameters used to create this instance are saved as instance @@ -33,7 +32,6 @@ class AutomationClientConfiguration(Configuration): # pylint: disable=too-many- """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AutomationClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -43,6 +41,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.subscription_id = subscription_id self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-automation/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -51,9 +50,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/automation/azure-mgmt-automation/azure/mgmt/automation/_serialization.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_serialization.py index 2c170e28dbca..8139854b97bb 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_serialization.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_serialization.py @@ -38,7 +38,22 @@ import re import sys import codecs -from typing import Optional, Union, AnyStr, IO, Mapping +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + TypeVar, + MutableMapping, + Type, + List, + Mapping, +) try: from urllib import quote # type: ignore @@ -48,12 +63,14 @@ import isodate # type: ignore -from typing import Dict, Any, cast - -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") +ModelType = TypeVar("ModelType", bound="Model") +JSON = MutableMapping[str, Any] + class RawDeserializer: @@ -107,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 @@ -126,7 +143,9 @@ def _json_attemp(data): # The function hack is because Py2.7 messes up with exception # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") - raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -153,13 +172,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - _LOGGER = logging.getLogger(__name__) try: @@ -277,8 +289,8 @@ class Model(object): _attribute_map: Dict[str, Dict[str, Any]] = {} _validation: Dict[str, Dict[str, Any]] = {} - def __init__(self, **kwargs): - self.additional_properties = {} + def __init__(self, **kwargs: Any) -> None: + 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__) @@ -287,25 +299,25 @@ def __init__(self, **kwargs): else: setattr(self, k, kwargs[k]) - def __eq__(self, other): + def __eq__(self, other: Any) -> bool: """Compare objects by comparing all attributes.""" if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ return False - def __ne__(self, other): + def __ne__(self, other: Any) -> bool: """Compare objects by comparing all attributes.""" return not self.__eq__(other) - def __str__(self): + def __str__(self) -> str: return str(self.__dict__) @classmethod - def enable_additional_properties_sending(cls): + def enable_additional_properties_sending(cls) -> None: cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} @classmethod - def is_xml_model(cls): + def is_xml_model(cls) -> bool: try: cls._xml_map # type: ignore except AttributeError: @@ -322,8 +334,8 @@ 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=False, **kwargs): - """Return the JSON that would be sent to azure from this model. + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: + """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)`. @@ -334,10 +346,15 @@ def serialize(self, keep_readonly=False, **kwargs): :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, keep_readonly=True, key_transformer=attribute_transformer, **kwargs): - """Return a dict that can be JSONify using json.dump. + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. Advanced usage might optionally use a callback as parameter: @@ -368,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): @@ -384,7 +401,7 @@ def _infer_class_models(cls): return client_models @classmethod - def deserialize(cls, data, content_type=None): + def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: """Parse a str using the RestAPI syntax and return a model. :param str data: A str using RestAPI structure. JSON by default. @@ -393,10 +410,15 @@ def deserialize(cls, data, content_type=None): :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(cls, data, key_extractors=None, content_type=None): + def from_dict( + cls: Type[ModelType], + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> ModelType: """Parse a dict using given key extractor return a model. By default consider key @@ -409,8 +431,8 @@ def from_dict(cls, data, key_extractors=None, content_type=None): :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( - [ + deserializer.key_extractors = ( # type: ignore + [ # type: ignore attribute_key_case_insensitive_extractor, rest_key_case_insensitive_extractor, last_rest_key_case_insensitive_extractor, @@ -418,7 +440,7 @@ def from_dict(cls, data, key_extractors=None, content_type=None): 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): @@ -518,7 +540,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes=None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -534,7 +556,7 @@ def __init__(self, classes=None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies = 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 @@ -602,7 +624,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if xml_desc.get("attr", False): if xml_ns: ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) serialized.set(xml_name, new_attr) # type: ignore continue if xml_desc.get("text", False): @@ -622,12 +644,11 @@ 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 - unflattened = {k: new_attr} - new_attr = unflattened + new_attr = {k: new_attr} _new_attr = new_attr _serialized = serialized @@ -636,12 +657,13 @@ def _serialize(self, target_obj, data_type=None, **kwargs): _serialized.update(_new_attr) # type: ignore _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] - except ValueError: - continue + except ValueError as err: + if isinstance(err, SerializationError): + raise except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err else: return serialized @@ -656,8 +678,8 @@ def body(self, data, data_type, **kwargs): """ # Just in case this is a dict - internal_data_type = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type, None) + internal_data_type_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, None) try: is_xml_model_serialization = kwargs["is_xml"] except KeyError: @@ -683,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) @@ -703,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: @@ -715,7 +738,9 @@ def query(self, name, data, data_type, **kwargs): :param data: The data to be serialized. :param str data_type: The type to be serialized from. - :rtype: str + :keyword bool skip_quote: Whether to skip quote the serialized result. + Defaults to False. + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -723,10 +748,8 @@ def query(self, name, data, data_type, **kwargs): # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] - if not kwargs.get("skip_quote", False): - data = [quote(str(d), safe="") for d in data] - return str(self.serialize_iter(data, internal_data_type, **kwargs)) + do_quote = not kwargs.get("skip_quote", False) + return 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) @@ -777,6 +800,8 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: + if data is CoreNull: + return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -795,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) @@ -863,6 +888,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. + :keyword bool do_quote: Whether to quote the serialized result of each iterable element. + Defaults to False. :rtype: list, str """ if isinstance(data, str): @@ -875,9 +902,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -922,7 +954,9 @@ def serialize_dict(self, attr, dict_type, **kwargs): for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: @@ -955,7 +989,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) if obj_type is _long_type: return self.serialize_long(attr) - if obj_type is unicode_str: + if obj_type is str: return self.serialize_unicode(attr) if obj_type is datetime.datetime: return self.serialize_iso(attr) @@ -1132,10 +1166,10 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod def serialize_unix(attr, **kwargs): @@ -1161,7 +1195,8 @@ def rest_key_extractor(attr, attr_desc, data): working_data = data while "." in key: - dict_keys = _FLATTEN.split(key) + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(List[str], _FLATTEN.split(key)) if len(dict_keys) == 1: key = _decode_attribute_map_key(dict_keys[0]) break @@ -1170,7 +1205,6 @@ def rest_key_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1191,7 +1225,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1242,7 +1275,7 @@ def _extract_name_from_internal_type(internal_type): xml_name = internal_type_xml_map.get("name", internal_type.__name__) xml_ns = internal_type_xml_map.get("ns", None) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) return xml_name @@ -1266,7 +1299,7 @@ def xml_key_extractor(attr, attr_desc, data): # Integrate namespace if necessary xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) # If it's an attribute, that's simple if xml_desc.get("attr", False): @@ -1332,7 +1365,7 @@ class Deserializer(object): valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes=None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1352,7 +1385,7 @@ def __init__(self, classes=None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies = 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 @@ -1405,12 +1438,12 @@ def _deserialize(self, target_obj, data): response, class_name = self._classify_target(target_obj, data) - if isinstance(response, basestring): + if isinstance(response, str): return self.deserialize_data(data, response) elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: attributes = response._attribute_map # type: ignore @@ -1442,7 +1475,7 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: additional_properties = self._build_additional_properties(attributes, data) return self._instantiate_model(response, d_attrs, additional_properties) @@ -1471,22 +1504,22 @@ def _classify_target(self, target, data): Once classification has been determined, initialize object. :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deseralize. + :param str/dict data: The response data to deserialize. """ 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__ + return target, target.__class__.__name__ # type: ignore def failsafe_deserialize(self, target_obj, data, content_type=None): """Ignores any errors encountered in deserialization, @@ -1496,7 +1529,7 @@ def failsafe_deserialize(self, target_obj, data, content_type=None): a deserialization error. :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deseralize. + :param str/dict data: The response data to deserialize. :param str content_type: Swagger "produces" if available. """ try: @@ -1539,7 +1572,7 @@ def _unpack_content(raw_data, content_type=None): if hasattr(raw_data, "_content_consumed"): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data @@ -1613,7 +1646,7 @@ def deserialize_data(self, data, data_type): except (ValueError, TypeError, AttributeError) as err: msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return self._deserialize(obj_type, data) @@ -1661,7 +1694,7 @@ def deserialize_object(self, attr, **kwargs): if isinstance(attr, ET.Element): # Do no recurse on XML, just return the tree as-is return attr - if isinstance(attr, basestring): + if isinstance(attr, str): return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: @@ -1718,7 +1751,7 @@ def deserialize_basic(self, attr, data_type): if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + elif isinstance(attr, str): if attr.lower() in ["true", "1"]: return True elif attr.lower() in ["false", "0"]: @@ -1769,7 +1802,6 @@ def deserialize_enum(data, enum_obj): data = data.value if isinstance(data, int): # Workaround. We might consider remove it in the future. - # https://github.com/Azure/azure-rest-api-specs/issues/141 try: return list(enum_obj.__members__.values())[data] except IndexError: @@ -1823,10 +1855,10 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): @@ -1854,7 +1886,7 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return duration @@ -1871,7 +1903,7 @@ def deserialize_date(attr): if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) @staticmethod def deserialize_time(attr): @@ -1906,7 +1938,7 @@ def deserialize_rfc(attr): date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1943,7 +1975,7 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1959,9 +1991,10 @@ def deserialize_unix(attr): if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore try: + attr = int(attr) date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_vendor.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_vendor.py index 2bd6526d54d6..36f1cf507c1a 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_vendor.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_vendor.py @@ -8,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import AutomationClientConfiguration if TYPE_CHECKING: @@ -19,25 +17,6 @@ from ._serialization import Deserializer, Serializer -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 - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - formatted_components = template.split("/") - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) - - class AutomationClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_version.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_version.py index 73aef742777f..e5754a47ce68 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_version.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.1.0b3" +VERSION = "1.0.0b1" diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_automation_client.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_automation_client.py index 4a916016e428..0ccf8cb928e0 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_automation_client.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_automation_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from .._serialization import Deserializer, Serializer @@ -43,6 +46,7 @@ NodeReportsOperations, ObjectDataTypesOperations, Operations, + PowerShell72ModuleOperations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, Python2PackageOperations, @@ -149,6 +153,9 @@ class AutomationClient( :vartype object_data_types: azure.mgmt.automation.aio.operations.ObjectDataTypesOperations :ivar fields: FieldsOperations operations :vartype fields: azure.mgmt.automation.aio.operations.FieldsOperations + :ivar power_shell72_module: PowerShell72ModuleOperations operations + :vartype power_shell72_module: + azure.mgmt.automation.aio.operations.PowerShell72ModuleOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.automation.aio.operations.Operations :ivar python2_package: Python2PackageOperations operations @@ -201,7 +208,25 @@ def __init__( **kwargs: Any ) -> None: self._config = AutomationClientConfiguration(credential=credential, subscription_id=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 = 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) @@ -269,6 +294,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) self.fields = FieldsOperations(self._client, self._config, self._serialize, self._deserialize) + self.power_shell72_module = PowerShell72ModuleOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.python2_package = Python2PackageOperations(self._client, self._config, self._serialize, self._deserialize) self.python3_package = Python3PackageOperations(self._client, self._config, self._serialize, self._deserialize) @@ -292,7 +320,9 @@ def __init__( ) self.variable = VariableOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -312,14 +342,14 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "AutomationClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_configuration.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_configuration.py index 06cbd251fdb0..e646eef1aee2 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_configuration.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/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 AutomationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AutomationClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AutomationClient. Note that all parameters used to create this instance are saved as instance @@ -33,7 +32,6 @@ class AutomationClientConfiguration(Configuration): # pylint: disable=too-many- """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AutomationClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -43,6 +41,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.subscription_id = subscription_id self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-automation/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -51,9 +50,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/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_vendor.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_vendor.py index 4f8b6e44ad42..275e83ccb7e0 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_vendor.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_vendor.py @@ -8,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import AutomationClientConfiguration if TYPE_CHECKING: diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/__init__.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/__init__.py index ceadd5d1de73..98093c1e0571 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/__init__.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/__init__.py @@ -38,6 +38,7 @@ from ._module_operations import ModuleOperations from ._object_data_types_operations import ObjectDataTypesOperations from ._fields_operations import FieldsOperations +from ._power_shell72_module_operations import PowerShell72ModuleOperations from ._operations import Operations from ._automation_client_operations import AutomationClientOperationsMixin from ._python2_package_operations import Python2PackageOperations @@ -91,6 +92,7 @@ "ModuleOperations", "ObjectDataTypesOperations", "FieldsOperations", + "PowerShell72ModuleOperations", "Operations", "AutomationClientOperationsMixin", "Python2PackageOperations", diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_activity_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_activity_operations.py index 48d5318457f7..875f4fa1c82b 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_activity_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_activity_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,22 +19,20 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.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._activity_operations import build_get_request, build_list_by_module_request from .._vendor import AutomationClientMixinABC -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]] @@ -69,6 +67,9 @@ async def get( ) -> _models.Activity: """Retrieve the activity in the module identified by module name and activity name. + .. seealso:: + - http://aka.ms/azureautomationsdk/activityoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -77,12 +78,11 @@ async def get( :type module_name: str :param activity_name: The name of activity. Required. :type activity_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Activity or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Activity :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,25 +93,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.Activity] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, module_name=module_name, activity_name=activity_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -121,16 +120,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Activity", pipeline_response) + deserialized = self._deserialize("Activity", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities/{activityName}" - } + return deserialized # type: ignore @distributed_trace def list_by_module( @@ -138,13 +133,15 @@ def list_by_module( ) -> AsyncIterable["_models.Activity"]: """Retrieve a list of activities in the module identified by module name. + .. seealso:: + - http://aka.ms/azureautomationsdk/activityoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param module_name: The name of module. Required. :type module_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Activity or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.Activity] :raises ~azure.core.exceptions.HttpResponseError: @@ -152,10 +149,10 @@ def list_by_module( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.ActivityListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -166,25 +163,22 @@ def list_by_module( def prepare_request(next_link=None): if not next_link: - request = build_list_by_module_request( + _request = build_list_by_module_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, module_name=module_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_module.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ActivityListResult", pipeline_response) @@ -194,10 +188,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -209,7 +204,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_module.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_agent_registration_information_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_agent_registration_information_operations.py index 3615ea66bc8f..f808aa6e36bf 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_agent_registration_information_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_agent_registration_information_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,21 +19,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_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._agent_registration_information_operations import build_get_request, build_regenerate_key_request from .._vendor import AutomationClientMixinABC -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]] @@ -62,16 +61,18 @@ async def get( ) -> _models.AgentRegistration: """Retrieve the automation agent registration information. + .. seealso:: + - http://aka.ms/azureautomationsdk/agentregistrationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AgentRegistration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AgentRegistration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,25 +83,22 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.AgentRegistration] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -110,16 +108,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AgentRegistration", pipeline_response) + deserialized = self._deserialize("AgentRegistration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation" - } + return deserialized # type: ignore @overload async def regenerate_key( @@ -133,6 +127,9 @@ async def regenerate_key( ) -> _models.AgentRegistration: """Regenerate a primary or secondary agent registration key. + .. seealso:: + - http://aka.ms/azureautomationsdk/agentregistrationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -142,7 +139,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: AgentRegistration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AgentRegistration :raises ~azure.core.exceptions.HttpResponseError: @@ -153,23 +149,25 @@ async def regenerate_key( self, resource_group_name: str, automation_account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.AgentRegistration: """Regenerate a primary or secondary agent registration key. + .. seealso:: + - http://aka.ms/azureautomationsdk/agentregistrationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param parameters: The name of the agent registration key to be regenerated. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AgentRegistration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AgentRegistration :raises ~azure.core.exceptions.HttpResponseError: @@ -180,27 +178,27 @@ async def regenerate_key( self, resource_group_name: str, automation_account_name: str, - parameters: Union[_models.AgentRegistrationRegenerateKeyParameter, IO], + parameters: Union[_models.AgentRegistrationRegenerateKeyParameter, IO[bytes]], **kwargs: Any ) -> _models.AgentRegistration: """Regenerate a primary or secondary agent registration key. + .. seealso:: + - http://aka.ms/azureautomationsdk/agentregistrationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str - :param parameters: The name of the agent registration key to be regenerated. Is either a model - type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.AgentRegistrationRegenerateKeyParameter or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 name of the agent registration key to be regenerated. Is either a + AgentRegistrationRegenerateKeyParameter type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.AgentRegistrationRegenerateKeyParameter or + IO[bytes] :return: AgentRegistration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AgentRegistration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -211,21 +209,19 @@ async def regenerate_key( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AgentRegistration] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "AgentRegistrationRegenerateKeyParameter") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, @@ -233,15 +229,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -251,13 +246,9 @@ async def regenerate_key( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AgentRegistration", pipeline_response) + deserialized = self._deserialize("AgentRegistration", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation/regenerateKey" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_automation_account_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_automation_account_operations.py index d6ddc08bfb00..68aa97115202 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_automation_account_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_automation_account_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.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._automation_account_operations import ( build_create_or_update_request, build_delete_request, @@ -38,10 +37,10 @@ ) from .._vendor import AutomationClientMixinABC -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,6 +76,9 @@ async def update( ) -> _models.AutomationAccount: """Update an automation account. + .. seealso:: + - http://aka.ms/azureautomationsdk/automationaccountoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -86,7 +88,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: AutomationAccount or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -97,23 +98,25 @@ async def update( self, resource_group_name: str, automation_account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.AutomationAccount: """Update an automation account. + .. seealso:: + - http://aka.ms/azureautomationsdk/automationaccountoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param parameters: Parameters supplied to the update automation 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: AutomationAccount or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -124,27 +127,26 @@ async def update( self, resource_group_name: str, automation_account_name: str, - parameters: Union[_models.AutomationAccountUpdateParameters, IO], + parameters: Union[_models.AutomationAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.AutomationAccount: """Update an automation account. + .. seealso:: + - http://aka.ms/azureautomationsdk/automationaccountoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str - :param parameters: Parameters supplied to the update automation account. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.AutomationAccountUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Parameters supplied to the update automation account. Is either a + AutomationAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.AutomationAccountUpdateParameters or IO[bytes] :return: AutomationAccount or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -155,19 +157,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AutomationAccount] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "AutomationAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, @@ -175,15 +177,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -193,16 +194,12 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AutomationAccount", pipeline_response) + deserialized = self._deserialize("AutomationAccount", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -216,6 +213,9 @@ async def create_or_update( ) -> _models.AutomationAccount: """Create or update automation account. + .. seealso:: + - http://aka.ms/azureautomationsdk/automationaccountoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -225,7 +225,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: AutomationAccount or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -236,23 +235,25 @@ async def create_or_update( self, resource_group_name: str, automation_account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.AutomationAccount: """Create or update automation account. + .. seealso:: + - http://aka.ms/azureautomationsdk/automationaccountoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param parameters: Parameters supplied to the create or update automation 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: AutomationAccount or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -263,27 +264,27 @@ async def create_or_update( self, resource_group_name: str, automation_account_name: str, - parameters: Union[_models.AutomationAccountCreateOrUpdateParameters, IO], + parameters: Union[_models.AutomationAccountCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.AutomationAccount: """Create or update automation account. + .. seealso:: + - http://aka.ms/azureautomationsdk/automationaccountoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param parameters: Parameters supplied to the create or update automation account. Is either a - model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.AutomationAccountCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + AutomationAccountCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.AutomationAccountCreateOrUpdateParameters or + IO[bytes] :return: AutomationAccount or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -294,19 +295,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AutomationAccount] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "AutomationAccountCreateOrUpdateParameters") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, @@ -314,15 +315,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -333,36 +333,34 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("AutomationAccount", pipeline_response) + deserialized = self._deserialize("AutomationAccount", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("AutomationAccount", pipeline_response) + deserialized = self._deserialize("AutomationAccount", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}" - } - @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, **kwargs: Any ) -> None: """Delete an automation account. + .. seealso:: + - http://aka.ms/azureautomationsdk/automationaccountoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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, @@ -373,23 +371,22 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -400,11 +397,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.Automation/automationAccounts/{automationAccountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -412,16 +405,18 @@ async def get( ) -> _models.AutomationAccount: """Get information about an Automation Account. + .. seealso:: + - http://aka.ms/azureautomationsdk/automationaccountoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AutomationAccount or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,23 +427,22 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.AutomationAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -458,16 +452,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AutomationAccount", pipeline_response) + deserialized = self._deserialize("AutomationAccount", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}" - } + return deserialized # type: ignore @distributed_trace def list_by_resource_group( @@ -475,9 +465,11 @@ def list_by_resource_group( ) -> AsyncIterable["_models.AutomationAccount"]: """Retrieve a list of accounts within a given resource group. + .. seealso:: + - http://aka.ms/azureautomationsdk/automationaccountoperations + :param resource_group_name: Name of an Azure Resource group. 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 AutomationAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.AutomationAccount] @@ -486,10 +478,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.AutomationAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,23 +492,20 @@ 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.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AutomationAccountListResult", pipeline_response) @@ -526,10 +515,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -542,17 +532,12 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts" - } - @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.AutomationAccount"]: """Lists the Automation Accounts within an Azure subscription. Retrieve a list of accounts within a given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AutomationAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.AutomationAccount] @@ -561,10 +546,10 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.AutomationAccount"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.AutomationAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -575,22 +560,19 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.AutomationAccount"]: 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.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AutomationAccountListResult", pipeline_response) @@ -600,10 +582,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -615,5 +598,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Automation/automationAccounts"} diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_automation_client_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_automation_client_operations.py index ef0c01c9f234..a251cdee1dbe 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_automation_client_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_automation_client_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,26 +19,25 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_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._automation_client_operations import build_convert_graph_runbook_content_request from .._vendor import AutomationClientMixinABC -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]] class AutomationClientOperationsMixin(AutomationClientMixinABC): + @overload async def convert_graph_runbook_content( self, @@ -59,7 +59,6 @@ async def convert_graph_runbook_content( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: GraphicalRunbookContent or the result of cls(response) :rtype: ~azure.mgmt.automation.models.GraphicalRunbookContent :raises ~azure.core.exceptions.HttpResponseError: @@ -70,7 +69,7 @@ async def convert_graph_runbook_content( self, resource_group_name: str, automation_account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -82,11 +81,10 @@ async def convert_graph_runbook_content( :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param parameters: Input data describing the graphical runbook. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: GraphicalRunbookContent or the result of cls(response) :rtype: ~azure.mgmt.automation.models.GraphicalRunbookContent :raises ~azure.core.exceptions.HttpResponseError: @@ -97,7 +95,7 @@ async def convert_graph_runbook_content( self, resource_group_name: str, automation_account_name: str, - parameters: Union[_models.GraphicalRunbookContent, IO], + parameters: Union[_models.GraphicalRunbookContent, IO[bytes]], **kwargs: Any ) -> _models.GraphicalRunbookContent: """Post operation to serialize or deserialize GraphRunbookContent. @@ -106,18 +104,14 @@ async def convert_graph_runbook_content( :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str - :param parameters: Input data describing the graphical runbook. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.automation.models.GraphicalRunbookContent or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Input data describing the graphical runbook. Is either a + GraphicalRunbookContent type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.GraphicalRunbookContent or IO[bytes] :return: GraphicalRunbookContent or the result of cls(response) :rtype: ~azure.mgmt.automation.models.GraphicalRunbookContent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -128,19 +122,19 @@ async def convert_graph_runbook_content( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.GraphicalRunbookContent] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "GraphicalRunbookContent") - request = build_convert_graph_runbook_content_request( + _request = build_convert_graph_runbook_content_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, @@ -148,15 +142,14 @@ async def convert_graph_runbook_content( content_type=content_type, json=_json, content=_content, - template_url=self.convert_graph_runbook_content.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -166,13 +159,9 @@ async def convert_graph_runbook_content( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GraphicalRunbookContent", pipeline_response) + deserialized = self._deserialize("GraphicalRunbookContent", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - convert_graph_runbook_content.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/convertGraphRunbookContent" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_certificate_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_certificate_operations.py index 5379dc31ca25..29c591a83f50 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_certificate_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_certificate_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.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._certificate_operations import ( build_create_or_update_request, build_delete_request, @@ -37,10 +36,10 @@ ) from .._vendor import AutomationClientMixinABC -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]] @@ -70,18 +69,20 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the certificate. + .. seealso:: + - http://aka.ms/azureautomationsdk/certificateoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param certificate_name: The name of certificate. Required. :type certificate_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, @@ -92,24 +93,23 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, certificate_name=certificate_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -120,11 +120,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.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -132,18 +128,20 @@ async def get( ) -> _models.Certificate: """Retrieve the certificate identified by certificate name. + .. seealso:: + - http://aka.ms/azureautomationsdk/certificateoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param certificate_name: The name of certificate. Required. :type certificate_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -154,24 +152,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.Certificate] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, certificate_name=certificate_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -181,16 +178,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Certificate", pipeline_response) + deserialized = self._deserialize("Certificate", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -205,6 +198,9 @@ async def create_or_update( ) -> _models.Certificate: """Create a certificate. + .. seealso:: + - http://aka.ms/azureautomationsdk/certificateoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -218,7 +214,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: Certificate or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: @@ -230,13 +225,16 @@ async def create_or_update( resource_group_name: str, automation_account_name: str, certificate_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Certificate: """Create a certificate. + .. seealso:: + - http://aka.ms/azureautomationsdk/certificateoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -246,11 +244,10 @@ async def create_or_update( :type certificate_name: str :param parameters: The parameters supplied to the create or update certificate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: @@ -262,11 +259,14 @@ async def create_or_update( resource_group_name: str, automation_account_name: str, certificate_name: str, - parameters: Union[_models.CertificateCreateOrUpdateParameters, IO], + parameters: Union[_models.CertificateCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Certificate: """Create a certificate. + .. seealso:: + - http://aka.ms/azureautomationsdk/certificateoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -275,17 +275,14 @@ async def create_or_update( Required. :type certificate_name: str :param parameters: The parameters supplied to the create or update certificate operation. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.CertificateCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 CertificateCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.CertificateCreateOrUpdateParameters or + IO[bytes] :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -296,19 +293,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Certificate] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CertificateCreateOrUpdateParameters") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, certificate_name=certificate_name, @@ -317,15 +314,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -336,20 +332,16 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("Certificate", pipeline_response) + deserialized = self._deserialize("Certificate", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("Certificate", pipeline_response) + deserialized = self._deserialize("Certificate", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}" - } - @overload async def update( self, @@ -363,6 +355,9 @@ async def update( ) -> _models.Certificate: """Update a certificate. + .. seealso:: + - http://aka.ms/azureautomationsdk/certificateoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -374,7 +369,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: Certificate or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: @@ -386,13 +380,16 @@ async def update( resource_group_name: str, automation_account_name: str, certificate_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Certificate: """Update a certificate. + .. seealso:: + - http://aka.ms/azureautomationsdk/certificateoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -400,11 +397,10 @@ async def update( :param certificate_name: The parameters supplied to the update certificate operation. Required. :type certificate_name: str :param parameters: The parameters supplied to the update certificate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: @@ -416,11 +412,14 @@ async def update( resource_group_name: str, automation_account_name: str, certificate_name: str, - parameters: Union[_models.CertificateUpdateParameters, IO], + parameters: Union[_models.CertificateUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Certificate: """Update a certificate. + .. seealso:: + - http://aka.ms/azureautomationsdk/certificateoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -428,17 +427,13 @@ async def update( :param certificate_name: The parameters supplied to the update certificate operation. Required. :type certificate_name: str :param parameters: The parameters supplied to the update certificate operation. Is either a - model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.CertificateUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + CertificateUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.CertificateUpdateParameters or IO[bytes] :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -449,19 +444,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Certificate] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CertificateUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, certificate_name=certificate_name, @@ -470,15 +465,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -488,16 +482,12 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Certificate", pipeline_response) + deserialized = self._deserialize("Certificate", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -505,11 +495,13 @@ def list_by_automation_account( ) -> AsyncIterable["_models.Certificate"]: """Retrieve a list of certificates. + .. seealso:: + - http://aka.ms/azureautomationsdk/certificateoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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 Certificate or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.Certificate] :raises ~azure.core.exceptions.HttpResponseError: @@ -517,10 +509,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.CertificateListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -531,24 +523,21 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("CertificateListResult", pipeline_response) @@ -558,10 +547,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -573,7 +563,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_connection_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_connection_operations.py index 2a8289659e0f..1d4b97fdc61e 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_connection_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_connection_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.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._connection_operations import ( build_create_or_update_request, build_delete_request, @@ -37,10 +36,10 @@ ) from .._vendor import AutomationClientMixinABC -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]] @@ -70,18 +69,20 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the connection. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectionoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param connection_name: The name of connection. Required. :type 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, @@ -92,24 +93,23 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, connection_name=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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -120,11 +120,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.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -132,18 +128,20 @@ async def get( ) -> _models.Connection: """Retrieve the connection identified by connection name. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectionoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param connection_name: The name of connection. Required. :type connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Connection or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -154,24 +152,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.Connection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, connection_name=connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -181,16 +178,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Connection", pipeline_response) + deserialized = self._deserialize("Connection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -205,6 +198,9 @@ async def create_or_update( ) -> _models.Connection: """Create or update a connection. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectionoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -218,7 +214,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: Connection or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection :raises ~azure.core.exceptions.HttpResponseError: @@ -230,13 +225,16 @@ async def create_or_update( resource_group_name: str, automation_account_name: str, connection_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Connection: """Create or update a connection. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectionoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -246,11 +244,10 @@ async def create_or_update( :type connection_name: str :param parameters: The parameters supplied to the create or update connection operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Connection or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection :raises ~azure.core.exceptions.HttpResponseError: @@ -262,11 +259,14 @@ async def create_or_update( resource_group_name: str, automation_account_name: str, connection_name: str, - parameters: Union[_models.ConnectionCreateOrUpdateParameters, IO], + parameters: Union[_models.ConnectionCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Connection: """Create or update a connection. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectionoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -275,17 +275,13 @@ async def create_or_update( Required. :type connection_name: str :param parameters: The parameters supplied to the create or update connection operation. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.ConnectionCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 ConnectionCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.ConnectionCreateOrUpdateParameters or IO[bytes] :return: Connection or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -296,19 +292,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Connection] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ConnectionCreateOrUpdateParameters") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, connection_name=connection_name, @@ -317,15 +313,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -336,20 +331,16 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("Connection", pipeline_response) + deserialized = self._deserialize("Connection", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("Connection", pipeline_response) + deserialized = self._deserialize("Connection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}" - } - @overload async def update( self, @@ -363,6 +354,9 @@ async def update( ) -> _models.Connection: """Update a connection. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectionoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -374,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: Connection or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection :raises ~azure.core.exceptions.HttpResponseError: @@ -386,13 +379,16 @@ async def update( resource_group_name: str, automation_account_name: str, connection_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Connection: """Update a connection. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectionoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -400,11 +396,10 @@ async def update( :param connection_name: The parameters supplied to the update a connection operation. Required. :type connection_name: str :param parameters: The parameters supplied to the update a connection operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Connection or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection :raises ~azure.core.exceptions.HttpResponseError: @@ -416,11 +411,14 @@ async def update( resource_group_name: str, automation_account_name: str, connection_name: str, - parameters: Union[_models.ConnectionUpdateParameters, IO], + parameters: Union[_models.ConnectionUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Connection: """Update a connection. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectionoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -428,17 +426,13 @@ async def update( :param connection_name: The parameters supplied to the update a connection operation. Required. :type connection_name: str :param parameters: The parameters supplied to the update a connection operation. Is either a - model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.ConnectionUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ConnectionUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.ConnectionUpdateParameters or IO[bytes] :return: Connection or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -449,19 +443,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Connection] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ConnectionUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, connection_name=connection_name, @@ -470,15 +464,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -488,16 +481,12 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Connection", pipeline_response) + deserialized = self._deserialize("Connection", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -505,11 +494,13 @@ def list_by_automation_account( ) -> AsyncIterable["_models.Connection"]: """Retrieve a list of connections. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectionoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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 Connection or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.Connection] :raises ~azure.core.exceptions.HttpResponseError: @@ -517,10 +508,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.ConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -531,24 +522,21 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ConnectionListResult", pipeline_response) @@ -558,10 +546,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -573,7 +562,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_connection_type_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_connection_type_operations.py index e51ac98d5238..149a16453c55 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_connection_type_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_connection_type_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.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._connection_type_operations import ( build_create_or_update_request, build_delete_request, @@ -36,10 +35,10 @@ ) from .._vendor import AutomationClientMixinABC -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]] @@ -69,18 +68,20 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the connection type. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectiontypeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param connection_type_name: The name of connection type. Required. :type connection_type_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, @@ -91,24 +92,23 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, connection_type_name=connection_type_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -119,11 +119,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.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -131,18 +127,20 @@ async def get( ) -> _models.ConnectionType: """Retrieve the connection type identified by connection type name. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectiontypeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param connection_type_name: The name of connection type. Required. :type connection_type_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ConnectionType or the result of cls(response) :rtype: ~azure.mgmt.automation.models.ConnectionType :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -153,24 +151,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.ConnectionType] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, connection_type_name=connection_type_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -180,16 +177,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ConnectionType", pipeline_response) + deserialized = self._deserialize("ConnectionType", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -204,6 +197,9 @@ async def create_or_update( ) -> _models.ConnectionType: """Create a connection type. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectiontypeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -217,7 +213,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: ConnectionType or the result of cls(response) :rtype: ~azure.mgmt.automation.models.ConnectionType :raises ~azure.core.exceptions.HttpResponseError: @@ -229,13 +224,16 @@ async def create_or_update( resource_group_name: str, automation_account_name: str, connection_type_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.ConnectionType: """Create a connection type. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectiontypeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -245,11 +243,10 @@ async def create_or_update( :type connection_type_name: str :param parameters: The parameters supplied to the create or update connection type operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ConnectionType or the result of cls(response) :rtype: ~azure.mgmt.automation.models.ConnectionType :raises ~azure.core.exceptions.HttpResponseError: @@ -261,11 +258,14 @@ async def create_or_update( resource_group_name: str, automation_account_name: str, connection_type_name: str, - parameters: Union[_models.ConnectionTypeCreateOrUpdateParameters, IO], + parameters: Union[_models.ConnectionTypeCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.ConnectionType: """Create a connection type. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectiontypeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -274,17 +274,14 @@ async def create_or_update( operation. Required. :type connection_type_name: str :param parameters: The parameters supplied to the create or update connection type operation. - Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.ConnectionTypeCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 ConnectionTypeCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.ConnectionTypeCreateOrUpdateParameters or + IO[bytes] :return: ConnectionType or the result of cls(response) :rtype: ~azure.mgmt.automation.models.ConnectionType :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -295,19 +292,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ConnectionType] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ConnectionTypeCreateOrUpdateParameters") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, connection_type_name=connection_type_name, @@ -316,15 +313,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -334,16 +330,12 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ConnectionType", pipeline_response) + deserialized = self._deserialize("ConnectionType", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -351,11 +343,13 @@ def list_by_automation_account( ) -> AsyncIterable["_models.ConnectionType"]: """Retrieve a list of connection types. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectiontypeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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 ConnectionType or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.ConnectionType] :raises ~azure.core.exceptions.HttpResponseError: @@ -363,10 +357,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.ConnectionTypeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -377,24 +371,21 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ConnectionTypeListResult", pipeline_response) @@ -404,10 +395,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -419,7 +411,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_credential_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_credential_operations.py index 75800d5637d1..e89259486a86 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_credential_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_credential_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.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._credential_operations import ( build_create_or_update_request, build_delete_request, @@ -37,10 +36,10 @@ ) from .._vendor import AutomationClientMixinABC -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]] @@ -70,18 +69,20 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the credential. + .. seealso:: + - http://aka.ms/azureautomationsdk/credentialoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param credential_name: The name of credential. Required. :type credential_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, @@ -92,24 +93,23 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, credential_name=credential_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -120,11 +120,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.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -132,18 +128,20 @@ async def get( ) -> _models.Credential: """Retrieve the credential identified by credential name. + .. seealso:: + - http://aka.ms/azureautomationsdk/credentialoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param credential_name: The name of credential. Required. :type credential_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Credential or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -154,24 +152,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.Credential] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, credential_name=credential_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -181,16 +178,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Credential", pipeline_response) + deserialized = self._deserialize("Credential", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -205,6 +198,9 @@ async def create_or_update( ) -> _models.Credential: """Create a credential. + .. seealso:: + - http://aka.ms/azureautomationsdk/credentialoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -218,7 +214,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: Credential or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential :raises ~azure.core.exceptions.HttpResponseError: @@ -230,13 +225,16 @@ async def create_or_update( resource_group_name: str, automation_account_name: str, credential_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Credential: """Create a credential. + .. seealso:: + - http://aka.ms/azureautomationsdk/credentialoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -246,11 +244,10 @@ async def create_or_update( :type credential_name: str :param parameters: The parameters supplied to the create or update credential operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Credential or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential :raises ~azure.core.exceptions.HttpResponseError: @@ -262,11 +259,14 @@ async def create_or_update( resource_group_name: str, automation_account_name: str, credential_name: str, - parameters: Union[_models.CredentialCreateOrUpdateParameters, IO], + parameters: Union[_models.CredentialCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Credential: """Create a credential. + .. seealso:: + - http://aka.ms/azureautomationsdk/credentialoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -275,17 +275,13 @@ async def create_or_update( Required. :type credential_name: str :param parameters: The parameters supplied to the create or update credential operation. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.CredentialCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 CredentialCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.CredentialCreateOrUpdateParameters or IO[bytes] :return: Credential or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -296,19 +292,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Credential] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CredentialCreateOrUpdateParameters") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, credential_name=credential_name, @@ -317,15 +313,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -336,20 +331,16 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("Credential", pipeline_response) + deserialized = self._deserialize("Credential", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("Credential", pipeline_response) + deserialized = self._deserialize("Credential", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}" - } - @overload async def update( self, @@ -363,6 +354,9 @@ async def update( ) -> _models.Credential: """Update a credential. + .. seealso:: + - http://aka.ms/azureautomationsdk/credentialoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -374,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: Credential or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential :raises ~azure.core.exceptions.HttpResponseError: @@ -386,13 +379,16 @@ async def update( resource_group_name: str, automation_account_name: str, credential_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Credential: """Update a credential. + .. seealso:: + - http://aka.ms/azureautomationsdk/credentialoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -400,11 +396,10 @@ async def update( :param credential_name: The parameters supplied to the Update credential operation. Required. :type credential_name: str :param parameters: The parameters supplied to the Update credential operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Credential or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential :raises ~azure.core.exceptions.HttpResponseError: @@ -416,11 +411,14 @@ async def update( resource_group_name: str, automation_account_name: str, credential_name: str, - parameters: Union[_models.CredentialUpdateParameters, IO], + parameters: Union[_models.CredentialUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Credential: """Update a credential. + .. seealso:: + - http://aka.ms/azureautomationsdk/credentialoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -428,17 +426,13 @@ async def update( :param credential_name: The parameters supplied to the Update credential operation. Required. :type credential_name: str :param parameters: The parameters supplied to the Update credential operation. Is either a - model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.CredentialUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + CredentialUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.CredentialUpdateParameters or IO[bytes] :return: Credential or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -449,19 +443,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Credential] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CredentialUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, credential_name=credential_name, @@ -470,15 +464,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -488,16 +481,12 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Credential", pipeline_response) + deserialized = self._deserialize("Credential", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -505,11 +494,13 @@ def list_by_automation_account( ) -> AsyncIterable["_models.Credential"]: """Retrieve a list of credentials. + .. seealso:: + - http://aka.ms/azureautomationsdk/credentialoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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 Credential or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.Credential] :raises ~azure.core.exceptions.HttpResponseError: @@ -517,10 +508,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.CredentialListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -531,24 +522,21 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("CredentialListResult", pipeline_response) @@ -558,10 +546,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -572,7 +561,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_deleted_automation_accounts_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_deleted_automation_accounts_operations.py index 1035080d3af2..020eeb8a48c4 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_deleted_automation_accounts_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_deleted_automation_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,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, TypeVar +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,21 +18,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_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_automation_accounts_operations import build_list_by_subscription_request from .._vendor import AutomationClientMixinABC -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]] @@ -60,12 +58,11 @@ def __init__(self, *args, **kwargs) -> None: async def list_by_subscription(self, **kwargs: Any) -> _models.DeletedAutomationAccountListResult: """Retrieve deleted automation account. - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedAutomationAccountListResult or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DeletedAutomationAccountListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -76,21 +73,20 @@ async def list_by_subscription(self, **kwargs: Any) -> _models.DeletedAutomation _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-31")) cls: ClsType[_models.DeletedAutomationAccountListResult] = kwargs.pop("cls", None) - request = build_list_by_subscription_request( + _request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -100,13 +96,9 @@ async def list_by_subscription(self, **kwargs: Any) -> _models.DeletedAutomation error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DeletedAutomationAccountListResult", pipeline_response) + deserialized = self._deserialize("DeletedAutomationAccountListResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Automation/deletedAutomationAccounts" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_compilation_job_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_compilation_job_operations.py index 46bf8b413117..c2607e33031b 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_compilation_job_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_compilation_job_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,9 +20,8 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -29,7 +29,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._dsc_compilation_job_operations import ( build_create_request, build_get_request, @@ -38,10 +37,10 @@ ) from .._vendor import AutomationClientMixinABC -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]] @@ -70,10 +69,10 @@ async def _create_initial( resource_group_name: str, automation_account_name: str, compilation_job_name: str, - parameters: Union[_models.DscCompilationJobCreateParameters, IO], + parameters: Union[_models.DscCompilationJobCreateParameters, IO[bytes]], **kwargs: Any - ) -> _models.DscCompilationJob: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -84,21 +83,19 @@ async def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DscCompilationJob] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DscCompilationJobCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, compilation_job_name=compilation_job_name, @@ -107,34 +104,30 @@ 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.url = self._client.format_url(_request.url) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: + await response.read() # Load the body in memory and close the socket 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("DscCompilationJob", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) 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.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -149,6 +142,9 @@ async def begin_create( ) -> AsyncLROPoller[_models.DscCompilationJob]: """Creates the Dsc compilation job of the configuration. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscconfigurationcompilejoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -160,14 +156,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 DscCompilationJob or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.automation.models.DscCompilationJob] @@ -180,13 +168,16 @@ async def begin_create( resource_group_name: str, automation_account_name: str, compilation_job_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.DscCompilationJob]: """Creates the Dsc compilation job of the configuration. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscconfigurationcompilejoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -194,18 +185,10 @@ async def begin_create( :param compilation_job_name: The DSC configuration Id. Required. :type compilation_job_name: str :param parameters: The parameters supplied to the create compilation job operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. 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 DscCompilationJob or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.automation.models.DscCompilationJob] @@ -218,11 +201,14 @@ async def begin_create( resource_group_name: str, automation_account_name: str, compilation_job_name: str, - parameters: Union[_models.DscCompilationJobCreateParameters, IO], + parameters: Union[_models.DscCompilationJobCreateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.DscCompilationJob]: """Creates the Dsc compilation job of the configuration. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscconfigurationcompilejoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -230,19 +216,8 @@ async def begin_create( :param compilation_job_name: The DSC configuration Id. Required. :type compilation_job_name: str :param parameters: The parameters supplied to the create compilation job operation. Is either a - model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.DscCompilationJobCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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. + DscCompilationJobCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.DscCompilationJobCreateParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either DscCompilationJob or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.automation.models.DscCompilationJob] @@ -251,9 +226,7 @@ async def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DscCompilationJob] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -272,12 +245,13 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DscCompilationJob", pipeline_response) + deserialized = self._deserialize("DscCompilationJob", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -287,17 +261,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.DscCompilationJob].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.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}" - } + return AsyncLROPoller[_models.DscCompilationJob]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def get( @@ -305,18 +277,20 @@ async def get( ) -> _models.DscCompilationJob: """Retrieve the Dsc configuration compilation job identified by job id. + .. seealso:: + - http://aka.ms/azureautomationsdk/dsccompilationjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param compilation_job_name: The DSC configuration Id. Required. :type compilation_job_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DscCompilationJob or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscCompilationJob :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -327,26 +301,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.DscCompilationJob] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, compilation_job_name=compilation_job_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -356,16 +327,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DscCompilationJob", pipeline_response) + deserialized = self._deserialize("DscCompilationJob", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -373,13 +340,15 @@ def list_by_automation_account( ) -> AsyncIterable["_models.DscCompilationJob"]: """Retrieve a list of dsc compilation jobs. + .. seealso:: + - http://aka.ms/azureautomationsdk/compilationjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param filter: The filter to apply on the operation. 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 DscCompilationJob or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.DscCompilationJob] @@ -388,12 +357,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.DscCompilationJobListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -404,25 +371,22 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DscCompilationJobListResult", pipeline_response) @@ -432,10 +396,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -448,16 +413,15 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs" - } - @distributed_trace_async async def get_stream( self, resource_group_name: str, automation_account_name: str, job_id: str, job_stream_id: str, **kwargs: Any ) -> _models.JobStream: """Retrieve the job stream identified by job stream id. + .. seealso:: + - http://aka.ms/azureautomationsdk/jobstreamoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -466,12 +430,11 @@ async def get_stream( :type job_id: str :param job_stream_id: The job stream id. Required. :type job_stream_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: JobStream or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobStream :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -482,27 +445,24 @@ async def get_stream( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.JobStream] = kwargs.pop("cls", None) - request = build_get_stream_request( + _request = build_get_stream_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_id=job_id, job_stream_id=job_stream_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_stream.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -512,13 +472,9 @@ async def get_stream( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("JobStream", pipeline_response) + deserialized = self._deserialize("JobStream", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_stream.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams/{jobStreamId}" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_compilation_job_stream_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_compilation_job_stream_operations.py index cf2858b8ec2c..d03f9625c7cb 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_compilation_job_stream_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_compilation_job_stream_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, TypeVar +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,21 +18,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_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._dsc_compilation_job_stream_operations import build_list_by_job_request from .._vendor import AutomationClientMixinABC -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]] @@ -62,18 +60,20 @@ async def list_by_job( ) -> _models.JobStreamListResult: """Retrieve all the job streams for the compilation Job. + .. seealso:: + - http://aka.ms/azureautomationsdk/jobstreamoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param job_id: The job id. Required. :type job_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: JobStreamListResult or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobStreamListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -84,26 +84,23 @@ async def list_by_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.JobStreamListResult] = kwargs.pop("cls", None) - request = build_list_by_job_request( + _request = build_list_by_job_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_id=job_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_job.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -113,13 +110,9 @@ async def list_by_job( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("JobStreamListResult", pipeline_response) + deserialized = self._deserialize("JobStreamListResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_by_job.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_configuration_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_configuration_operations.py index 8235b0d6417f..732cc43f3e37 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_configuration_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_configuration_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, Optional, TypeVar, Union, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, Optional, Type, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,15 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.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._dsc_configuration_operations import ( build_create_or_update_request, build_delete_request, @@ -38,10 +36,10 @@ ) from .._vendor import AutomationClientMixinABC -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]] @@ -71,18 +69,20 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the dsc configuration identified by configuration name. + .. seealso:: + - http://aka.ms/azureautomationsdk/configurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param configuration_name: The configuration name. Required. :type configuration_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, @@ -93,24 +93,23 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, configuration_name=configuration_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -121,11 +120,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.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -133,18 +128,20 @@ async def get( ) -> _models.DscConfiguration: """Retrieve the configuration identified by configuration name. + .. seealso:: + - http://aka.ms/azureautomationsdk/configurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param configuration_name: The configuration name. Required. :type configuration_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DscConfiguration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -155,24 +152,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.DscConfiguration] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, configuration_name=configuration_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -182,16 +178,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DscConfiguration", pipeline_response) + deserialized = self._deserialize("DscConfiguration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -206,6 +198,9 @@ async def create_or_update( ) -> _models.DscConfiguration: """Create the configuration identified by configuration name. + .. seealso:: + - http://aka.ms/azureautomationsdk/configurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -217,7 +212,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: DscConfiguration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration :raises ~azure.core.exceptions.HttpResponseError: @@ -236,6 +230,9 @@ async def create_or_update( ) -> _models.DscConfiguration: """Create the configuration identified by configuration name. + .. seealso:: + - http://aka.ms/azureautomationsdk/configurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -247,7 +244,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for string body. Default value is None. :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DscConfiguration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration :raises ~azure.core.exceptions.HttpResponseError: @@ -264,24 +260,23 @@ async def create_or_update( ) -> _models.DscConfiguration: """Create the configuration identified by configuration name. + .. seealso:: + - http://aka.ms/azureautomationsdk/configurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param configuration_name: The create or update parameters for configuration. Required. :type configuration_name: str - :param parameters: The create or update parameters for configuration. Is either a model type or - a string type. Required. + :param parameters: The create or update parameters for configuration. Is either a + DscConfigurationCreateOrUpdateParameters type or a str type. Required. :type parameters: ~azure.mgmt.automation.models.DscConfigurationCreateOrUpdateParameters or str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/plain; charset=utf-8'. Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DscConfiguration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -292,7 +287,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DscConfiguration] = kwargs.pop("cls", None) @@ -304,7 +299,7 @@ async def create_or_update( elif isinstance(parameters, str): _content = self._serialize.body(parameters, "str") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, configuration_name=configuration_name, @@ -313,15 +308,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -332,20 +326,16 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("DscConfiguration", pipeline_response) + deserialized = self._deserialize("DscConfiguration", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("DscConfiguration", pipeline_response) + deserialized = self._deserialize("DscConfiguration", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}" - } - @overload async def update( self, @@ -359,6 +349,9 @@ async def update( ) -> _models.DscConfiguration: """Create the configuration identified by configuration name. + .. seealso:: + - http://aka.ms/azureautomationsdk/configurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -370,7 +363,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: DscConfiguration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration :raises ~azure.core.exceptions.HttpResponseError: @@ -389,6 +381,9 @@ async def update( ) -> _models.DscConfiguration: """Create the configuration identified by configuration name. + .. seealso:: + - http://aka.ms/azureautomationsdk/configurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -400,7 +395,6 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for string body. Default value is None. :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DscConfiguration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration :raises ~azure.core.exceptions.HttpResponseError: @@ -417,24 +411,23 @@ async def update( ) -> _models.DscConfiguration: """Create the configuration identified by configuration name. + .. seealso:: + - http://aka.ms/azureautomationsdk/configurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param configuration_name: The create or update parameters for configuration. Required. :type configuration_name: str - :param parameters: The create or update parameters for configuration. Is either a model type or - a string type. Default value is None. + :param parameters: The create or update parameters for configuration. Is either a + DscConfigurationUpdateParameters type or a str type. Default value is None. :type parameters: ~azure.mgmt.automation.models.DscConfigurationUpdateParameters or str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/plain; charset=utf-8'. Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DscConfiguration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -445,7 +438,7 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DscConfiguration] = kwargs.pop("cls", None) @@ -463,7 +456,7 @@ async def update( else: _content = None - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, configuration_name=configuration_name, @@ -472,15 +465,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -490,16 +482,12 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DscConfiguration", pipeline_response) + deserialized = self._deserialize("DscConfiguration", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_content( @@ -507,18 +495,20 @@ async def get_content( ) -> AsyncIterator[bytes]: """Retrieve the configuration script identified by configuration name. + .. seealso:: + - http://aka.ms/azureautomationsdk/configurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param configuration_name: The configuration name. Required. :type configuration_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Async iterator of the response bytes or the result of cls(response) + :return: AsyncIterator[bytes] or the result of cls(response) :rtype: AsyncIterator[bytes] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -529,29 +519,29 @@ async def get_content( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_get_content_request( + _request = build_get_content_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, configuration_name=configuration_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_content.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=True, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: + await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -562,10 +552,6 @@ async def get_content( return deserialized # type: ignore - get_content.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}/content" - } - @distributed_trace def list_by_automation_account( self, @@ -579,6 +565,9 @@ def list_by_automation_account( ) -> AsyncIterable["_models.DscConfiguration"]: """Retrieve a list of configurations. + .. seealso:: + - http://aka.ms/azureautomationsdk/configurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -591,7 +580,6 @@ def list_by_automation_account( :type top: int :param inlinecount: Return total rows. Default value is None. :type inlinecount: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DscConfiguration or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.DscConfiguration] :raises ~azure.core.exceptions.HttpResponseError: @@ -599,10 +587,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.DscConfigurationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -613,7 +601,7 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, @@ -622,19 +610,16 @@ def prepare_request(next_link=None): top=top, inlinecount=inlinecount, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DscConfigurationListResult", pipeline_response) @@ -644,10 +629,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -659,7 +645,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_node_configuration_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_node_configuration_operations.py index 9f8e09ce19bf..82a119d4cfa3 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_node_configuration_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_node_configuration_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,9 +20,8 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -29,7 +29,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._dsc_node_configuration_operations import ( build_create_or_update_request, build_delete_request, @@ -38,10 +37,10 @@ ) from .._vendor import AutomationClientMixinABC -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]] @@ -71,18 +70,20 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the Dsc node configurations by node configuration. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodeconfigurations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param node_configuration_name: The Dsc node configuration name. Required. :type node_configuration_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, @@ -93,24 +94,23 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, node_configuration_name=node_configuration_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -121,11 +121,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.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -133,18 +129,20 @@ async def get( ) -> _models.DscNodeConfiguration: """Retrieve the Dsc node configurations by node configuration. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodeconfigurations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param node_configuration_name: The Dsc node configuration name. Required. :type node_configuration_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DscNodeConfiguration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNodeConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -155,24 +153,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.DscNodeConfiguration] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, node_configuration_name=node_configuration_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -182,26 +179,22 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DscNodeConfiguration", pipeline_response) + deserialized = self._deserialize("DscNodeConfiguration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, automation_account_name: str, node_configuration_name: str, - parameters: Union[_models.DscNodeConfigurationCreateOrUpdateParameters, IO], + parameters: Union[_models.DscNodeConfigurationCreateOrUpdateParameters, IO[bytes]], **kwargs: Any - ) -> Optional[_models.DscNodeConfiguration]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -212,19 +205,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.DscNodeConfiguration]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DscNodeConfigurationCreateOrUpdateParameters") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, node_configuration_name=node_configuration_name, @@ -233,36 +226,34 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None + if response.status_code == 200: + deserialized = response.stream_download(self._client._pipeline) + if response.status_code == 201: - deserialized = self._deserialize("DscNodeConfiguration", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}" - } + return deserialized # type: ignore @overload async def begin_create_or_update( @@ -274,9 +265,12 @@ async def begin_create_or_update( *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[None]: + ) -> AsyncLROPoller[_models.DscNodeConfiguration]: """Create the node configuration identified by node configuration name. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodeconfigurations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -288,14 +282,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either DscNodeConfiguration or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.automation.models.DscNodeConfiguration] @@ -308,13 +294,16 @@ async def begin_create_or_update( resource_group_name: str, automation_account_name: str, node_configuration_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[None]: + ) -> AsyncLROPoller[_models.DscNodeConfiguration]: """Create the node configuration identified by node configuration name. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodeconfigurations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -322,18 +311,10 @@ async def begin_create_or_update( :param node_configuration_name: The Dsc node configuration name. Required. :type node_configuration_name: str :param parameters: The create or update parameters for configuration. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. 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 DscNodeConfiguration or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.automation.models.DscNodeConfiguration] @@ -346,32 +327,24 @@ async def begin_create_or_update( resource_group_name: str, automation_account_name: str, node_configuration_name: str, - parameters: Union[_models.DscNodeConfigurationCreateOrUpdateParameters, IO], + parameters: Union[_models.DscNodeConfigurationCreateOrUpdateParameters, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[None]: + ) -> AsyncLROPoller[_models.DscNodeConfiguration]: """Create the node configuration identified by node configuration name. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodeconfigurations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param node_configuration_name: The Dsc node configuration name. Required. :type node_configuration_name: str - :param parameters: The create or update parameters for configuration. Is either a model type or - a IO type. Required. + :param parameters: The create or update parameters for configuration. Is either a + DscNodeConfigurationCreateOrUpdateParameters type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.automation.models.DscNodeConfigurationCreateOrUpdateParameters or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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. + IO[bytes] :return: An instance of AsyncLROPoller that returns either DscNodeConfiguration or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.automation.models.DscNodeConfiguration] @@ -380,7 +353,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -399,12 +372,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DscNodeConfiguration", pipeline_response) + deserialized = self._deserialize("DscNodeConfiguration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -414,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.DscNodeConfiguration].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}" - } + return AsyncLROPoller[_models.DscNodeConfiguration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list_by_automation_account( @@ -439,6 +411,9 @@ def list_by_automation_account( ) -> AsyncIterable["_models.DscNodeConfiguration"]: """Retrieve a list of dsc node configurations. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodeconfigurations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -451,7 +426,6 @@ def list_by_automation_account( :type top: int :param inlinecount: Return total rows. Default value is None. :type inlinecount: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DscNodeConfiguration or the result of cls(response) :rtype: @@ -461,10 +435,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.DscNodeConfigurationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -475,7 +449,7 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, @@ -484,19 +458,16 @@ def prepare_request(next_link=None): top=top, inlinecount=inlinecount, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DscNodeConfigurationListResult", pipeline_response) @@ -506,10 +477,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -521,7 +493,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_node_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_node_operations.py index 90db769927b8..2b71db4b055d 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_node_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_node_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.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._dsc_node_operations import ( build_delete_request, build_get_request, @@ -36,10 +35,10 @@ ) from .._vendor import AutomationClientMixinABC -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]] @@ -69,18 +68,20 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the dsc node identified by node id. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param node_id: The node id. Required. :type node_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, @@ -91,26 +92,23 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, node_id=node_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -121,11 +119,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.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -133,18 +127,20 @@ async def get( ) -> _models.DscNode: """Retrieve the dsc node identified by node id. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param node_id: The node id. Required. :type node_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DscNode or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNode :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -155,26 +151,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.DscNode] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, node_id=node_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -184,16 +177,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DscNode", pipeline_response) + deserialized = self._deserialize("DscNode", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}" - } + return deserialized # type: ignore @overload async def update( @@ -208,6 +197,9 @@ async def update( ) -> _models.DscNode: """Update the dsc node. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -219,7 +211,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: DscNode or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNode :raises ~azure.core.exceptions.HttpResponseError: @@ -231,13 +222,16 @@ async def update( resource_group_name: str, automation_account_name: str, node_id: str, - dsc_node_update_parameters: IO, + dsc_node_update_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.DscNode: """Update the dsc node. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -245,11 +239,10 @@ async def update( :param node_id: Parameters supplied to the update dsc node. Required. :type node_id: str :param dsc_node_update_parameters: Parameters supplied to the update dsc node. Required. - :type dsc_node_update_parameters: IO + :type dsc_node_update_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DscNode or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNode :raises ~azure.core.exceptions.HttpResponseError: @@ -261,11 +254,14 @@ async def update( resource_group_name: str, automation_account_name: str, node_id: str, - dsc_node_update_parameters: Union[_models.DscNodeUpdateParameters, IO], + dsc_node_update_parameters: Union[_models.DscNodeUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.DscNode: """Update the dsc node. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -273,17 +269,14 @@ async def update( :param node_id: Parameters supplied to the update dsc node. Required. :type node_id: str :param dsc_node_update_parameters: Parameters supplied to the update dsc node. Is either a - model type or a IO type. Required. - :type dsc_node_update_parameters: ~azure.mgmt.automation.models.DscNodeUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + DscNodeUpdateParameters type or a IO[bytes] type. Required. + :type dsc_node_update_parameters: ~azure.mgmt.automation.models.DscNodeUpdateParameters or + IO[bytes] :return: DscNode or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNode :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -294,21 +287,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DscNode] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(dsc_node_update_parameters, (IO, bytes)): + if isinstance(dsc_node_update_parameters, (IOBase, bytes)): _content = dsc_node_update_parameters else: _json = self._serialize.body(dsc_node_update_parameters, "DscNodeUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, node_id=node_id, @@ -317,15 +308,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -335,16 +325,12 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DscNode", pipeline_response) + deserialized = self._deserialize("DscNode", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -359,6 +345,9 @@ def list_by_automation_account( ) -> AsyncIterable["_models.DscNode"]: """Retrieve a list of dsc nodes. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -371,7 +360,6 @@ def list_by_automation_account( :type top: int :param inlinecount: Return total rows. Default value is None. :type inlinecount: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DscNode or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.DscNode] :raises ~azure.core.exceptions.HttpResponseError: @@ -379,12 +367,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.DscNodeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -395,7 +381,7 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, @@ -404,19 +390,16 @@ def prepare_request(next_link=None): top=top, inlinecount=inlinecount, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DscNodeListResult", pipeline_response) @@ -426,10 +409,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -441,7 +425,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_fields_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_fields_operations.py index bf24b786c68e..63fbfef95dcf 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_fields_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_fields_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,21 +19,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._fields_operations import build_list_by_type_request from .._vendor import AutomationClientMixinABC -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]] @@ -63,6 +61,9 @@ def list_by_type( ) -> AsyncIterable["_models.TypeField"]: """Retrieve a list of fields of a given type identified by module name. + .. seealso:: + - http://aka.ms/azureautomationsdk/typefieldoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -71,7 +72,6 @@ def list_by_type( :type module_name: str :param type_name: The name of type. Required. :type type_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TypeField or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.TypeField] :raises ~azure.core.exceptions.HttpResponseError: @@ -79,10 +79,10 @@ def list_by_type( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.TypeFieldListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,26 +93,23 @@ def list_by_type( def prepare_request(next_link=None): if not next_link: - request = build_list_by_type_request( + _request = build_list_by_type_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, module_name=module_name, type_name=type_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_type.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("TypeFieldListResult", pipeline_response) @@ -122,10 +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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -137,7 +135,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_type.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/types/{typeName}/fields" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_hybrid_runbook_worker_group_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_hybrid_runbook_worker_group_operations.py index f806c6b894b2..e00ad5b67b85 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_hybrid_runbook_worker_group_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_hybrid_runbook_worker_group_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.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._hybrid_runbook_worker_group_operations import ( build_create_request, build_delete_request, @@ -37,10 +36,10 @@ ) from .._vendor import AutomationClientMixinABC -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]] @@ -74,18 +73,20 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete a hybrid runbook worker group. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkergroupoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. Required. :type hybrid_runbook_worker_group_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, @@ -96,24 +97,23 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -124,11 +124,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.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -140,18 +136,20 @@ async def get( ) -> _models.HybridRunbookWorkerGroup: """Retrieve a hybrid runbook worker group. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkergroupoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. Required. :type hybrid_runbook_worker_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridRunbookWorkerGroup or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -162,24 +160,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.HybridRunbookWorkerGroup] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -189,16 +186,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("HybridRunbookWorkerGroup", pipeline_response) + deserialized = self._deserialize("HybridRunbookWorkerGroup", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}" - } + return deserialized # type: ignore @overload async def create( @@ -213,6 +206,9 @@ async def create( ) -> _models.HybridRunbookWorkerGroup: """Create a hybrid runbook worker group. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkergroupoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -226,7 +222,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: HybridRunbookWorkerGroup or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup :raises ~azure.core.exceptions.HttpResponseError: @@ -238,13 +233,16 @@ async def create( resource_group_name: str, automation_account_name: str, hybrid_runbook_worker_group_name: str, - hybrid_runbook_worker_group_creation_parameters: IO, + hybrid_runbook_worker_group_creation_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.HybridRunbookWorkerGroup: """Create a hybrid runbook worker group. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkergroupoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -253,11 +251,10 @@ async def create( :type hybrid_runbook_worker_group_name: str :param hybrid_runbook_worker_group_creation_parameters: The create or update parameters for hybrid runbook worker group. Required. - :type hybrid_runbook_worker_group_creation_parameters: IO + :type hybrid_runbook_worker_group_creation_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridRunbookWorkerGroup or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup :raises ~azure.core.exceptions.HttpResponseError: @@ -270,12 +267,15 @@ async def create( automation_account_name: str, hybrid_runbook_worker_group_name: str, hybrid_runbook_worker_group_creation_parameters: Union[ - _models.HybridRunbookWorkerGroupCreateOrUpdateParameters, IO + _models.HybridRunbookWorkerGroupCreateOrUpdateParameters, IO[bytes] ], **kwargs: Any ) -> _models.HybridRunbookWorkerGroup: """Create a hybrid runbook worker group. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkergroupoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -283,18 +283,15 @@ async def create( :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. Required. :type hybrid_runbook_worker_group_name: str :param hybrid_runbook_worker_group_creation_parameters: The create or update parameters for - hybrid runbook worker group. Is either a model type or a IO type. Required. + hybrid runbook worker group. Is either a HybridRunbookWorkerGroupCreateOrUpdateParameters type + or a IO[bytes] type. Required. :type hybrid_runbook_worker_group_creation_parameters: - ~azure.mgmt.automation.models.HybridRunbookWorkerGroupCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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.automation.models.HybridRunbookWorkerGroupCreateOrUpdateParameters or IO[bytes] :return: HybridRunbookWorkerGroup or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -305,21 +302,21 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.HybridRunbookWorkerGroup] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(hybrid_runbook_worker_group_creation_parameters, (IO, bytes)): + if isinstance(hybrid_runbook_worker_group_creation_parameters, (IOBase, bytes)): _content = hybrid_runbook_worker_group_creation_parameters else: _json = self._serialize.body( hybrid_runbook_worker_group_creation_parameters, "HybridRunbookWorkerGroupCreateOrUpdateParameters" ) - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, @@ -328,15 +325,14 @@ async def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -347,20 +343,16 @@ async def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("HybridRunbookWorkerGroup", pipeline_response) + deserialized = self._deserialize("HybridRunbookWorkerGroup", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("HybridRunbookWorkerGroup", pipeline_response) + deserialized = self._deserialize("HybridRunbookWorkerGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}" - } - @overload async def update( self, @@ -374,6 +366,9 @@ async def update( ) -> _models.HybridRunbookWorkerGroup: """Update a hybrid runbook worker group. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkergroupoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -387,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: HybridRunbookWorkerGroup or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup :raises ~azure.core.exceptions.HttpResponseError: @@ -399,13 +393,16 @@ async def update( resource_group_name: str, automation_account_name: str, hybrid_runbook_worker_group_name: str, - hybrid_runbook_worker_group_updation_parameters: IO, + hybrid_runbook_worker_group_updation_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.HybridRunbookWorkerGroup: """Update a hybrid runbook worker group. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkergroupoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -414,11 +411,10 @@ async def update( :type hybrid_runbook_worker_group_name: str :param hybrid_runbook_worker_group_updation_parameters: The hybrid runbook worker group. Required. - :type hybrid_runbook_worker_group_updation_parameters: IO + :type hybrid_runbook_worker_group_updation_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridRunbookWorkerGroup or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup :raises ~azure.core.exceptions.HttpResponseError: @@ -431,12 +427,15 @@ async def update( automation_account_name: str, hybrid_runbook_worker_group_name: str, hybrid_runbook_worker_group_updation_parameters: Union[ - _models.HybridRunbookWorkerGroupCreateOrUpdateParameters, IO + _models.HybridRunbookWorkerGroupCreateOrUpdateParameters, IO[bytes] ], **kwargs: Any ) -> _models.HybridRunbookWorkerGroup: """Update a hybrid runbook worker group. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkergroupoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -444,18 +443,14 @@ async def update( :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. Required. :type hybrid_runbook_worker_group_name: str :param hybrid_runbook_worker_group_updation_parameters: The hybrid runbook worker group. Is - either a model type or a IO type. Required. + either a HybridRunbookWorkerGroupCreateOrUpdateParameters type or a IO[bytes] type. Required. :type hybrid_runbook_worker_group_updation_parameters: - ~azure.mgmt.automation.models.HybridRunbookWorkerGroupCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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.automation.models.HybridRunbookWorkerGroupCreateOrUpdateParameters or IO[bytes] :return: HybridRunbookWorkerGroup or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -466,21 +461,21 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.HybridRunbookWorkerGroup] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(hybrid_runbook_worker_group_updation_parameters, (IO, bytes)): + if isinstance(hybrid_runbook_worker_group_updation_parameters, (IOBase, bytes)): _content = hybrid_runbook_worker_group_updation_parameters else: _json = self._serialize.body( hybrid_runbook_worker_group_updation_parameters, "HybridRunbookWorkerGroupCreateOrUpdateParameters" ) - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, @@ -489,15 +484,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -507,16 +501,12 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("HybridRunbookWorkerGroup", pipeline_response) + deserialized = self._deserialize("HybridRunbookWorkerGroup", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -524,13 +514,15 @@ def list_by_automation_account( ) -> AsyncIterable["_models.HybridRunbookWorkerGroup"]: """Retrieve a list of hybrid runbook worker groups. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkergroupoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param filter: The filter to apply on the operation. 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 HybridRunbookWorkerGroup or the result of cls(response) :rtype: @@ -540,10 +532,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.HybridRunbookWorkerGroupsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -554,25 +546,22 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("HybridRunbookWorkerGroupsListResult", pipeline_response) @@ -582,10 +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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -597,7 +587,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_hybrid_runbook_workers_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_hybrid_runbook_workers_operations.py index 250602e6afec..621c268e8c6b 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_hybrid_runbook_workers_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_hybrid_runbook_workers_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.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._hybrid_runbook_workers_operations import ( build_create_request, build_delete_request, @@ -37,10 +36,10 @@ ) from .._vendor import AutomationClientMixinABC -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]] @@ -75,6 +74,9 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete a hybrid runbook worker. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkeroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -83,12 +85,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type hybrid_runbook_worker_group_name: str :param hybrid_runbook_worker_id: The hybrid runbook worker id. Required. :type hybrid_runbook_worker_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, @@ -99,25 +100,24 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, hybrid_runbook_worker_id=hybrid_runbook_worker_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -128,11 +128,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.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -145,6 +141,9 @@ async def get( ) -> _models.HybridRunbookWorker: """Retrieve a hybrid runbook worker. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkeroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -153,12 +152,11 @@ async def get( :type hybrid_runbook_worker_group_name: str :param hybrid_runbook_worker_id: The hybrid runbook worker id. Required. :type hybrid_runbook_worker_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridRunbookWorker or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorker :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -169,25 +167,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.HybridRunbookWorker] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, hybrid_runbook_worker_id=hybrid_runbook_worker_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -197,16 +194,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("HybridRunbookWorker", pipeline_response) + deserialized = self._deserialize("HybridRunbookWorker", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}" - } + return deserialized # type: ignore @overload async def create( @@ -222,6 +215,9 @@ async def create( ) -> _models.HybridRunbookWorker: """Create a hybrid runbook worker. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkeroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -237,7 +233,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: HybridRunbookWorker or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorker :raises ~azure.core.exceptions.HttpResponseError: @@ -250,13 +245,16 @@ async def create( automation_account_name: str, hybrid_runbook_worker_group_name: str, hybrid_runbook_worker_id: str, - hybrid_runbook_worker_creation_parameters: IO, + hybrid_runbook_worker_creation_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.HybridRunbookWorker: """Create a hybrid runbook worker. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkeroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -267,11 +265,10 @@ async def create( :type hybrid_runbook_worker_id: str :param hybrid_runbook_worker_creation_parameters: The create or update parameters for hybrid runbook worker. Required. - :type hybrid_runbook_worker_creation_parameters: IO + :type hybrid_runbook_worker_creation_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridRunbookWorker or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorker :raises ~azure.core.exceptions.HttpResponseError: @@ -284,11 +281,14 @@ async def create( automation_account_name: str, hybrid_runbook_worker_group_name: str, hybrid_runbook_worker_id: str, - hybrid_runbook_worker_creation_parameters: Union[_models.HybridRunbookWorkerCreateParameters, IO], + hybrid_runbook_worker_creation_parameters: Union[_models.HybridRunbookWorkerCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.HybridRunbookWorker: """Create a hybrid runbook worker. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkeroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -298,18 +298,15 @@ async def create( :param hybrid_runbook_worker_id: The hybrid runbook worker id. Required. :type hybrid_runbook_worker_id: str :param hybrid_runbook_worker_creation_parameters: The create or update parameters for hybrid - runbook worker. Is either a model type or a IO type. Required. + runbook worker. Is either a HybridRunbookWorkerCreateParameters type or a IO[bytes] type. + Required. :type hybrid_runbook_worker_creation_parameters: - ~azure.mgmt.automation.models.HybridRunbookWorkerCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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.automation.models.HybridRunbookWorkerCreateParameters or IO[bytes] :return: HybridRunbookWorker or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorker :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -320,21 +317,21 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.HybridRunbookWorker] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(hybrid_runbook_worker_creation_parameters, (IO, bytes)): + if isinstance(hybrid_runbook_worker_creation_parameters, (IOBase, bytes)): _content = hybrid_runbook_worker_creation_parameters else: _json = self._serialize.body( hybrid_runbook_worker_creation_parameters, "HybridRunbookWorkerCreateParameters" ) - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, @@ -344,15 +341,14 @@ async def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -363,20 +359,16 @@ async def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("HybridRunbookWorker", pipeline_response) + deserialized = self._deserialize("HybridRunbookWorker", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("HybridRunbookWorker", pipeline_response) + deserialized = self._deserialize("HybridRunbookWorker", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}" - } - @overload async def move( # pylint: disable=inconsistent-return-statements self, @@ -391,6 +383,9 @@ async def move( # pylint: disable=inconsistent-return-statements ) -> None: """Move a hybrid worker to a different group. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkeroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -406,7 +401,6 @@ async def move( # 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: @@ -419,13 +413,16 @@ async def move( # pylint: disable=inconsistent-return-statements automation_account_name: str, hybrid_runbook_worker_group_name: str, hybrid_runbook_worker_id: str, - hybrid_runbook_worker_move_parameters: IO, + hybrid_runbook_worker_move_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> None: """Move a hybrid worker to a different group. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkeroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -436,11 +433,10 @@ async def move( # pylint: disable=inconsistent-return-statements :type hybrid_runbook_worker_id: str :param hybrid_runbook_worker_move_parameters: The hybrid runbook worker move parameters. Required. - :type hybrid_runbook_worker_move_parameters: IO + :type hybrid_runbook_worker_move_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default 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: @@ -453,11 +449,14 @@ async def move( # pylint: disable=inconsistent-return-statements automation_account_name: str, hybrid_runbook_worker_group_name: str, hybrid_runbook_worker_id: str, - hybrid_runbook_worker_move_parameters: Union[_models.HybridRunbookWorkerMoveParameters, IO], + hybrid_runbook_worker_move_parameters: Union[_models.HybridRunbookWorkerMoveParameters, IO[bytes]], **kwargs: Any ) -> None: """Move a hybrid worker to a different group. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkeroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -467,18 +466,14 @@ async def move( # pylint: disable=inconsistent-return-statements :param hybrid_runbook_worker_id: The hybrid runbook worker id. Required. :type hybrid_runbook_worker_id: str :param hybrid_runbook_worker_move_parameters: The hybrid runbook worker move parameters. Is - either a model type or a IO type. Required. + either a HybridRunbookWorkerMoveParameters type or a IO[bytes] type. Required. :type hybrid_runbook_worker_move_parameters: - ~azure.mgmt.automation.models.HybridRunbookWorkerMoveParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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.automation.models.HybridRunbookWorkerMoveParameters 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, @@ -489,19 +484,19 @@ async def move( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(hybrid_runbook_worker_move_parameters, (IO, bytes)): + if isinstance(hybrid_runbook_worker_move_parameters, (IOBase, bytes)): _content = hybrid_runbook_worker_move_parameters else: _json = self._serialize.body(hybrid_runbook_worker_move_parameters, "HybridRunbookWorkerMoveParameters") - request = build_move_request( + _request = build_move_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, @@ -511,15 +506,14 @@ async def move( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.move.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -530,11 +524,7 @@ async def move( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - move.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}/move" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_by_hybrid_runbook_worker_group( @@ -547,6 +537,9 @@ def list_by_hybrid_runbook_worker_group( ) -> AsyncIterable["_models.HybridRunbookWorker"]: """Retrieve a list of hybrid runbook workers. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkeroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -555,7 +548,6 @@ def list_by_hybrid_runbook_worker_group( :type hybrid_runbook_worker_group_name: str :param filter: The filter to apply on the operation. 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 HybridRunbookWorker or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.HybridRunbookWorker] @@ -564,10 +556,10 @@ def list_by_hybrid_runbook_worker_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.HybridRunbookWorkersListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -578,26 +570,23 @@ def list_by_hybrid_runbook_worker_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_hybrid_runbook_worker_group_request( + _request = build_list_by_hybrid_runbook_worker_group_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_hybrid_runbook_worker_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("HybridRunbookWorkersListResult", pipeline_response) @@ -607,10 +596,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -622,7 +612,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_hybrid_runbook_worker_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_operations.py index 294a6b54fe5f..4b5a81fff4f3 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.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._job_operations import ( build_create_request, build_get_output_request, @@ -40,10 +39,10 @@ ) from .._vendor import AutomationClientMixinABC -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]] @@ -78,6 +77,9 @@ async def get_output( ) -> str: """Retrieve the job output identified by job name. + .. seealso:: + - http://aka.ms/azureautomationsdk/joboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -86,12 +88,11 @@ async def get_output( :type job_name: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: str or the result of cls(response) :rtype: str :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -102,25 +103,24 @@ async def get_output( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[str] = kwargs.pop("cls", None) - request = build_get_output_request( + _request = build_get_output_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_name=job_name, subscription_id=self._config.subscription_id, client_request_id=client_request_id, api_version=api_version, - template_url=self.get_output.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -129,16 +129,12 @@ async def get_output( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("str", pipeline_response) + deserialized = self._deserialize("str", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_output.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/output" - } + return deserialized # type: ignore @distributed_trace_async async def get_runbook_content( @@ -151,6 +147,9 @@ async def get_runbook_content( ) -> str: """Retrieve the runbook content of the job identified by job name. + .. seealso:: + - http://aka.ms/azureautomationsdk/joboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -159,12 +158,11 @@ async def get_runbook_content( :type job_name: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: str or the result of cls(response) :rtype: str :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -175,25 +173,24 @@ async def get_runbook_content( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[str] = kwargs.pop("cls", None) - request = build_get_runbook_content_request( + _request = build_get_runbook_content_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_name=job_name, subscription_id=self._config.subscription_id, client_request_id=client_request_id, api_version=api_version, - template_url=self.get_runbook_content.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -202,16 +199,12 @@ async def get_runbook_content( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("str", pipeline_response) + deserialized = self._deserialize("str", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_runbook_content.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/runbookContent" - } + return deserialized # type: ignore @distributed_trace_async async def suspend( # pylint: disable=inconsistent-return-statements @@ -224,6 +217,9 @@ async def suspend( # pylint: disable=inconsistent-return-statements ) -> None: """Suspend the job identified by job name. + .. seealso:: + - http://aka.ms/azureautomationsdk/joboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -232,12 +228,11 @@ async def suspend( # pylint: disable=inconsistent-return-statements :type job_name: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_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, @@ -248,25 +243,24 @@ async def suspend( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_suspend_request( + _request = build_suspend_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_name=job_name, subscription_id=self._config.subscription_id, client_request_id=client_request_id, api_version=api_version, - template_url=self.suspend.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -277,11 +271,7 @@ async def suspend( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - suspend.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/suspend" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def stop( # pylint: disable=inconsistent-return-statements @@ -294,6 +284,9 @@ async def stop( # pylint: disable=inconsistent-return-statements ) -> None: """Stop the job identified by jobName. + .. seealso:: + - http://aka.ms/azureautomationsdk/joboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -302,12 +295,11 @@ async def stop( # pylint: disable=inconsistent-return-statements :type job_name: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_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, @@ -318,25 +310,24 @@ async def stop( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_name=job_name, subscription_id=self._config.subscription_id, client_request_id=client_request_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -347,11 +338,7 @@ async def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -364,6 +351,9 @@ async def get( ) -> _models.Job: """Retrieve the job identified by job name. + .. seealso:: + - http://aka.ms/azureautomationsdk/joboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -372,12 +362,11 @@ async def get( :type job_name: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Job or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Job :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -388,25 +377,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.Job] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_name=job_name, subscription_id=self._config.subscription_id, client_request_id=client_request_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -416,16 +404,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Job", pipeline_response) + deserialized = self._deserialize("Job", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}" - } + return deserialized # type: ignore @overload async def create( @@ -441,6 +425,9 @@ async def create( ) -> _models.Job: """Create a job of the runbook. + .. seealso:: + - http://aka.ms/azureautomationsdk/joboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -454,7 +441,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: Job or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Job :raises ~azure.core.exceptions.HttpResponseError: @@ -466,7 +452,7 @@ async def create( resource_group_name: str, automation_account_name: str, job_name: str, - parameters: IO, + parameters: IO[bytes], client_request_id: Optional[str] = None, *, content_type: str = "application/json", @@ -474,6 +460,9 @@ async def create( ) -> _models.Job: """Create a job of the runbook. + .. seealso:: + - http://aka.ms/azureautomationsdk/joboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -481,13 +470,12 @@ async def create( :param job_name: The job name. Required. :type job_name: str :param parameters: The parameters supplied to the create job operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: 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: Job or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Job :raises ~azure.core.exceptions.HttpResponseError: @@ -499,32 +487,31 @@ async def create( resource_group_name: str, automation_account_name: str, job_name: str, - parameters: Union[_models.JobCreateParameters, IO], + parameters: Union[_models.JobCreateParameters, IO[bytes]], client_request_id: Optional[str] = None, **kwargs: Any ) -> _models.Job: """Create a job of the runbook. + .. seealso:: + - http://aka.ms/azureautomationsdk/joboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param job_name: The job name. Required. :type job_name: str - :param parameters: The parameters supplied to the create job operation. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.JobCreateParameters or IO + :param parameters: The parameters supplied to the create job operation. Is either a + JobCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.JobCreateParameters or IO[bytes] :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: 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: Job or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Job :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -535,19 +522,19 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Job] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "JobCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_name=job_name, @@ -557,15 +544,14 @@ async def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -575,16 +561,12 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Job", pipeline_response) + deserialized = self._deserialize("Job", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -597,6 +579,9 @@ def list_by_automation_account( ) -> AsyncIterable["_models.JobCollectionItem"]: """Retrieve a list of jobs. + .. seealso:: + - http://aka.ms/azureautomationsdk/joboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -605,7 +590,6 @@ def list_by_automation_account( :type filter: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either JobCollectionItem or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.JobCollectionItem] @@ -614,10 +598,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.JobListResultV2] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -628,26 +612,23 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, filter=filter, client_request_id=client_request_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("JobListResultV2", pipeline_response) @@ -657,10 +638,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -673,10 +655,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs" - } - @distributed_trace_async async def resume( # pylint: disable=inconsistent-return-statements self, @@ -688,6 +666,9 @@ async def resume( # pylint: disable=inconsistent-return-statements ) -> None: """Resume the job identified by jobName. + .. seealso:: + - http://aka.ms/azureautomationsdk/joboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -696,12 +677,11 @@ async def resume( # pylint: disable=inconsistent-return-statements :type job_name: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_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, @@ -712,25 +692,24 @@ async def resume( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_resume_request( + _request = build_resume_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_name=job_name, subscription_id=self._config.subscription_id, client_request_id=client_request_id, api_version=api_version, - template_url=self.resume.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -741,8 +720,4 @@ async def resume( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - resume.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/resume" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_schedule_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_schedule_operations.py index 1b87fe2cc35c..f2a38dab45e6 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_schedule_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_schedule_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.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._job_schedule_operations import ( build_create_request, build_delete_request, @@ -36,10 +35,10 @@ ) from .._vendor import AutomationClientMixinABC -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]] @@ -69,18 +68,20 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the job schedule identified by job schedule name. + .. seealso:: + - http://aka.ms/azureautomationsdk/jobscheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param job_schedule_id: The job schedule name. Required. :type job_schedule_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, @@ -91,24 +92,23 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_schedule_id=job_schedule_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -119,11 +119,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.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -131,18 +127,20 @@ async def get( ) -> _models.JobSchedule: """Retrieve the job schedule identified by job schedule name. + .. seealso:: + - http://aka.ms/azureautomationsdk/jobscheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param job_schedule_id: The job schedule name. Required. :type job_schedule_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: JobSchedule or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobSchedule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -153,24 +151,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.JobSchedule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_schedule_id=job_schedule_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -180,16 +177,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("JobSchedule", pipeline_response) + deserialized = self._deserialize("JobSchedule", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}" - } + return deserialized # type: ignore @overload async def create( @@ -204,6 +197,9 @@ async def create( ) -> _models.JobSchedule: """Create a job schedule. + .. seealso:: + - http://aka.ms/azureautomationsdk/jobscheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -215,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: JobSchedule or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobSchedule :raises ~azure.core.exceptions.HttpResponseError: @@ -227,13 +222,16 @@ async def create( resource_group_name: str, automation_account_name: str, job_schedule_id: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.JobSchedule: """Create a job schedule. + .. seealso:: + - http://aka.ms/azureautomationsdk/jobscheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -241,11 +239,10 @@ async def create( :param job_schedule_id: The job schedule name. Required. :type job_schedule_id: str :param parameters: The parameters supplied to the create job schedule operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: JobSchedule or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobSchedule :raises ~azure.core.exceptions.HttpResponseError: @@ -257,11 +254,14 @@ async def create( resource_group_name: str, automation_account_name: str, job_schedule_id: str, - parameters: Union[_models.JobScheduleCreateParameters, IO], + parameters: Union[_models.JobScheduleCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.JobSchedule: """Create a job schedule. + .. seealso:: + - http://aka.ms/azureautomationsdk/jobscheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -269,17 +269,13 @@ async def create( :param job_schedule_id: The job schedule name. Required. :type job_schedule_id: str :param parameters: The parameters supplied to the create job schedule operation. Is either a - model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.JobScheduleCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + JobScheduleCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.JobScheduleCreateParameters or IO[bytes] :return: JobSchedule or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobSchedule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -290,19 +286,19 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobSchedule] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "JobScheduleCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_schedule_id=job_schedule_id, @@ -311,15 +307,14 @@ async def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -329,16 +324,12 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("JobSchedule", pipeline_response) + deserialized = self._deserialize("JobSchedule", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -346,13 +337,15 @@ def list_by_automation_account( ) -> AsyncIterable["_models.JobSchedule"]: """Retrieve a list of job schedules. + .. seealso:: + - http://aka.ms/azureautomationsdk/jobscheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param filter: The filter to apply on the operation. 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 JobSchedule or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.JobSchedule] :raises ~azure.core.exceptions.HttpResponseError: @@ -360,10 +353,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.JobScheduleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -374,25 +367,22 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("JobScheduleListResult", pipeline_response) @@ -402,10 +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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -417,7 +408,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_stream_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_stream_operations.py index b815bac87793..9b84ea7cd735 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_stream_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_stream_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,22 +19,20 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.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._job_stream_operations import build_get_request, build_list_by_job_request from .._vendor import AutomationClientMixinABC -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]] @@ -70,6 +68,9 @@ async def get( ) -> _models.JobStream: """Retrieve the job stream identified by job stream id. + .. seealso:: + - http://aka.ms/azureautomationsdk/jobstreamoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -80,12 +81,11 @@ async def get( :type job_stream_id: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: JobStream or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobStream :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,10 +96,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.JobStream] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_name=job_name, @@ -107,15 +107,14 @@ async def get( subscription_id=self._config.subscription_id, client_request_id=client_request_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -125,16 +124,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("JobStream", pipeline_response) + deserialized = self._deserialize("JobStream", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams/{jobStreamId}" - } + return deserialized # type: ignore @distributed_trace def list_by_job( @@ -148,6 +143,9 @@ def list_by_job( ) -> AsyncIterable["_models.JobStream"]: """Retrieve a list of jobs streams identified by job name. + .. seealso:: + - http://aka.ms/azureautomationsdk/jobstreamoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -158,7 +156,6 @@ def list_by_job( :type filter: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either JobStream or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.JobStream] :raises ~azure.core.exceptions.HttpResponseError: @@ -166,10 +163,10 @@ def list_by_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.JobStreamListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -180,7 +177,7 @@ def list_by_job( def prepare_request(next_link=None): if not next_link: - request = build_list_by_job_request( + _request = build_list_by_job_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_name=job_name, @@ -188,19 +185,16 @@ def prepare_request(next_link=None): filter=filter, client_request_id=client_request_id, api_version=api_version, - template_url=self.list_by_job.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("JobStreamListResult", pipeline_response) @@ -210,10 +204,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -225,7 +220,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_job.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_keys_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_keys_operations.py index 8f4a8d9484f8..9064b1a62afc 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_keys_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_keys_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, TypeVar +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,21 +18,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_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._keys_operations import build_list_by_automation_account_request from .._vendor import AutomationClientMixinABC -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]] @@ -66,12 +64,11 @@ async def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: KeyListResult or the result of cls(response) :rtype: ~azure.mgmt.automation.models.KeyListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,23 +79,22 @@ async def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -108,13 +104,9 @@ async def list_by_automation_account( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("KeyListResult", pipeline_response) + deserialized = self._deserialize("KeyListResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/listKeys" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_linked_workspace_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_linked_workspace_operations.py index c383a374464f..0309bdb70cdf 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_linked_workspace_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_linked_workspace_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, TypeVar +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,21 +18,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_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._linked_workspace_operations import build_get_request from .._vendor import AutomationClientMixinABC -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]] @@ -62,16 +60,18 @@ async def get( ) -> _models.LinkedWorkspace: """Retrieve the linked workspace for the account id. + .. seealso:: + - http://aka.ms/azureautomationsdk/linkedworkspaceoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LinkedWorkspace or the result of cls(response) :rtype: ~azure.mgmt.automation.models.LinkedWorkspace :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,23 +82,22 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.LinkedWorkspace] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -108,13 +107,9 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("LinkedWorkspace", pipeline_response) + deserialized = self._deserialize("LinkedWorkspace", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/linkedWorkspace" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_module_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_module_operations.py index f6de70a18d40..3a6b6bca7abb 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_module_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_module_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,15 +20,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict 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._module_operations import ( build_create_or_update_request, build_delete_request, @@ -37,10 +38,10 @@ ) from .._vendor import AutomationClientMixinABC -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]] @@ -70,18 +71,20 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the module by name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param module_name: The module name. Required. :type module_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, @@ -92,24 +95,23 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, module_name=module_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -120,11 +122,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.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -132,18 +130,20 @@ async def get( ) -> _models.Module: """Retrieve the module identified by module name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param module_name: The module name. Required. :type module_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -154,24 +154,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.Module] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, module_name=module_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -181,19 +180,84 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Module", pipeline_response) + deserialized = self._deserialize("Module", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}" - } + async def _create_or_update_initial( + self, + resource_group_name: str, + automation_account_name: str, + module_name: str, + parameters: Union[_models.ModuleCreateOrUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ModuleCreateOrUpdateParameters") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + await response.read() # Load the body in memory and close the socket + 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 = response.stream_download(self._client._pipeline) + + if response.status_code == 201: + deserialized = response.stream_download(self._client._pipeline) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @overload - async def create_or_update( + async def begin_create_or_update( self, resource_group_name: str, automation_account_name: str, @@ -202,9 +266,12 @@ async def create_or_update( *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Module: + ) -> AsyncLROPoller[_models.Module]: """Create or Update the module identified by module name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -216,25 +283,28 @@ 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: Module or the result of cls(response) - :rtype: ~azure.mgmt.automation.models.Module + :return: An instance of AsyncLROPoller that returns either Module or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.automation.models.Module] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create_or_update( + async def begin_create_or_update( self, resource_group_name: str, automation_account_name: str, module_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Module: + ) -> AsyncLROPoller[_models.Module]: """Create or Update the module identified by module name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -242,109 +312,94 @@ async def create_or_update( :param module_name: The name of module. Required. :type module_name: str :param parameters: The create or update parameters for module. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Module or the result of cls(response) - :rtype: ~azure.mgmt.automation.models.Module + :return: An instance of AsyncLROPoller that returns either Module or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.automation.models.Module] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def create_or_update( + async def begin_create_or_update( self, resource_group_name: str, automation_account_name: str, module_name: str, - parameters: Union[_models.ModuleCreateOrUpdateParameters, IO], + parameters: Union[_models.ModuleCreateOrUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.Module: + ) -> AsyncLROPoller[_models.Module]: """Create or Update the module identified by module name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param module_name: The name of module. Required. :type module_name: str - :param parameters: The create or update parameters for module. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.automation.models.ModuleCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Module or the result of cls(response) - :rtype: ~azure.mgmt.automation.models.Module + :param parameters: The create or update parameters for module. Is either a + ModuleCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.ModuleCreateOrUpdateParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either Module or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.automation.models.Module] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Module] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ModuleCreateOrUpdateParameters") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - automation_account_name=automation_account_name, - module_name=module_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Module", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + 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.Module].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Module]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - 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("Module", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Module", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}" - } - @overload async def update( self, @@ -358,6 +413,9 @@ async def update( ) -> _models.Module: """Update the module identified by module name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -369,7 +427,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: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: @@ -381,13 +438,16 @@ async def update( resource_group_name: str, automation_account_name: str, module_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Module: """Update the module identified by module name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -395,11 +455,10 @@ async def update( :param module_name: The name of module. Required. :type module_name: str :param parameters: The update parameters for module. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: @@ -411,29 +470,28 @@ async def update( resource_group_name: str, automation_account_name: str, module_name: str, - parameters: Union[_models.ModuleUpdateParameters, IO], + parameters: Union[_models.ModuleUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Module: """Update the module identified by module name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param module_name: The name of module. Required. :type module_name: str - :param parameters: The update parameters for module. Is either a model type or a IO type. - Required. - :type parameters: ~azure.mgmt.automation.models.ModuleUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 update parameters for module. Is either a ModuleUpdateParameters type or + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.ModuleUpdateParameters or IO[bytes] :return: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -444,19 +502,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Module] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ModuleUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, module_name=module_name, @@ -465,15 +523,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -483,16 +540,12 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Module", pipeline_response) + deserialized = self._deserialize("Module", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -500,11 +553,13 @@ def list_by_automation_account( ) -> AsyncIterable["_models.Module"]: """Retrieve a list of modules. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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 Module or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.Module] :raises ~azure.core.exceptions.HttpResponseError: @@ -512,10 +567,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.ModuleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -526,24 +581,21 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ModuleListResult", pipeline_response) @@ -553,10 +605,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -568,7 +621,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_node_count_information_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_node_count_information_operations.py index 9c3773f1b89b..0877b19c9091 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_node_count_information_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_node_count_information_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, TypeVar, Union +from typing import Any, Callable, Dict, Optional, Type, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,21 +18,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_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._node_count_information_operations import build_get_request from .._vendor import AutomationClientMixinABC -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]] @@ -66,6 +64,9 @@ async def get( ) -> _models.NodeCounts: """Retrieve counts for Dsc Nodes. + .. seealso:: + - http://aka.ms/azureautomationsdk/nodecounts + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -73,12 +74,11 @@ async def get( :param count_type: The type of counts to retrieve. Known values are: "status" and "nodeconfiguration". Required. :type count_type: str or ~azure.mgmt.automation.models.CountType - :keyword callable cls: A custom type or function that will be passed the direct response :return: NodeCounts or the result of cls(response) :rtype: ~azure.mgmt.automation.models.NodeCounts :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,26 +89,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.NodeCounts] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, count_type=count_type, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -118,13 +115,9 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("NodeCounts", pipeline_response) + deserialized = self._deserialize("NodeCounts", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodecounts/{countType}" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_node_reports_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_node_reports_operations.py index f69a5d6d25f4..2bace1c00728 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_node_reports_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_node_reports_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,15 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.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._node_reports_operations import ( build_get_content_request, build_get_request, @@ -39,10 +37,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 JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -78,6 +72,9 @@ def list_by_node( ) -> AsyncIterable["_models.DscNodeReport"]: """Retrieve the Dsc node report list by node id. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodereportoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -86,7 +83,6 @@ def list_by_node( :type node_id: str :param filter: The filter to apply on the operation. 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 DscNodeReport or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.DscNodeReport] :raises ~azure.core.exceptions.HttpResponseError: @@ -94,12 +90,10 @@ def list_by_node( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.DscNodeReportListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -110,26 +104,23 @@ def list_by_node( def prepare_request(next_link=None): if not next_link: - request = build_list_by_node_request( + _request = build_list_by_node_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, node_id=node_id, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_node.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DscNodeReportListResult", pipeline_response) @@ -139,10 +130,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,16 +147,15 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_node.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports" - } - @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, node_id: str, report_id: str, **kwargs: Any ) -> _models.DscNodeReport: """Retrieve the Dsc node report data by node id and report id. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodereportoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -173,12 +164,11 @@ async def get( :type node_id: str :param report_id: The report id. Required. :type report_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DscNodeReport or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNodeReport :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -189,27 +179,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.DscNodeReport] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, node_id=node_id, report_id=report_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -219,16 +206,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DscNodeReport", pipeline_response) + deserialized = self._deserialize("DscNodeReport", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}" - } + return deserialized # type: ignore @distributed_trace_async async def get_content( @@ -236,6 +219,9 @@ async def get_content( ) -> JSON: """Retrieve the Dsc node reports by node id and report id. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodereportoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -244,12 +230,11 @@ async def get_content( :type node_id: str :param report_id: The report id. Required. :type report_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: JSON or the result of cls(response) :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -260,27 +245,24 @@ async def get_content( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_get_content_request( + _request = build_get_content_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, node_id=node_id, report_id=report_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_content.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -290,13 +272,9 @@ async def get_content( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_content.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}/content" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_object_data_types_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_object_data_types_operations.py index 2a5725fd5a63..77021b2d19d3 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_object_data_types_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_object_data_types_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,24 +19,22 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._object_data_types_operations import ( build_list_fields_by_module_and_type_request, build_list_fields_by_type_request, ) from .._vendor import AutomationClientMixinABC -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]] @@ -66,6 +64,9 @@ def list_fields_by_module_and_type( ) -> AsyncIterable["_models.TypeField"]: """Retrieve a list of fields of a given type identified by module name. + .. seealso:: + - http://aka.ms/azureautomationsdk/objectdatatypeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -74,7 +75,6 @@ def list_fields_by_module_and_type( :type module_name: str :param type_name: The name of type. Required. :type type_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TypeField or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.TypeField] :raises ~azure.core.exceptions.HttpResponseError: @@ -82,10 +82,10 @@ def list_fields_by_module_and_type( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.TypeFieldListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,26 +96,23 @@ def list_fields_by_module_and_type( def prepare_request(next_link=None): if not next_link: - request = build_list_fields_by_module_and_type_request( + _request = build_list_fields_by_module_and_type_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, module_name=module_name, type_name=type_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_fields_by_module_and_type.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("TypeFieldListResult", pipeline_response) @@ -125,10 +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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -141,23 +139,21 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_fields_by_module_and_type.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/objectDataTypes/{typeName}/fields" - } - @distributed_trace def list_fields_by_type( self, resource_group_name: str, automation_account_name: str, type_name: str, **kwargs: Any ) -> AsyncIterable["_models.TypeField"]: """Retrieve a list of fields of a given type across all accessible modules. + .. seealso:: + - http://aka.ms/azureautomationsdk/objectdatatypeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param type_name: The name of type. Required. :type type_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TypeField or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.TypeField] :raises ~azure.core.exceptions.HttpResponseError: @@ -165,10 +161,10 @@ def list_fields_by_type( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.TypeFieldListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -179,25 +175,22 @@ def list_fields_by_type( def prepare_request(next_link=None): if not next_link: - request = build_list_fields_by_type_request( + _request = build_list_fields_by_type_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, type_name=type_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_fields_by_type.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("TypeFieldListResult", pipeline_response) @@ -207,10 +200,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -222,7 +216,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_fields_by_type.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/objectDataTypes/{typeName}/fields" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_operations.py index 3599d8fec14d..a3b6321b8830 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/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. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,21 +19,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operations import build_list_request from .._vendor import AutomationClientMixinABC -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]] @@ -61,7 +59,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Automation 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.automation.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -69,10 +66,10 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,21 +80,18 @@ 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.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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) @@ -107,10 +101,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -122,5 +117,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Automation/operations"} diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_power_shell72_module_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_power_shell72_module_operations.py new file mode 100644 index 000000000000..9734056d22d5 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_power_shell72_module_operations.py @@ -0,0 +1,632 @@ +# 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, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload + +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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._power_shell72_module_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_automation_account_request, + build_update_request, +) +from .._vendor import AutomationClientMixinABC + +if sys.version_info >= (3, 9): + 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 PowerShell72ModuleOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`power_shell72_module` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, automation_account_name: str, module_name: str, **kwargs: Any + ) -> None: + """Delete the module by name. + + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. Required. + :type automation_account_name: str + :param module_name: The name of module. Required. + :type module_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", "2023-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 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 get( + self, resource_group_name: str, automation_account_name: str, module_name: str, **kwargs: Any + ) -> _models.Module: + """Retrieve the module identified by module name. + + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. Required. + :type automation_account_name: str + :param module_name: The name of module. Required. + :type module_name: str + :return: Module or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.Module + :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", "2023-11-01")) + cls: ClsType[_models.Module] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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("Module", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + automation_account_name: str, + module_name: str, + parameters: Union[_models.ModuleCreateOrUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ModuleCreateOrUpdateParameters") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + await response.read() # Load the body in memory and close the socket + 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 = response.stream_download(self._client._pipeline) + + if response.status_code == 201: + deserialized = response.stream_download(self._client._pipeline) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + automation_account_name: str, + module_name: str, + parameters: _models.ModuleCreateOrUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Module]: + """Create or Update the module identified by module name. + + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. Required. + :type automation_account_name: str + :param module_name: The name of module. Required. + :type module_name: str + :param parameters: The create or update parameters for module. Required. + :type parameters: ~azure.mgmt.automation.models.ModuleCreateOrUpdateParameters + :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 Module or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.automation.models.Module] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + automation_account_name: str, + module_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Module]: + """Create or Update the module identified by module name. + + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. Required. + :type automation_account_name: str + :param module_name: The name of module. Required. + :type module_name: str + :param parameters: The create or update parameters for module. 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 Module or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.automation.models.Module] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + automation_account_name: str, + module_name: str, + parameters: Union[_models.ModuleCreateOrUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Module]: + """Create or Update the module identified by module name. + + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. Required. + :type automation_account_name: str + :param module_name: The name of module. Required. + :type module_name: str + :param parameters: The create or update parameters for module. Is either a + ModuleCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.ModuleCreateOrUpdateParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either Module or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.automation.models.Module] + :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", "2023-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Module] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Module", pipeline_response.http_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.Module].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Module]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @overload + async def update( + self, + resource_group_name: str, + automation_account_name: str, + module_name: str, + parameters: _models.ModuleUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Module: + """Update the module identified by module name. + + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. Required. + :type automation_account_name: str + :param module_name: The name of module. Required. + :type module_name: str + :param parameters: The update parameters for module. Required. + :type parameters: ~azure.mgmt.automation.models.ModuleUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Module or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.Module + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + automation_account_name: str, + module_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Module: + """Update the module identified by module name. + + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. Required. + :type automation_account_name: str + :param module_name: The name of module. Required. + :type module_name: str + :param parameters: The update parameters for module. 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: Module or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.Module + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + automation_account_name: str, + module_name: str, + parameters: Union[_models.ModuleUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> _models.Module: + """Update the module identified by module name. + + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. Required. + :type automation_account_name: str + :param module_name: The name of module. Required. + :type module_name: str + :param parameters: The update parameters for module. Is either a ModuleUpdateParameters type or + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.ModuleUpdateParameters or IO[bytes] + :return: Module or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.Module + :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", "2023-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Module] = 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, "ModuleUpdateParameters") + + _request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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("Module", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_automation_account( + self, resource_group_name: str, automation_account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Module"]: + """Retrieve a list of PowerShell72 modules. + + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. Required. + :type automation_account_name: str + :return: An iterator like instance of either Module or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.Module] + :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", "2023-11-01")) + cls: ClsType[_models.ModuleListResult] = 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_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ModuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_private_endpoint_connections_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_private_endpoint_connections_operations.py index 5325585a9f77..1a4751dd9a1d 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,9 +20,8 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -29,7 +29,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._private_endpoint_connections_operations import ( build_create_or_update_request, build_delete_request, @@ -38,10 +37,10 @@ ) from .._vendor import AutomationClientMixinABC -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]] @@ -75,7 +74,6 @@ def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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: @@ -85,12 +83,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,24 +97,21 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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) @@ -128,10 +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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -143,10 +137,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections" - } - @distributed_trace_async async def get( self, @@ -163,12 +153,11 @@ async def get( :type automation_account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.automation.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -179,26 +168,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -207,26 +193,22 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, automation_account_name: str, private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any - ) -> Optional[_models.PrivateEndpointConnection]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -237,21 +219,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "PrivateEndpointConnection") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -260,36 +240,34 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) - if cls: - return cls(pipeline_response, deserialized, {}) + if response.status_code == 202: + deserialized = response.stream_download(self._client._pipeline) - return deserialized + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload async def begin_create_or_update( @@ -315,14 +293,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -336,7 +306,7 @@ async def begin_create_or_update( resource_group_name: str, automation_account_name: str, private_endpoint_connection_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -350,18 +320,10 @@ async def begin_create_or_update( :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param parameters: Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -375,7 +337,7 @@ async def begin_create_or_update( resource_group_name: str, automation_account_name: str, private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection with a given name. @@ -386,19 +348,8 @@ async def begin_create_or_update( :type automation_account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :param parameters: Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.PrivateEndpointConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param parameters: Is either a PrivateEndpointConnection type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.PrivateEndpointConnection or IO[bytes] :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -408,9 +359,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -429,12 +378,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -444,26 +394,24 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.PrivateEndpointConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return AsyncLROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, automation_account_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -474,41 +422,43 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + await response.read() # Load the body in memory and close the socket 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 == 202: + deserialized = response.stream_download(self._client._pipeline) + + if response.status_code == 204: + deserialized = response.stream_download(self._client._pipeline) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -526,14 +476,6 @@ async def begin_delete( :type automation_account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -541,15 +483,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, automation_account_name=automation_account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -559,11 +499,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -572,14 +513,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_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_private_link_resources_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_private_link_resources_operations.py index b31120697d9a..34902cb04e49 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_private_link_resources_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/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. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,21 +19,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_automation_request from .._vendor import AutomationClientMixinABC -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]] @@ -67,7 +65,6 @@ def automation( :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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 PrivateLinkResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.PrivateLinkResource] @@ -76,12 +73,10 @@ def automation( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -92,24 +87,21 @@ def automation( def prepare_request(next_link=None): if not next_link: - request = build_automation_request( + _request = build_automation_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.automation.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) @@ -119,10 +111,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -133,7 +126,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - automation.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateLinkResources" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_python2_package_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_python2_package_operations.py index 7422ff40e17e..a999bdf24fc0 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_python2_package_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_python2_package_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.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._python2_package_operations import ( build_create_or_update_request, build_delete_request, @@ -37,10 +36,10 @@ ) from .._vendor import AutomationClientMixinABC -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]] @@ -70,18 +69,20 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the python 2 package by name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param package_name: The python package name. Required. :type package_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, @@ -92,24 +93,23 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, package_name=package_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -120,11 +120,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.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -132,18 +128,20 @@ async def get( ) -> _models.Module: """Retrieve the python 2 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param package_name: The python package name. Required. :type package_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -154,24 +152,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.Module] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, package_name=package_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -181,16 +178,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Module", pipeline_response) + deserialized = self._deserialize("Module", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -205,6 +198,9 @@ async def create_or_update( ) -> _models.Module: """Create or Update the python 2 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -216,7 +212,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: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: @@ -228,13 +223,16 @@ async def create_or_update( resource_group_name: str, automation_account_name: str, package_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Module: """Create or Update the python 2 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -242,11 +240,10 @@ async def create_or_update( :param package_name: The name of python package. Required. :type package_name: str :param parameters: The create or update parameters for python package. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: @@ -258,29 +255,28 @@ async def create_or_update( resource_group_name: str, automation_account_name: str, package_name: str, - parameters: Union[_models.PythonPackageCreateParameters, IO], + parameters: Union[_models.PythonPackageCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.Module: """Create or Update the python 2 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param package_name: The name of python package. Required. :type package_name: str - :param parameters: The create or update parameters for python package. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.PythonPackageCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 create or update parameters for python package. Is either a + PythonPackageCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.PythonPackageCreateParameters or IO[bytes] :return: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -291,19 +287,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Module] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "PythonPackageCreateParameters") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, package_name=package_name, @@ -312,15 +308,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -331,20 +326,16 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("Module", pipeline_response) + deserialized = self._deserialize("Module", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("Module", pipeline_response) + deserialized = self._deserialize("Module", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}" - } - @overload async def update( self, @@ -358,6 +349,9 @@ async def update( ) -> _models.Module: """Update the python 2 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -369,7 +363,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: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: @@ -381,13 +374,16 @@ async def update( resource_group_name: str, automation_account_name: str, package_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Module: """Update the python 2 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -395,11 +391,10 @@ async def update( :param package_name: The name of python package. Required. :type package_name: str :param parameters: The update parameters for python package. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: @@ -411,29 +406,28 @@ async def update( resource_group_name: str, automation_account_name: str, package_name: str, - parameters: Union[_models.PythonPackageUpdateParameters, IO], + parameters: Union[_models.PythonPackageUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Module: """Update the python 2 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param package_name: The name of python package. Required. :type package_name: str - :param parameters: The update parameters for python package. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.automation.models.PythonPackageUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 update parameters for python package. Is either a + PythonPackageUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.PythonPackageUpdateParameters or IO[bytes] :return: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -444,19 +438,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Module] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "PythonPackageUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, package_name=package_name, @@ -465,15 +459,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -483,16 +476,12 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Module", pipeline_response) + deserialized = self._deserialize("Module", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -500,11 +489,13 @@ def list_by_automation_account( ) -> AsyncIterable["_models.Module"]: """Retrieve a list of python 2 packages. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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 Module or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.Module] :raises ~azure.core.exceptions.HttpResponseError: @@ -512,10 +503,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.ModuleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -526,24 +517,21 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ModuleListResult", pipeline_response) @@ -553,10 +541,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -568,7 +557,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_python3_package_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_python3_package_operations.py index eb2d17821588..7223d53f6e6c 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_python3_package_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_python3_package_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,15 +20,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict 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._python3_package_operations import ( build_create_or_update_request, build_delete_request, @@ -37,10 +38,10 @@ ) from .._vendor import AutomationClientMixinABC -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]] @@ -70,18 +71,20 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the python 3 package by name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param package_name: The python package name. Required. :type package_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, @@ -92,24 +95,23 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, package_name=package_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -120,11 +122,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.Automation/automationAccounts/{automationAccountName}/python3Packages/{packageName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -132,18 +130,20 @@ async def get( ) -> _models.Module: """Retrieve the python 3 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param package_name: The python package name. Required. :type package_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -154,24 +154,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.Module] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, package_name=package_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -181,19 +180,84 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Module", pipeline_response) + deserialized = self._deserialize("Module", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python3Packages/{packageName}" - } + async def _create_or_update_initial( + self, + resource_group_name: str, + automation_account_name: str, + package_name: str, + parameters: Union[_models.PythonPackageCreateParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PythonPackageCreateParameters") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + package_name=package_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + await response.read() # Load the body in memory and close the socket + 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 = response.stream_download(self._client._pipeline) + + if response.status_code == 201: + deserialized = response.stream_download(self._client._pipeline) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @overload - async def create_or_update( + async def begin_create_or_update( self, resource_group_name: str, automation_account_name: str, @@ -202,9 +266,12 @@ async def create_or_update( *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Module: + ) -> AsyncLROPoller[_models.Module]: """Create or Update the python 3 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -216,25 +283,28 @@ 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: Module or the result of cls(response) - :rtype: ~azure.mgmt.automation.models.Module + :return: An instance of AsyncLROPoller that returns either Module or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.automation.models.Module] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create_or_update( + async def begin_create_or_update( self, resource_group_name: str, automation_account_name: str, package_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Module: + ) -> AsyncLROPoller[_models.Module]: """Create or Update the python 3 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -242,109 +312,94 @@ async def create_or_update( :param package_name: The name of python package. Required. :type package_name: str :param parameters: The create or update parameters for python package. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Module or the result of cls(response) - :rtype: ~azure.mgmt.automation.models.Module + :return: An instance of AsyncLROPoller that returns either Module or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.automation.models.Module] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def create_or_update( + async def begin_create_or_update( self, resource_group_name: str, automation_account_name: str, package_name: str, - parameters: Union[_models.PythonPackageCreateParameters, IO], + parameters: Union[_models.PythonPackageCreateParameters, IO[bytes]], **kwargs: Any - ) -> _models.Module: + ) -> AsyncLROPoller[_models.Module]: """Create or Update the python 3 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param package_name: The name of python package. Required. :type package_name: str - :param parameters: The create or update parameters for python package. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.PythonPackageCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Module or the result of cls(response) - :rtype: ~azure.mgmt.automation.models.Module + :param parameters: The create or update parameters for python package. Is either a + PythonPackageCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.PythonPackageCreateParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either Module or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.automation.models.Module] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Module] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + package_name=package_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PythonPackageCreateParameters") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - automation_account_name=automation_account_name, - package_name=package_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Module", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + 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.Module].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Module]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - 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("Module", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Module", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python3Packages/{packageName}" - } - @overload async def update( self, @@ -358,6 +413,9 @@ async def update( ) -> _models.Module: """Update the python 3 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -369,7 +427,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: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: @@ -381,13 +438,16 @@ async def update( resource_group_name: str, automation_account_name: str, package_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Module: """Update the python 3 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -395,11 +455,10 @@ async def update( :param package_name: The name of python package. Required. :type package_name: str :param parameters: The update parameters for python package. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: @@ -411,29 +470,28 @@ async def update( resource_group_name: str, automation_account_name: str, package_name: str, - parameters: Union[_models.PythonPackageUpdateParameters, IO], + parameters: Union[_models.PythonPackageUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Module: """Update the python 3 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param package_name: The name of python package. Required. :type package_name: str - :param parameters: The update parameters for python package. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.automation.models.PythonPackageUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 update parameters for python package. Is either a + PythonPackageUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.PythonPackageUpdateParameters or IO[bytes] :return: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -444,19 +502,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Module] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "PythonPackageUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, package_name=package_name, @@ -465,15 +523,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -483,16 +540,12 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Module", pipeline_response) + deserialized = self._deserialize("Module", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/python3Packages/{packageName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -500,11 +553,13 @@ def list_by_automation_account( ) -> AsyncIterable["_models.Module"]: """Retrieve a list of python 3 packages. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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 Module or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.Module] :raises ~azure.core.exceptions.HttpResponseError: @@ -512,10 +567,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.ModuleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -526,24 +581,21 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ModuleListResult", pipeline_response) @@ -553,10 +605,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -568,7 +621,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python3Packages" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_runbook_draft_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_runbook_draft_operations.py index f2bab4dec2f3..e4ab1ce7cdd6 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_runbook_draft_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_runbook_draft_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._runbook_draft_operations import ( build_get_content_request, build_get_request, @@ -36,10 +34,10 @@ ) from .._vendor import AutomationClientMixinABC -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]] @@ -69,18 +67,20 @@ async def get_content( ) -> AsyncIterator[bytes]: """Retrieve the content of runbook draft identified by runbook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookdraftoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The runbook name. Required. :type runbook_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Async iterator of the response bytes or the result of cls(response) + :return: AsyncIterator[bytes] or the result of cls(response) :rtype: AsyncIterator[bytes] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,29 +91,29 @@ async def get_content( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_get_content_request( + _request = build_get_content_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_content.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=True, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: + await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -124,19 +124,15 @@ async def get_content( return deserialized # type: ignore - get_content.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content" - } - async def _replace_content_initial( self, resource_group_name: str, automation_account_name: str, runbook_name: str, - runbook_content: IO, + runbook_content: IO[bytes], **kwargs: Any - ) -> Optional[AsyncIterator[bytes]]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -147,13 +143,13 @@ async def _replace_content_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[AsyncIterator[bytes]]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _content = runbook_content - request = build_replace_content_request( + _request = build_replace_content_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, @@ -161,25 +157,24 @@ async def _replace_content_initial( api_version=api_version, content_type=content_type, content=_content, - template_url=self._replace_content_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=True, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} if response.status_code == 200: deserialized = response.stream_download(self._client._pipeline) @@ -187,14 +182,12 @@ async def _replace_content_initial( if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _replace_content_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content" - } + return deserialized # type: ignore @distributed_trace_async async def begin_replace_content( @@ -202,11 +195,14 @@ async def begin_replace_content( resource_group_name: str, automation_account_name: str, runbook_name: str, - runbook_content: IO, + runbook_content: IO[bytes], **kwargs: Any ) -> AsyncLROPoller[AsyncIterator[bytes]]: """Replaces the runbook draft content. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookdraftoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -214,24 +210,16 @@ async def begin_replace_content( :param runbook_name: The runbook name. Required. :type runbook_name: str :param runbook_content: The runbook draft content. Required. - :type runbook_content: IO - :keyword callable cls: A custom type or function that will be passed the direct response - :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 Async iterator of the response bytes - or the result of cls(response) + :type runbook_content: IO[bytes] + :return: An instance of AsyncLROPoller that returns either AsyncIterator[bytes] or the result + of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[AsyncIterator[bytes]] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -250,12 +238,13 @@ async def begin_replace_content( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = response.stream_download(self._client._pipeline) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -268,17 +257,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[AsyncIterator[bytes]].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_replace_content.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content" - } + return AsyncLROPoller[AsyncIterator[bytes]]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def get( @@ -286,18 +273,20 @@ async def get( ) -> _models.RunbookDraft: """Retrieve the runbook draft identified by runbook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookdraftoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The runbook name. Required. :type runbook_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RunbookDraft or the result of cls(response) :rtype: ~azure.mgmt.automation.models.RunbookDraft :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -308,24 +297,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.RunbookDraft] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -335,16 +323,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RunbookDraft", pipeline_response) + deserialized = self._deserialize("RunbookDraft", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft" - } + return deserialized # type: ignore @distributed_trace_async async def undo_edit( @@ -352,18 +336,20 @@ async def undo_edit( ) -> _models.RunbookDraftUndoEditResult: """Undo draft edit to last known published state identified by runbook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookdraftoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The runbook name. Required. :type runbook_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RunbookDraftUndoEditResult or the result of cls(response) :rtype: ~azure.mgmt.automation.models.RunbookDraftUndoEditResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -374,24 +360,23 @@ async def undo_edit( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.RunbookDraftUndoEditResult] = kwargs.pop("cls", None) - request = build_undo_edit_request( + _request = build_undo_edit_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.undo_edit.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -401,13 +386,9 @@ async def undo_edit( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RunbookDraftUndoEditResult", pipeline_response) + deserialized = self._deserialize("RunbookDraftUndoEditResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - undo_edit.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/undoEdit" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_runbook_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_runbook_operations.py index 055eb0da6ab7..12c847d76ee3 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_runbook_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_runbook_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,9 +20,8 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -29,7 +29,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._runbook_operations import ( build_create_or_update_request, build_delete_request, @@ -41,10 +40,10 @@ ) from .._vendor import AutomationClientMixinABC -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]] @@ -68,10 +67,10 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def _publish_initial( # pylint: disable=inconsistent-return-statements + async def _publish_initial( self, resource_group_name: str, automation_account_name: str, runbook_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,29 +81,29 @@ async def _publish_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_publish_request( + _request = build_publish_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._publish_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202]: + await response.read() # Load the body in memory and close the socket 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) @@ -112,12 +111,12 @@ async def _publish_initial( # pylint: disable=inconsistent-return-statements response_headers = {} response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _publish_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/publish" - } + return deserialized # type: ignore @distributed_trace_async async def begin_publish( @@ -125,20 +124,15 @@ async def begin_publish( ) -> AsyncLROPoller[None]: """Publish runbook draft. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookdraftoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The parameters supplied to the publish runbook operation. Required. :type runbook_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: @@ -146,13 +140,13 @@ async def begin_publish( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-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._publish_initial( # type: ignore + raw_result = await self._publish_initial( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, @@ -162,11 +156,12 @@ async def begin_publish( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -175,17 +170,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_publish.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/publish" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get_content( @@ -193,18 +184,20 @@ async def get_content( ) -> AsyncIterator[bytes]: """Retrieve the content of runbook identified by runbook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The runbook name. Required. :type runbook_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Async iterator of the response bytes or the result of cls(response) + :return: AsyncIterator[bytes] or the result of cls(response) :rtype: AsyncIterator[bytes] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -215,29 +208,29 @@ async def get_content( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_get_content_request( + _request = build_get_content_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_content.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=True, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: + await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -248,28 +241,26 @@ async def get_content( return deserialized # type: ignore - get_content.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/content" - } - @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, runbook_name: str, **kwargs: Any ) -> _models.Runbook: """Retrieve the runbook identified by runbook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The runbook name. Required. :type runbook_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Runbook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -280,24 +271,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.Runbook] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -307,16 +297,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Runbook", pipeline_response) + deserialized = self._deserialize("Runbook", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -331,6 +317,9 @@ async def create_or_update( ) -> _models.Runbook: """Create the runbook identified by runbook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -343,7 +332,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: Runbook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook :raises ~azure.core.exceptions.HttpResponseError: @@ -355,13 +343,16 @@ async def create_or_update( resource_group_name: str, automation_account_name: str, runbook_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Runbook: """Create the runbook identified by runbook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -370,11 +361,10 @@ async def create_or_update( :type runbook_name: str :param parameters: The create or update parameters for runbook. Provide either content link for a published runbook or draft, not both. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Runbook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook :raises ~azure.core.exceptions.HttpResponseError: @@ -386,11 +376,14 @@ async def create_or_update( resource_group_name: str, automation_account_name: str, runbook_name: str, - parameters: Union[_models.RunbookCreateOrUpdateParameters, IO], + parameters: Union[_models.RunbookCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Runbook: """Create the runbook identified by runbook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -398,17 +391,14 @@ async def create_or_update( :param runbook_name: The runbook name. Required. :type runbook_name: str :param parameters: The create or update parameters for runbook. Provide either content link for - a published runbook or draft, not both. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.RunbookCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + a published runbook or draft, not both. Is either a RunbookCreateOrUpdateParameters type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.RunbookCreateOrUpdateParameters or IO[bytes] :return: Runbook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -419,19 +409,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Runbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RunbookCreateOrUpdateParameters") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, @@ -440,15 +430,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -459,20 +448,16 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("Runbook", pipeline_response) + deserialized = self._deserialize("Runbook", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("Runbook", pipeline_response) + deserialized = self._deserialize("Runbook", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}" - } - @overload async def update( self, @@ -486,6 +471,9 @@ async def update( ) -> _models.Runbook: """Update the runbook identified by runbook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -497,7 +485,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: Runbook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook :raises ~azure.core.exceptions.HttpResponseError: @@ -509,13 +496,16 @@ async def update( resource_group_name: str, automation_account_name: str, runbook_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Runbook: """Update the runbook identified by runbook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -523,11 +513,10 @@ async def update( :param runbook_name: The runbook name. Required. :type runbook_name: str :param parameters: The update parameters for runbook. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Runbook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook :raises ~azure.core.exceptions.HttpResponseError: @@ -539,29 +528,28 @@ async def update( resource_group_name: str, automation_account_name: str, runbook_name: str, - parameters: Union[_models.RunbookUpdateParameters, IO], + parameters: Union[_models.RunbookUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Runbook: """Update the runbook identified by runbook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The runbook name. Required. :type runbook_name: str - :param parameters: The update parameters for runbook. Is either a model type or a IO type. - Required. - :type parameters: ~azure.mgmt.automation.models.RunbookUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 update parameters for runbook. Is either a RunbookUpdateParameters type + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.RunbookUpdateParameters or IO[bytes] :return: Runbook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -572,19 +560,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Runbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RunbookUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, @@ -593,15 +581,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -611,16 +598,12 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Runbook", pipeline_response) + deserialized = self._deserialize("Runbook", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -628,18 +611,20 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the runbook by name. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The runbook name. Required. :type runbook_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, @@ -650,24 +635,23 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -678,11 +662,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.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_by_automation_account( @@ -690,11 +670,13 @@ def list_by_automation_account( ) -> AsyncIterable["_models.Runbook"]: """Retrieve a list of runbooks. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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 Runbook or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.Runbook] :raises ~azure.core.exceptions.HttpResponseError: @@ -702,10 +684,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.RunbookListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -716,24 +698,21 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RunbookListResult", pipeline_response) @@ -743,10 +722,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -758,7 +738,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_schedule_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_schedule_operations.py index 7a3e4d38c12e..76ce1971f339 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_schedule_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_schedule_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.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._schedule_operations import ( build_create_or_update_request, build_delete_request, @@ -37,10 +36,10 @@ ) from .._vendor import AutomationClientMixinABC -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,6 +76,9 @@ async def create_or_update( ) -> Optional[_models.Schedule]: """Create a schedule. + .. seealso:: + - http://aka.ms/azureautomationsdk/scheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -89,7 +91,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: Schedule or None or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule or None :raises ~azure.core.exceptions.HttpResponseError: @@ -101,13 +102,16 @@ async def create_or_update( resource_group_name: str, automation_account_name: str, schedule_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> Optional[_models.Schedule]: """Create a schedule. + .. seealso:: + - http://aka.ms/azureautomationsdk/scheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -116,11 +120,10 @@ async def create_or_update( :type schedule_name: str :param parameters: The parameters supplied to the create or update schedule operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule or None or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule or None :raises ~azure.core.exceptions.HttpResponseError: @@ -132,11 +135,14 @@ async def create_or_update( resource_group_name: str, automation_account_name: str, schedule_name: str, - parameters: Union[_models.ScheduleCreateOrUpdateParameters, IO], + parameters: Union[_models.ScheduleCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.Schedule]: """Create a schedule. + .. seealso:: + - http://aka.ms/azureautomationsdk/scheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -144,17 +150,13 @@ async def create_or_update( :param schedule_name: The schedule name. Required. :type schedule_name: str :param parameters: The parameters supplied to the create or update schedule operation. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.ScheduleCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 ScheduleCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.ScheduleCreateOrUpdateParameters or IO[bytes] :return: Schedule or None or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -165,19 +167,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.Schedule]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ScheduleCreateOrUpdateParameters") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, schedule_name=schedule_name, @@ -186,15 +188,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -206,19 +207,15 @@ async def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("Schedule", pipeline_response) + deserialized = self._deserialize("Schedule", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("Schedule", pipeline_response) + deserialized = self._deserialize("Schedule", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}" - } + return deserialized # type: ignore @overload async def update( @@ -233,6 +230,9 @@ async def update( ) -> _models.Schedule: """Update the schedule identified by schedule name. + .. seealso:: + - http://aka.ms/azureautomationsdk/scheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -244,7 +244,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: Schedule or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule :raises ~azure.core.exceptions.HttpResponseError: @@ -256,13 +255,16 @@ async def update( resource_group_name: str, automation_account_name: str, schedule_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Schedule: """Update the schedule identified by schedule name. + .. seealso:: + - http://aka.ms/azureautomationsdk/scheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -270,11 +272,10 @@ async def update( :param schedule_name: The schedule name. Required. :type schedule_name: str :param parameters: The parameters supplied to the update schedule operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule :raises ~azure.core.exceptions.HttpResponseError: @@ -286,29 +287,28 @@ async def update( resource_group_name: str, automation_account_name: str, schedule_name: str, - parameters: Union[_models.ScheduleUpdateParameters, IO], + parameters: Union[_models.ScheduleUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Schedule: """Update the schedule identified by schedule name. + .. seealso:: + - http://aka.ms/azureautomationsdk/scheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param schedule_name: The schedule name. Required. :type schedule_name: str - :param parameters: The parameters supplied to the update schedule operation. Is either a model - type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.ScheduleUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 supplied to the update schedule operation. Is either a + ScheduleUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.ScheduleUpdateParameters or IO[bytes] :return: Schedule or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -319,19 +319,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Schedule] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ScheduleUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, schedule_name=schedule_name, @@ -340,15 +340,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,16 +357,12 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Schedule", pipeline_response) + deserialized = self._deserialize("Schedule", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -375,18 +370,20 @@ async def get( ) -> _models.Schedule: """Retrieve the schedule identified by schedule name. + .. seealso:: + - http://aka.ms/azureautomationsdk/scheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param schedule_name: The schedule name. Required. :type schedule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -397,24 +394,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.Schedule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, schedule_name=schedule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -424,16 +420,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Schedule", pipeline_response) + deserialized = self._deserialize("Schedule", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -441,18 +433,20 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the schedule identified by schedule name. + .. seealso:: + - http://aka.ms/azureautomationsdk/scheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param schedule_name: The schedule name. Required. :type schedule_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,24 +457,23 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, schedule_name=schedule_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -491,11 +484,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.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_by_automation_account( @@ -503,11 +492,13 @@ def list_by_automation_account( ) -> AsyncIterable["_models.Schedule"]: """Retrieve a list of schedules. + .. seealso:: + - http://aka.ms/azureautomationsdk/scheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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 Schedule or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.Schedule] :raises ~azure.core.exceptions.HttpResponseError: @@ -515,10 +506,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.ScheduleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -529,24 +520,21 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ScheduleListResult", pipeline_response) @@ -556,10 +544,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -571,7 +560,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configuration_machine_runs_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configuration_machine_runs_operations.py index 5f715eec7678..7ea1d5e8dd2e 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configuration_machine_runs_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configuration_machine_runs_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, TypeVar +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,29 +18,27 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_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._software_update_configuration_machine_runs_operations import ( build_get_by_id_request, build_list_request, ) from .._vendor import AutomationClientMixinABC -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]] -class SoftwareUpdateConfigurationMachineRunsOperations: +class SoftwareUpdateConfigurationMachineRunsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -70,6 +68,9 @@ async def get_by_id( ) -> _models.SoftwareUpdateConfigurationMachineRun: """Get a single software update configuration machine run by Id. + .. seealso:: + - http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -79,12 +80,11 @@ async def get_by_id( :type software_update_configuration_machine_run_id: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationMachineRun or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationMachineRun :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,25 +95,24 @@ async def get_by_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.SoftwareUpdateConfigurationMachineRun] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, software_update_configuration_machine_run_id=software_update_configuration_machine_run_id, subscription_id=self._config.subscription_id, client_request_id=client_request_id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -123,16 +122,12 @@ async def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SoftwareUpdateConfigurationMachineRun", pipeline_response) + deserialized = self._deserialize("SoftwareUpdateConfigurationMachineRun", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns/{softwareUpdateConfigurationMachineRunId}" - } + return deserialized # type: ignore @distributed_trace_async async def list( @@ -147,6 +142,9 @@ async def list( ) -> _models.SoftwareUpdateConfigurationMachineRunListResult: """Return list of software update configuration machine runs. + .. seealso:: + - http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -162,12 +160,11 @@ async def list( :param top: Maximum number of entries returned in the results collection. Default value is None. :type top: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationMachineRunListResult or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationMachineRunListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -178,10 +175,10 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.SoftwareUpdateConfigurationMachineRunListResult] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, @@ -190,15 +187,14 @@ async def list( skip=skip, top=top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -208,13 +204,11 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SoftwareUpdateConfigurationMachineRunListResult", pipeline_response) + deserialized = self._deserialize( + "SoftwareUpdateConfigurationMachineRunListResult", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configuration_runs_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configuration_runs_operations.py index 2e5dfb1846ab..0f2860ab71c8 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configuration_runs_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configuration_runs_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, TypeVar +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,26 +18,24 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_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._software_update_configuration_runs_operations import build_get_by_id_request, build_list_request from .._vendor import AutomationClientMixinABC -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]] -class SoftwareUpdateConfigurationRunsOperations: +class SoftwareUpdateConfigurationRunsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -67,6 +65,9 @@ async def get_by_id( ) -> _models.SoftwareUpdateConfigurationRun: """Get a single software update configuration Run by Id. + .. seealso:: + - http://aka.ms/azureautomationsdk/softwareupdateconfigurationrunoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -76,12 +77,11 @@ async def get_by_id( :type software_update_configuration_run_id: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationRun or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRun :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -92,25 +92,24 @@ async def get_by_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.SoftwareUpdateConfigurationRun] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, software_update_configuration_run_id=software_update_configuration_run_id, subscription_id=self._config.subscription_id, client_request_id=client_request_id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -120,16 +119,12 @@ async def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SoftwareUpdateConfigurationRun", pipeline_response) + deserialized = self._deserialize("SoftwareUpdateConfigurationRun", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns/{softwareUpdateConfigurationRunId}" - } + return deserialized # type: ignore @distributed_trace_async async def list( @@ -144,6 +139,9 @@ async def list( ) -> _models.SoftwareUpdateConfigurationRunListResult: """Return list of software update configuration runs. + .. seealso:: + - http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -159,12 +157,11 @@ async def list( :param top: Maximum number of entries returned in the results collection. Default value is None. :type top: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationRunListResult or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRunListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -175,10 +172,10 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.SoftwareUpdateConfigurationRunListResult] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, @@ -187,15 +184,14 @@ async def list( skip=skip, top=top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -205,13 +201,9 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SoftwareUpdateConfigurationRunListResult", pipeline_response) + deserialized = self._deserialize("SoftwareUpdateConfigurationRunListResult", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configurations_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configurations_operations.py index 38d44d4fb817..6164645920d1 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configurations_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configurations_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_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._software_update_configurations_operations import ( build_create_request, build_delete_request, @@ -34,10 +33,10 @@ ) from .._vendor import AutomationClientMixinABC -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]] @@ -75,6 +74,9 @@ async def create( ) -> _models.SoftwareUpdateConfiguration: """Create a new software update configuration with the name given in the URI. + .. seealso:: + - http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -89,7 +91,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: SoftwareUpdateConfiguration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfiguration :raises ~azure.core.exceptions.HttpResponseError: @@ -101,7 +102,7 @@ async def create( resource_group_name: str, automation_account_name: str, software_update_configuration_name: str, - parameters: IO, + parameters: IO[bytes], client_request_id: Optional[str] = None, *, content_type: str = "application/json", @@ -109,6 +110,9 @@ async def create( ) -> _models.SoftwareUpdateConfiguration: """Create a new software update configuration with the name given in the URI. + .. seealso:: + - http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -117,13 +121,12 @@ async def create( created. Required. :type software_update_configuration_name: str :param parameters: Request body. Required. - :type parameters: IO + :type parameters: IO[bytes] :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: 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: SoftwareUpdateConfiguration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfiguration :raises ~azure.core.exceptions.HttpResponseError: @@ -135,12 +138,15 @@ async def create( resource_group_name: str, automation_account_name: str, software_update_configuration_name: str, - parameters: Union[_models.SoftwareUpdateConfiguration, IO], + parameters: Union[_models.SoftwareUpdateConfiguration, IO[bytes]], client_request_id: Optional[str] = None, **kwargs: Any ) -> _models.SoftwareUpdateConfiguration: """Create a new software update configuration with the name given in the URI. + .. seealso:: + - http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -148,19 +154,16 @@ async def create( :param software_update_configuration_name: The name of the software update configuration to be created. Required. :type software_update_configuration_name: str - :param parameters: Request body. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.SoftwareUpdateConfiguration or IO + :param parameters: Request body. Is either a SoftwareUpdateConfiguration type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.automation.models.SoftwareUpdateConfiguration or IO[bytes] :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: 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: SoftwareUpdateConfiguration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -171,19 +174,19 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SoftwareUpdateConfiguration] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SoftwareUpdateConfiguration") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, software_update_configuration_name=software_update_configuration_name, @@ -193,15 +196,14 @@ async def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -212,20 +214,16 @@ async def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("SoftwareUpdateConfiguration", pipeline_response) + deserialized = self._deserialize("SoftwareUpdateConfiguration", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("SoftwareUpdateConfiguration", pipeline_response) + deserialized = self._deserialize("SoftwareUpdateConfiguration", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}" - } - @distributed_trace_async async def get_by_name( self, @@ -237,6 +235,9 @@ async def get_by_name( ) -> _models.SoftwareUpdateConfiguration: """Get a single software update configuration by name. + .. seealso:: + - http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -246,12 +247,11 @@ async def get_by_name( :type software_update_configuration_name: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfiguration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -262,25 +262,24 @@ async def get_by_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) cls: ClsType[_models.SoftwareUpdateConfiguration] = kwargs.pop("cls", None) - request = build_get_by_name_request( + _request = build_get_by_name_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, software_update_configuration_name=software_update_configuration_name, subscription_id=self._config.subscription_id, client_request_id=client_request_id, api_version=api_version, - template_url=self.get_by_name.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -290,16 +289,12 @@ async def get_by_name( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SoftwareUpdateConfiguration", pipeline_response) + deserialized = self._deserialize("SoftwareUpdateConfiguration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_name.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -312,6 +307,9 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """delete a specific software update configuration. + .. seealso:: + - http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -321,12 +319,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type software_update_configuration_name: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_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, @@ -337,25 +334,24 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, software_update_configuration_name=software_update_configuration_name, subscription_id=self._config.subscription_id, client_request_id=client_request_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -366,11 +362,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.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def list( @@ -383,6 +375,9 @@ async def list( ) -> _models.SoftwareUpdateConfigurationListResult: """Get all software update configurations for the account. + .. seealso:: + - http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -391,12 +386,11 @@ async def list( :type client_request_id: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationListResult or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -407,25 +401,24 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) cls: ClsType[_models.SoftwareUpdateConfigurationListResult] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, client_request_id=client_request_id, 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -435,13 +428,9 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SoftwareUpdateConfigurationListResult", pipeline_response) + deserialized = self._deserialize("SoftwareUpdateConfigurationListResult", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_operations.py index 4b0b4776ffe5..d1f09f1cb212 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.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._source_control_operations import ( build_create_or_update_request, build_delete_request, @@ -37,10 +36,10 @@ ) from .._vendor import AutomationClientMixinABC -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,6 +76,9 @@ async def create_or_update( ) -> _models.SourceControl: """Create a source control. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontroloperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -89,7 +91,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: SourceControl or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl :raises ~azure.core.exceptions.HttpResponseError: @@ -101,13 +102,16 @@ async def create_or_update( resource_group_name: str, automation_account_name: str, source_control_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.SourceControl: """Create a source control. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontroloperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -116,11 +120,10 @@ async def create_or_update( :type source_control_name: str :param parameters: The parameters supplied to the create or update source control operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControl or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl :raises ~azure.core.exceptions.HttpResponseError: @@ -132,11 +135,14 @@ async def create_or_update( resource_group_name: str, automation_account_name: str, source_control_name: str, - parameters: Union[_models.SourceControlCreateOrUpdateParameters, IO], + parameters: Union[_models.SourceControlCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.SourceControl: """Create a source control. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontroloperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -144,17 +150,14 @@ async def create_or_update( :param source_control_name: The source control name. Required. :type source_control_name: str :param parameters: The parameters supplied to the create or update source control operation. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.SourceControlCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 SourceControlCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.SourceControlCreateOrUpdateParameters or + IO[bytes] :return: SourceControl or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -165,19 +168,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SourceControl] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SourceControlCreateOrUpdateParameters") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, source_control_name=source_control_name, @@ -186,15 +189,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -205,20 +207,16 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("SourceControl", pipeline_response) + deserialized = self._deserialize("SourceControl", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("SourceControl", pipeline_response) + deserialized = self._deserialize("SourceControl", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}" - } - @overload async def update( self, @@ -232,6 +230,9 @@ async def update( ) -> _models.SourceControl: """Update a source control. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontroloperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -243,7 +244,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: SourceControl or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl :raises ~azure.core.exceptions.HttpResponseError: @@ -255,13 +255,16 @@ async def update( resource_group_name: str, automation_account_name: str, source_control_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.SourceControl: """Update a source control. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontroloperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -269,11 +272,10 @@ async def update( :param source_control_name: The source control name. Required. :type source_control_name: str :param parameters: The parameters supplied to the update source control operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControl or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl :raises ~azure.core.exceptions.HttpResponseError: @@ -285,11 +287,14 @@ async def update( resource_group_name: str, automation_account_name: str, source_control_name: str, - parameters: Union[_models.SourceControlUpdateParameters, IO], + parameters: Union[_models.SourceControlUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.SourceControl: """Update a source control. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontroloperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -297,17 +302,13 @@ async def update( :param source_control_name: The source control name. Required. :type source_control_name: str :param parameters: The parameters supplied to the update source control operation. Is either a - model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.SourceControlUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + SourceControlUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.SourceControlUpdateParameters or IO[bytes] :return: SourceControl or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -318,19 +319,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SourceControl] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SourceControlUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, source_control_name=source_control_name, @@ -339,15 +340,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -357,16 +357,12 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SourceControl", pipeline_response) + deserialized = self._deserialize("SourceControl", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -374,18 +370,20 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the source control. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontroloperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param source_control_name: The name of source control. Required. :type source_control_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, @@ -396,24 +394,23 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, source_control_name=source_control_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -424,11 +421,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.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -436,18 +429,20 @@ async def get( ) -> _models.SourceControl: """Retrieve the source control identified by source control name. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontroloperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param source_control_name: The name of source control. Required. :type source_control_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControl or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -458,24 +453,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.SourceControl] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, source_control_name=source_control_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -485,16 +479,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SourceControl", pipeline_response) + deserialized = self._deserialize("SourceControl", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -502,13 +492,15 @@ def list_by_automation_account( ) -> AsyncIterable["_models.SourceControl"]: """Retrieve a list of source controls. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontroloperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param filter: The filter to apply on the operation. 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 SourceControl or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.SourceControl] :raises ~azure.core.exceptions.HttpResponseError: @@ -516,10 +508,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.SourceControlListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -530,25 +522,22 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SourceControlListResult", pipeline_response) @@ -558,10 +547,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -573,7 +563,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_sync_job_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_sync_job_operations.py index 51cee98812a5..691840569036 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_sync_job_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_sync_job_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.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._source_control_sync_job_operations import ( build_create_request, build_get_request, @@ -35,10 +34,10 @@ ) from .._vendor import AutomationClientMixinABC -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]] @@ -76,6 +75,9 @@ async def create( ) -> _models.SourceControlSyncJob: """Creates the sync job for a source control. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontrolsyncjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -90,7 +92,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: SourceControlSyncJob or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControlSyncJob :raises ~azure.core.exceptions.HttpResponseError: @@ -103,13 +104,16 @@ async def create( automation_account_name: str, source_control_name: str, source_control_sync_job_id: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.SourceControlSyncJob: """Creates the sync job for a source control. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontrolsyncjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -120,11 +124,10 @@ async def create( :type source_control_sync_job_id: str :param parameters: The parameters supplied to the create source control sync job operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControlSyncJob or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControlSyncJob :raises ~azure.core.exceptions.HttpResponseError: @@ -137,11 +140,14 @@ async def create( automation_account_name: str, source_control_name: str, source_control_sync_job_id: str, - parameters: Union[_models.SourceControlSyncJobCreateParameters, IO], + parameters: Union[_models.SourceControlSyncJobCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.SourceControlSyncJob: """Creates the sync job for a source control. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontrolsyncjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -151,17 +157,14 @@ async def create( :param source_control_sync_job_id: The source control sync job id. Required. :type source_control_sync_job_id: str :param parameters: The parameters supplied to the create source control sync job operation. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.SourceControlSyncJobCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 SourceControlSyncJobCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.SourceControlSyncJobCreateParameters or + IO[bytes] :return: SourceControlSyncJob or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControlSyncJob :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -172,19 +175,19 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SourceControlSyncJob] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SourceControlSyncJobCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, source_control_name=source_control_name, @@ -194,15 +197,14 @@ async def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -212,16 +214,12 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SourceControlSyncJob", pipeline_response) + deserialized = self._deserialize("SourceControlSyncJob", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -234,6 +232,9 @@ async def get( ) -> _models.SourceControlSyncJobById: """Retrieve the source control sync job identified by job id. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontrolsyncjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -242,12 +243,11 @@ async def get( :type source_control_name: str :param source_control_sync_job_id: The source control sync job id. Required. :type source_control_sync_job_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControlSyncJobById or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControlSyncJobById :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -258,25 +258,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.SourceControlSyncJobById] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, source_control_name=source_control_name, source_control_sync_job_id=source_control_sync_job_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -286,16 +285,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SourceControlSyncJobById", pipeline_response) + deserialized = self._deserialize("SourceControlSyncJobById", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -308,6 +303,9 @@ def list_by_automation_account( ) -> AsyncIterable["_models.SourceControlSyncJob"]: """Retrieve a list of source control sync jobs. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontrolsyncjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -316,7 +314,6 @@ def list_by_automation_account( :type source_control_name: str :param filter: The filter to apply on the operation. 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 SourceControlSyncJob or the result of cls(response) :rtype: @@ -326,10 +323,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.SourceControlSyncJobListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -340,26 +337,23 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, source_control_name=source_control_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SourceControlSyncJobListResult", pipeline_response) @@ -369,10 +363,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -384,7 +379,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_sync_job_streams_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_sync_job_streams_operations.py index 42a2a6839152..ceb18d0cfd8c 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_sync_job_streams_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_sync_job_streams_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,22 +19,20 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.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._source_control_sync_job_streams_operations import build_get_request, build_list_by_sync_job_request from .._vendor import AutomationClientMixinABC -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]] @@ -70,6 +68,9 @@ def list_by_sync_job( ) -> AsyncIterable["_models.SourceControlSyncJobStream"]: """Retrieve a list of sync job streams identified by sync job id. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontrolsyncjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -80,7 +81,6 @@ def list_by_sync_job( :type source_control_sync_job_id: str :param filter: The filter to apply on the operation. 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 SourceControlSyncJobStream or the result of cls(response) :rtype: @@ -90,10 +90,10 @@ def list_by_sync_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.SourceControlSyncJobStreamsListBySyncJob] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -104,7 +104,7 @@ def list_by_sync_job( def prepare_request(next_link=None): if not next_link: - request = build_list_by_sync_job_request( + _request = build_list_by_sync_job_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, source_control_name=source_control_name, @@ -112,19 +112,16 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_sync_job.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SourceControlSyncJobStreamsListBySyncJob", pipeline_response) @@ -134,10 +131,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -150,10 +148,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_sync_job.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams" - } - @distributed_trace_async async def get( self, @@ -166,6 +160,9 @@ async def get( ) -> _models.SourceControlSyncJobStreamById: """Retrieve a sync job stream identified by stream id. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontrolsyncjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -176,12 +173,11 @@ async def get( :type source_control_sync_job_id: str :param stream_id: The id of the sync job stream. Required. :type stream_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControlSyncJobStreamById or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControlSyncJobStreamById :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -192,10 +188,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.SourceControlSyncJobStreamById] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, source_control_name=source_control_name, @@ -203,15 +199,14 @@ async def get( stream_id=stream_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,13 +216,9 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SourceControlSyncJobStreamById", pipeline_response) + deserialized = self._deserialize("SourceControlSyncJobStreamById", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams/{streamId}" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_statistics_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_statistics_operations.py index 5ef85ee1ce1f..d84d5f1ed373 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_statistics_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_statistics_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,21 +19,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._statistics_operations import build_list_by_automation_account_request from .._vendor import AutomationClientMixinABC -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]] @@ -63,13 +61,15 @@ def list_by_automation_account( ) -> AsyncIterable["_models.Statistics"]: """Retrieve the statistics for the account. + .. seealso:: + - http://aka.ms/azureautomationsdk/statisticsoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param filter: The filter to apply on the operation. 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 Statistics or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.Statistics] :raises ~azure.core.exceptions.HttpResponseError: @@ -77,10 +77,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.StatisticsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,25 +91,22 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StatisticsListResult", pipeline_response) @@ -119,10 +116,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -134,7 +132,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/statistics" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_test_job_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_test_job_operations.py index fabe9d8f9a29..b88587425310 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_test_job_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_test_job_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_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._test_job_operations import ( build_create_request, build_get_request, @@ -35,10 +34,10 @@ ) from .._vendor import AutomationClientMixinABC -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]] @@ -75,6 +74,9 @@ async def create( ) -> _models.TestJob: """Create a test job of the runbook. + .. seealso:: + - http://aka.ms/azureautomationsdk/testjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -86,7 +88,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: TestJob or the result of cls(response) :rtype: ~azure.mgmt.automation.models.TestJob :raises ~azure.core.exceptions.HttpResponseError: @@ -98,13 +99,16 @@ async def create( resource_group_name: str, automation_account_name: str, runbook_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.TestJob: """Create a test job of the runbook. + .. seealso:: + - http://aka.ms/azureautomationsdk/testjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -112,11 +116,10 @@ async def create( :param runbook_name: The parameters supplied to the create test job operation. Required. :type runbook_name: str :param parameters: The parameters supplied to the create test job operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TestJob or the result of cls(response) :rtype: ~azure.mgmt.automation.models.TestJob :raises ~azure.core.exceptions.HttpResponseError: @@ -128,29 +131,28 @@ async def create( resource_group_name: str, automation_account_name: str, runbook_name: str, - parameters: Union[_models.TestJobCreateParameters, IO], + parameters: Union[_models.TestJobCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.TestJob: """Create a test job of the runbook. + .. seealso:: + - http://aka.ms/azureautomationsdk/testjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The parameters supplied to the create test job operation. Required. :type runbook_name: str - :param parameters: The parameters supplied to the create test job operation. Is either a model - type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.TestJobCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 supplied to the create test job operation. Is either a + TestJobCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.TestJobCreateParameters or IO[bytes] :return: TestJob or the result of cls(response) :rtype: ~azure.mgmt.automation.models.TestJob :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -161,19 +163,19 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestJob] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "TestJobCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, @@ -182,15 +184,14 @@ async def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -200,16 +201,12 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("TestJob", pipeline_response) + deserialized = self._deserialize("TestJob", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -217,18 +214,20 @@ async def get( ) -> _models.TestJob: """Retrieve the test job for the specified runbook. + .. seealso:: + - http://aka.ms/azureautomationsdk/testjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The runbook name. Required. :type runbook_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TestJob or the result of cls(response) :rtype: ~azure.mgmt.automation.models.TestJob :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -239,24 +238,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.TestJob] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -266,16 +264,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("TestJob", pipeline_response) + deserialized = self._deserialize("TestJob", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob" - } + return deserialized # type: ignore @distributed_trace_async async def resume( # pylint: disable=inconsistent-return-statements @@ -283,18 +277,20 @@ async def resume( # pylint: disable=inconsistent-return-statements ) -> None: """Resume the test job. + .. seealso:: + - http://aka.ms/azureautomationsdk/testjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The runbook name. Required. :type runbook_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, @@ -305,24 +301,23 @@ async def resume( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_resume_request( + _request = build_resume_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.resume.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -333,11 +328,7 @@ async def resume( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - resume.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/resume" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def stop( # pylint: disable=inconsistent-return-statements @@ -345,18 +336,20 @@ async def stop( # pylint: disable=inconsistent-return-statements ) -> None: """Stop the test job. + .. seealso:: + - http://aka.ms/azureautomationsdk/testjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The runbook name. Required. :type runbook_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, @@ -367,24 +360,23 @@ async def stop( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -395,11 +387,7 @@ async def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/stop" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def suspend( # pylint: disable=inconsistent-return-statements @@ -407,18 +395,20 @@ async def suspend( # pylint: disable=inconsistent-return-statements ) -> None: """Suspend the test job. + .. seealso:: + - http://aka.ms/azureautomationsdk/testjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The runbook name. Required. :type runbook_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, @@ -429,24 +419,23 @@ async def suspend( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_suspend_request( + _request = build_suspend_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.suspend.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -457,8 +446,4 @@ async def suspend( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - suspend.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/suspend" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_test_job_streams_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_test_job_streams_operations.py index 51075a4a0d03..11aa137e592b 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_test_job_streams_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_test_job_streams_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,22 +19,20 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.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._test_job_streams_operations import build_get_request, build_list_by_test_job_request from .._vendor import AutomationClientMixinABC -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]] @@ -69,6 +67,9 @@ async def get( ) -> _models.JobStream: """Retrieve a test job stream of the test job identified by runbook name and stream id. + .. seealso:: + - http://aka.ms/azureautomationsdk/jobstreamoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -77,12 +78,11 @@ async def get( :type runbook_name: str :param job_stream_id: The job stream id. Required. :type job_stream_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: JobStream or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobStream :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,25 +93,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.JobStream] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, job_stream_id=job_stream_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -121,16 +120,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("JobStream", pipeline_response) + deserialized = self._deserialize("JobStream", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams/{jobStreamId}" - } + return deserialized # type: ignore @distributed_trace def list_by_test_job( @@ -143,6 +138,9 @@ def list_by_test_job( ) -> AsyncIterable["_models.JobStream"]: """Retrieve a list of test job streams identified by runbook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/jobstreamoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -151,7 +149,6 @@ def list_by_test_job( :type runbook_name: str :param filter: The filter to apply on the operation. 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 JobStream or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.JobStream] :raises ~azure.core.exceptions.HttpResponseError: @@ -159,10 +156,10 @@ def list_by_test_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.JobStreamListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -173,26 +170,23 @@ def list_by_test_job( def prepare_request(next_link=None): if not next_link: - request = build_list_by_test_job_request( + _request = build_list_by_test_job_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_test_job.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("JobStreamListResult", pipeline_response) @@ -202,10 +196,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -217,7 +212,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_test_job.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_usages_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_usages_operations.py index 52a873ca2ef7..bba118b3dc67 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_usages_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/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. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,21 +19,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_automation_account_request from .._vendor import AutomationClientMixinABC -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]] @@ -63,11 +61,13 @@ def list_by_automation_account( ) -> AsyncIterable["_models.Usage"]: """Retrieve the usage for the account id. + .. seealso:: + - http://aka.ms/azureautomationsdk/usageoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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 Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -75,10 +75,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,24 +89,21 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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) @@ -116,10 +113,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -131,7 +129,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/usages" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_variable_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_variable_operations.py index bb54df1bd302..f2a8a82218a9 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_variable_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_variable_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.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._variable_operations import ( build_create_or_update_request, build_delete_request, @@ -37,10 +36,10 @@ ) from .._vendor import AutomationClientMixinABC -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,6 +76,9 @@ async def create_or_update( ) -> _models.Variable: """Create a variable. + .. seealso:: + - http://aka.ms/azureautomationsdk/variableoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -89,7 +91,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: Variable or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable :raises ~azure.core.exceptions.HttpResponseError: @@ -101,13 +102,16 @@ async def create_or_update( resource_group_name: str, automation_account_name: str, variable_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Variable: """Create a variable. + .. seealso:: + - http://aka.ms/azureautomationsdk/variableoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -116,11 +120,10 @@ async def create_or_update( :type variable_name: str :param parameters: The parameters supplied to the create or update variable operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Variable or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable :raises ~azure.core.exceptions.HttpResponseError: @@ -132,11 +135,14 @@ async def create_or_update( resource_group_name: str, automation_account_name: str, variable_name: str, - parameters: Union[_models.VariableCreateOrUpdateParameters, IO], + parameters: Union[_models.VariableCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Variable: """Create a variable. + .. seealso:: + - http://aka.ms/azureautomationsdk/variableoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -144,17 +150,13 @@ async def create_or_update( :param variable_name: The variable name. Required. :type variable_name: str :param parameters: The parameters supplied to the create or update variable operation. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.VariableCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 VariableCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.VariableCreateOrUpdateParameters or IO[bytes] :return: Variable or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -165,19 +167,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Variable] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "VariableCreateOrUpdateParameters") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, variable_name=variable_name, @@ -186,15 +188,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -205,20 +206,16 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("Variable", pipeline_response) + deserialized = self._deserialize("Variable", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("Variable", pipeline_response) + deserialized = self._deserialize("Variable", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}" - } - @overload async def update( self, @@ -232,6 +229,9 @@ async def update( ) -> _models.Variable: """Update a variable. + .. seealso:: + - http://aka.ms/azureautomationsdk/variableoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -243,7 +243,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: Variable or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable :raises ~azure.core.exceptions.HttpResponseError: @@ -255,13 +254,16 @@ async def update( resource_group_name: str, automation_account_name: str, variable_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Variable: """Update a variable. + .. seealso:: + - http://aka.ms/azureautomationsdk/variableoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -269,11 +271,10 @@ async def update( :param variable_name: The variable name. Required. :type variable_name: str :param parameters: The parameters supplied to the update variable operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Variable or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable :raises ~azure.core.exceptions.HttpResponseError: @@ -285,29 +286,28 @@ async def update( resource_group_name: str, automation_account_name: str, variable_name: str, - parameters: Union[_models.VariableUpdateParameters, IO], + parameters: Union[_models.VariableUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Variable: """Update a variable. + .. seealso:: + - http://aka.ms/azureautomationsdk/variableoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param variable_name: The variable name. Required. :type variable_name: str - :param parameters: The parameters supplied to the update variable operation. Is either a model - type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.VariableUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 supplied to the update variable operation. Is either a + VariableUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.VariableUpdateParameters or IO[bytes] :return: Variable or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -318,19 +318,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Variable] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "VariableUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, variable_name=variable_name, @@ -339,15 +339,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -357,16 +356,12 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Variable", pipeline_response) + deserialized = self._deserialize("Variable", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/variables/{variableName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -374,18 +369,20 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the variable. + .. seealso:: + - http://aka.ms/azureautomationsdk/variableoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param variable_name: The name of variable. Required. :type variable_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, @@ -396,24 +393,23 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, variable_name=variable_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -424,11 +420,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.Automation/automationAccounts/{automationAccountName}/variables/{variableName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -436,18 +428,20 @@ async def get( ) -> _models.Variable: """Retrieve the variable identified by variable name. + .. seealso:: + - http://aka.ms/azureautomationsdk/variableoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param variable_name: The name of variable. Required. :type variable_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Variable or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -458,24 +452,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.Variable] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, variable_name=variable_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -485,16 +478,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Variable", pipeline_response) + deserialized = self._deserialize("Variable", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -502,11 +491,13 @@ def list_by_automation_account( ) -> AsyncIterable["_models.Variable"]: """Retrieve a list of variables. + .. seealso:: + - http://aka.ms/azureautomationsdk/variableoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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 Variable or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.Variable] :raises ~azure.core.exceptions.HttpResponseError: @@ -514,10 +505,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.VariableListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -528,24 +519,21 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("VariableListResult", pipeline_response) @@ -555,10 +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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -570,7 +559,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_watcher_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_watcher_operations.py index 4dea29785374..f4027226fb45 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_watcher_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_watcher_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.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._watcher_operations import ( build_create_or_update_request, build_delete_request, @@ -39,10 +38,10 @@ ) from .._vendor import AutomationClientMixinABC -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]] @@ -79,6 +78,9 @@ async def create_or_update( ) -> _models.Watcher: """Create the watcher identified by watcher name. + .. seealso:: + - http://aka.ms/azureautomationsdk/watcheroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -90,7 +92,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: Watcher or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher :raises ~azure.core.exceptions.HttpResponseError: @@ -102,13 +103,16 @@ async def create_or_update( resource_group_name: str, automation_account_name: str, watcher_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Watcher: """Create the watcher identified by watcher name. + .. seealso:: + - http://aka.ms/azureautomationsdk/watcheroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -116,11 +120,10 @@ async def create_or_update( :param watcher_name: The watcher name. Required. :type watcher_name: str :param parameters: The create or update parameters for watcher. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Watcher or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher :raises ~azure.core.exceptions.HttpResponseError: @@ -132,29 +135,28 @@ async def create_or_update( resource_group_name: str, automation_account_name: str, watcher_name: str, - parameters: Union[_models.Watcher, IO], + parameters: Union[_models.Watcher, IO[bytes]], **kwargs: Any ) -> _models.Watcher: """Create the watcher identified by watcher name. + .. seealso:: + - http://aka.ms/azureautomationsdk/watcheroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param watcher_name: The watcher name. Required. :type watcher_name: str - :param parameters: The create or update parameters for watcher. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.automation.models.Watcher or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 create or update parameters for watcher. Is either a Watcher type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.Watcher or IO[bytes] :return: Watcher or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -165,21 +167,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Watcher] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Watcher") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, watcher_name=watcher_name, @@ -188,15 +188,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -207,38 +206,36 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("Watcher", pipeline_response) + deserialized = self._deserialize("Watcher", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("Watcher", pipeline_response) + deserialized = self._deserialize("Watcher", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}" - } - @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, watcher_name: str, **kwargs: Any ) -> _models.Watcher: """Retrieve the watcher identified by watcher name. + .. seealso:: + - http://aka.ms/azureautomationsdk/watcheroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param watcher_name: The watcher name. Required. :type watcher_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Watcher or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -249,26 +246,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.Watcher] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, watcher_name=watcher_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -278,16 +272,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Watcher", pipeline_response) + deserialized = self._deserialize("Watcher", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}" - } + return deserialized # type: ignore @overload async def update( @@ -302,6 +292,9 @@ async def update( ) -> _models.Watcher: """Update the watcher identified by watcher name. + .. seealso:: + - http://aka.ms/azureautomationsdk/watcheroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -313,7 +306,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: Watcher or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher :raises ~azure.core.exceptions.HttpResponseError: @@ -325,13 +317,16 @@ async def update( resource_group_name: str, automation_account_name: str, watcher_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Watcher: """Update the watcher identified by watcher name. + .. seealso:: + - http://aka.ms/azureautomationsdk/watcheroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -339,11 +334,10 @@ async def update( :param watcher_name: The watcher name. Required. :type watcher_name: str :param parameters: The update parameters for watcher. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Watcher or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher :raises ~azure.core.exceptions.HttpResponseError: @@ -355,29 +349,28 @@ async def update( resource_group_name: str, automation_account_name: str, watcher_name: str, - parameters: Union[_models.WatcherUpdateParameters, IO], + parameters: Union[_models.WatcherUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Watcher: """Update the watcher identified by watcher name. + .. seealso:: + - http://aka.ms/azureautomationsdk/watcheroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param watcher_name: The watcher name. Required. :type watcher_name: str - :param parameters: The update parameters for watcher. Is either a model type or a IO type. - Required. - :type parameters: ~azure.mgmt.automation.models.WatcherUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 update parameters for watcher. Is either a WatcherUpdateParameters type + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.WatcherUpdateParameters or IO[bytes] :return: Watcher or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -388,21 +381,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Watcher] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "WatcherUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, watcher_name=watcher_name, @@ -411,15 +402,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -429,16 +419,12 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Watcher", pipeline_response) + deserialized = self._deserialize("Watcher", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -446,18 +432,20 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the watcher by name. + .. seealso:: + - http://aka.ms/azureautomationsdk/watcheroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param watcher_name: The watcher name. Required. :type watcher_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, @@ -468,26 +456,23 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, watcher_name=watcher_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -498,11 +483,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.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def start( # pylint: disable=inconsistent-return-statements @@ -510,18 +491,20 @@ async def start( # pylint: disable=inconsistent-return-statements ) -> None: """Resume the watcher identified by watcher name. + .. seealso:: + - http://aka.ms/azureautomationsdk/watcheroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param watcher_name: The watcher name. Required. :type watcher_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, @@ -532,26 +515,23 @@ async def start( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_start_request( + _request = build_start_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, watcher_name=watcher_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.start.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -562,11 +542,7 @@ async def start( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - start.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/start" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def stop( # pylint: disable=inconsistent-return-statements @@ -574,18 +550,20 @@ async def stop( # pylint: disable=inconsistent-return-statements ) -> None: """Resume the watcher identified by watcher name. + .. seealso:: + - http://aka.ms/azureautomationsdk/watcheroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param watcher_name: The watcher name. Required. :type watcher_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, @@ -596,26 +574,23 @@ async def stop( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, watcher_name=watcher_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -626,11 +601,7 @@ async def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_by_automation_account( @@ -638,13 +609,15 @@ def list_by_automation_account( ) -> AsyncIterable["_models.Watcher"]: """Retrieve a list of watchers. + .. seealso:: + - http://aka.ms/azureautomationsdk/watcheroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param filter: The filter to apply on the operation. 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 Watcher or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.Watcher] :raises ~azure.core.exceptions.HttpResponseError: @@ -652,12 +625,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.WatcherListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -668,25 +639,22 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WatcherListResult", pipeline_response) @@ -696,10 +664,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -711,7 +680,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_webhook_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_webhook_operations.py index ef4c7b057bff..a5dda120e3e3 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_webhook_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_webhook_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,15 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.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._webhook_operations import ( build_create_or_update_request, build_delete_request, @@ -38,10 +37,10 @@ ) from .._vendor import AutomationClientMixinABC -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]] @@ -69,16 +68,18 @@ def __init__(self, *args, **kwargs) -> None: async def generate_uri(self, resource_group_name: str, automation_account_name: str, **kwargs: Any) -> str: """Generates a Uri for use in creating a webhook. + .. seealso:: + - http://aka.ms/azureautomationsdk/webhookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: str or the result of cls(response) :rtype: str :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,23 +90,22 @@ async def generate_uri(self, resource_group_name: str, automation_account_name: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2015-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) cls: ClsType[str] = kwargs.pop("cls", None) - request = build_generate_uri_request( + _request = build_generate_uri_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.generate_uri.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -115,16 +115,12 @@ async def generate_uri(self, resource_group_name: str, automation_account_name: error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("str", pipeline_response) + deserialized = self._deserialize("str", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - generate_uri.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/generateUri" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -132,18 +128,20 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the webhook by name. + .. seealso:: + - http://aka.ms/azureautomationsdk/webhookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param webhook_name: The webhook name. Required. :type webhook_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, @@ -154,24 +152,23 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2015-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, webhook_name=webhook_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -182,11 +179,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.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -194,18 +187,20 @@ async def get( ) -> _models.Webhook: """Retrieve the webhook identified by webhook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/webhookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param webhook_name: The webhook name. Required. :type webhook_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -216,24 +211,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2015-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, webhook_name=webhook_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -243,16 +237,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Webhook", pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -267,6 +257,9 @@ async def create_or_update( ) -> _models.Webhook: """Create the webhook identified by webhook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/webhookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -278,7 +271,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: Webhook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook :raises ~azure.core.exceptions.HttpResponseError: @@ -290,13 +282,16 @@ async def create_or_update( resource_group_name: str, automation_account_name: str, webhook_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Webhook: """Create the webhook identified by webhook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/webhookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -304,11 +299,10 @@ async def create_or_update( :param webhook_name: The webhook name. Required. :type webhook_name: str :param parameters: The create or update parameters for webhook. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook :raises ~azure.core.exceptions.HttpResponseError: @@ -320,29 +314,28 @@ async def create_or_update( resource_group_name: str, automation_account_name: str, webhook_name: str, - parameters: Union[_models.WebhookCreateOrUpdateParameters, IO], + parameters: Union[_models.WebhookCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Webhook: """Create the webhook identified by webhook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/webhookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param webhook_name: The webhook name. Required. :type webhook_name: str - :param parameters: The create or update parameters for webhook. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.automation.models.WebhookCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 create or update parameters for webhook. Is either a + WebhookCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.WebhookCreateOrUpdateParameters or IO[bytes] :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -353,19 +346,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2015-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "WebhookCreateOrUpdateParameters") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, webhook_name=webhook_name, @@ -374,15 +367,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -393,20 +385,16 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("Webhook", pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("Webhook", pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}" - } - @overload async def update( self, @@ -420,6 +408,9 @@ async def update( ) -> _models.Webhook: """Update the webhook identified by webhook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/webhookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -431,7 +422,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: Webhook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook :raises ~azure.core.exceptions.HttpResponseError: @@ -443,13 +433,16 @@ async def update( resource_group_name: str, automation_account_name: str, webhook_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Webhook: """Update the webhook identified by webhook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/webhookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -457,11 +450,10 @@ async def update( :param webhook_name: The webhook name. Required. :type webhook_name: str :param parameters: The update parameters for webhook. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook :raises ~azure.core.exceptions.HttpResponseError: @@ -473,29 +465,28 @@ async def update( resource_group_name: str, automation_account_name: str, webhook_name: str, - parameters: Union[_models.WebhookUpdateParameters, IO], + parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Webhook: """Update the webhook identified by webhook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/webhookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param webhook_name: The webhook name. Required. :type webhook_name: str - :param parameters: The update parameters for webhook. Is either a model type or a IO type. - Required. - :type parameters: ~azure.mgmt.automation.models.WebhookUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 update parameters for webhook. Is either a WebhookUpdateParameters type + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.WebhookUpdateParameters or IO[bytes] :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -506,19 +497,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2015-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "WebhookUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, webhook_name=webhook_name, @@ -527,15 +518,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -545,16 +535,12 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Webhook", pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -562,13 +548,15 @@ def list_by_automation_account( ) -> AsyncIterable["_models.Webhook"]: """Retrieve a list of webhooks. + .. seealso:: + - http://aka.ms/azureautomationsdk/webhookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param filter: The filter to apply on the operation. 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 Webhook or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.Webhook] :raises ~azure.core.exceptions.HttpResponseError: @@ -576,10 +564,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2015-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -590,25 +578,22 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WebhookListResult", pipeline_response) @@ -618,10 +603,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -633,7 +619,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_automation_client_enums.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_automation_client_enums.py index f1305838c80d..ff37c40a8fdd 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_automation_client_enums.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_automation_client_enums.py @@ -141,6 +141,7 @@ class HttpStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): SERVICE_UNAVAILABLE = "ServiceUnavailable" GATEWAY_TIMEOUT = "GatewayTimeout" HTTP_VERSION_NOT_SUPPORTED = "HttpVersionNotSupported" + CONTINUE_ENUM = "Continue" class JobProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -192,7 +193,7 @@ class LinuxUpdateClasses(str, Enum, metaclass=CaseInsensitiveEnumMeta): class ModuleProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets or sets the provisioning state of the module.""" + """Gets the provisioning state of the module.""" CREATED = "Created" CREATING = "Creating" @@ -208,7 +209,7 @@ class ModuleProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): MODULE_IMPORT_RUNBOOK_COMPLETE = "ModuleImportRunbookComplete" SUCCEEDED = "Succeeded" FAILED = "Failed" - CANCELLED = "Cancelled" + CANCELED = "Canceled" UPDATING = "Updating" @@ -255,6 +256,7 @@ class RunbookTypeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): GRAPH_POWER_SHELL = "GraphPowerShell" PYTHON2 = "Python2" PYTHON3 = "Python3" + POWER_SHELL72 = "PowerShell72" class ScheduleDay(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -279,8 +281,8 @@ class ScheduleFrequency(str, Enum, metaclass=CaseInsensitiveEnumMeta): HOUR = "Hour" WEEK = "Week" MONTH = "Month" - #: The minimum allowed interval for Minute schedules is 15 minutes. MINUTE = "Minute" + """The minimum allowed interval for Minute schedules is 15 minutes.""" class SkuNameEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_models_py3.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_models_py3.py index eab718b16728..a843d79b70ee 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_models_py3.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/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 @@ -76,8 +72,8 @@ def __init__( creation_time: Optional[datetime.datetime] = None, last_modified_time: Optional[datetime.datetime] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword id: Gets or sets the id of the resource. :paramtype id: str @@ -119,7 +115,9 @@ class ActivityListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.Activity"]] = None, next_link: Optional[str] = None, **kwargs): + def __init__( + self, *, value: Optional[List["_models.Activity"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: Gets or sets a list of activities. :paramtype value: list[~azure.mgmt.automation.models.Activity] @@ -145,7 +143,7 @@ class ActivityOutputType(_serialization.Model): "type": {"key": "type", "type": "str"}, } - def __init__(self, *, name: Optional[str] = None, type: Optional[str] = None, **kwargs): + def __init__(self, *, name: Optional[str] = None, type: Optional[str] = None, **kwargs: Any) -> None: """ :keyword name: Gets or sets the name of the activity output type. :paramtype name: str @@ -218,8 +216,8 @@ def __init__( value_from_remaining_arguments: Optional[bool] = None, description: Optional[str] = None, validation_set: Optional[List["_models.ActivityParameterValidationSet"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Gets or sets the name of the activity parameter. :paramtype name: str @@ -281,8 +279,12 @@ class ActivityParameterSet(_serialization.Model): } def __init__( - self, *, name: Optional[str] = None, parameters: Optional[List["_models.ActivityParameter"]] = None, **kwargs - ): + self, + *, + name: Optional[str] = None, + parameters: Optional[List["_models.ActivityParameter"]] = None, + **kwargs: Any + ) -> None: """ :keyword name: Gets or sets the name of the activity parameter set. :paramtype name: str @@ -305,7 +307,7 @@ class ActivityParameterValidationSet(_serialization.Model): "member_value": {"key": "memberValue", "type": "str"}, } - def __init__(self, *, member_value: Optional[str] = None, **kwargs): + def __init__(self, *, member_value: Optional[str] = None, **kwargs: Any) -> None: """ :keyword member_value: Gets or sets the name of the activity parameter validation set member. :paramtype member_value: str @@ -338,8 +340,8 @@ def __init__( week_days: Optional[List[str]] = None, month_days: Optional[List[int]] = None, monthly_occurrences: Optional[List["_models.AdvancedScheduleMonthlyOccurrence"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword week_days: Days of the week that the job should execute on. :paramtype week_days: list[str] @@ -373,8 +375,12 @@ class AdvancedScheduleMonthlyOccurrence(_serialization.Model): } def __init__( - self, *, occurrence: Optional[int] = None, day: Optional[Union[str, "_models.ScheduleDay"]] = None, **kwargs - ): + self, + *, + occurrence: Optional[int] = None, + day: Optional[Union[str, "_models.ScheduleDay"]] = None, + **kwargs: Any + ) -> None: """ :keyword occurrence: Occurrence of the week within the month. Must be between 1 and 5. :paramtype occurrence: int @@ -415,8 +421,8 @@ def __init__( endpoint: Optional[str] = None, keys: Optional["_models.AgentRegistrationKeys"] = None, id: Optional[str] = None, # pylint: disable=redefined-builtin - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword dsc_meta_configuration: Gets or sets the dsc meta configuration. :paramtype dsc_meta_configuration: str @@ -448,7 +454,7 @@ class AgentRegistrationKeys(_serialization.Model): "secondary": {"key": "secondary", "type": "str"}, } - def __init__(self, *, primary: Optional[str] = None, secondary: Optional[str] = None, **kwargs): + def __init__(self, *, primary: Optional[str] = None, secondary: Optional[str] = None, **kwargs: Any) -> None: """ :keyword primary: Gets or sets the primary key. :paramtype primary: str @@ -463,7 +469,7 @@ def __init__(self, *, primary: Optional[str] = None, secondary: Optional[str] = class AgentRegistrationRegenerateKeyParameter(_serialization.Model): """The parameters supplied to the regenerate keys operation. - All 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: Gets or sets the agent registration key name - primary or secondary. Required. Known values are: "primary" and "secondary". @@ -478,7 +484,7 @@ class AgentRegistrationRegenerateKeyParameter(_serialization.Model): "key_name": {"key": "keyName", "type": "str"}, } - def __init__(self, *, key_name: Union[str, "_models.AgentRegistrationKeyName"], **kwargs): + def __init__(self, *, key_name: Union[str, "_models.AgentRegistrationKeyName"], **kwargs: Any) -> None: """ :keyword key_name: Gets or sets the agent registration key name - primary or secondary. Required. Known values are: "primary" and "secondary". @@ -513,7 +519,7 @@ class Resource(_serialization.Model): "type": {"key": "type", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None @@ -552,7 +558,7 @@ class TrackedResource(Resource): "location": {"key": "location", "type": "str"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, location: Optional[str] = None, **kwargs): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, location: Optional[str] = None, **kwargs: Any) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -663,8 +669,8 @@ def __init__( public_network_access: Optional[bool] = None, disable_local_auth: Optional[bool] = None, automation_hybrid_service_url: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -713,7 +719,7 @@ def __init__( self.automation_hybrid_service_url = automation_hybrid_service_url -class AutomationAccountCreateOrUpdateParameters(_serialization.Model): +class AutomationAccountCreateOrUpdateParameters(_serialization.Model): # pylint: disable=name-too-long """The parameters supplied to the create or update automation account operation. :ivar name: Gets or sets name of the resource. @@ -757,8 +763,8 @@ def __init__( encryption: Optional["_models.EncryptionProperties"] = None, public_network_access: Optional[bool] = None, disable_local_auth: Optional[bool] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Gets or sets name of the resource. :paramtype name: str @@ -805,8 +811,12 @@ class AutomationAccountListResult(_serialization.Model): } def __init__( - self, *, value: Optional[List["_models.AutomationAccount"]] = None, next_link: Optional[str] = None, **kwargs - ): + self, + *, + value: Optional[List["_models.AutomationAccount"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: """ :keyword value: Gets or sets list of accounts. :paramtype value: list[~azure.mgmt.automation.models.AutomationAccount] @@ -862,8 +872,8 @@ def __init__( encryption: Optional["_models.EncryptionProperties"] = None, public_network_access: Optional[bool] = None, disable_local_auth: Optional[bool] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Gets or sets the name of the resource. :paramtype name: str @@ -918,8 +928,8 @@ def __init__( scope: Optional[List[str]] = None, locations: Optional[List[str]] = None, tag_settings: Optional["_models.TagSettingsProperties"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword scope: List of Subscription or Resource Group ARM Ids. :paramtype scope: list[str] @@ -947,22 +957,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): - """ """ - super().__init__(**kwargs) - class Certificate(ProxyResource): """Definition of the certificate. @@ -1012,7 +1006,7 @@ class Certificate(ProxyResource): "description": {"key": "properties.description", "type": "str"}, } - def __init__(self, *, description: Optional[str] = None, **kwargs): + def __init__(self, *, description: Optional[str] = None, **kwargs: Any) -> None: """ :keyword description: Gets or sets the description. :paramtype description: str @@ -1029,7 +1023,7 @@ def __init__(self, *, description: Optional[str] = None, **kwargs): class CertificateCreateOrUpdateParameters(_serialization.Model): """The parameters supplied to the create or update or replace certificate operation. - All 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 name of the certificate. Required. :vartype name: str @@ -1064,8 +1058,8 @@ def __init__( description: Optional[str] = None, thumbprint: Optional[str] = None, is_exportable: Optional[bool] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Gets or sets the name of the certificate. Required. :paramtype name: str @@ -1101,8 +1095,8 @@ class CertificateListResult(_serialization.Model): } def __init__( - self, *, value: Optional[List["_models.Certificate"]] = None, next_link: Optional[str] = None, **kwargs - ): + self, *, value: Optional[List["_models.Certificate"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: Gets or sets a list of certificates. :paramtype value: list[~azure.mgmt.automation.models.Certificate] @@ -1128,7 +1122,7 @@ class CertificateUpdateParameters(_serialization.Model): "description": {"key": "properties.description", "type": "str"}, } - def __init__(self, *, name: Optional[str] = None, description: Optional[str] = None, **kwargs): + def __init__(self, *, name: Optional[str] = None, description: Optional[str] = None, **kwargs: Any) -> None: """ :keyword name: Gets or sets the name of the certificate. :paramtype name: str @@ -1188,8 +1182,8 @@ def __init__( *, connection_type: Optional["_models.ConnectionTypeAssociationProperty"] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword connection_type: Gets or sets the connectionType of the connection. :paramtype connection_type: ~azure.mgmt.automation.models.ConnectionTypeAssociationProperty @@ -1207,7 +1201,7 @@ def __init__( class ConnectionCreateOrUpdateParameters(_serialization.Model): """The parameters supplied to the create or update connection operation. - All 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 name of the connection. Required. :vartype name: str @@ -1238,8 +1232,8 @@ def __init__( connection_type: "_models.ConnectionTypeAssociationProperty", description: Optional[str] = None, field_definition_values: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Gets or sets the name of the connection. Required. :paramtype name: str @@ -1273,8 +1267,8 @@ class ConnectionListResult(_serialization.Model): } def __init__( - self, *, value: Optional[List["_models.Connection"]] = None, next_link: Optional[str] = None, **kwargs - ): + self, *, value: Optional[List["_models.Connection"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: Gets or sets a list of connection. :paramtype value: list[~azure.mgmt.automation.models.Connection] @@ -1334,8 +1328,8 @@ def __init__( is_global: Optional[bool] = None, last_modified_time: Optional[datetime.datetime] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword is_global: Gets or sets a Boolean value to indicate if the connection type is global. :paramtype is_global: bool @@ -1366,7 +1360,7 @@ class ConnectionTypeAssociationProperty(_serialization.Model): "name": {"key": "name", "type": "str"}, } - def __init__(self, *, name: Optional[str] = None, **kwargs): + def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: """ :keyword name: Gets or sets the name of the connection type. :paramtype name: str @@ -1378,7 +1372,7 @@ def __init__(self, *, name: Optional[str] = None, **kwargs): class ConnectionTypeCreateOrUpdateParameters(_serialization.Model): """The parameters supplied to the create or update connection type operation. - All 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 name of the connection type. Required. :vartype name: str @@ -1405,8 +1399,8 @@ def __init__( name: str, field_definitions: Dict[str, "_models.FieldDefinition"], is_global: Optional[bool] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Gets or sets the name of the connection type. Required. :paramtype name: str @@ -1437,8 +1431,8 @@ class ConnectionTypeListResult(_serialization.Model): } def __init__( - self, *, value: Optional[List["_models.ConnectionType"]] = None, next_link: Optional[str] = None, **kwargs - ): + self, *, value: Optional[List["_models.ConnectionType"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: Gets or sets a list of connection types. :paramtype value: list[~azure.mgmt.automation.models.ConnectionType] @@ -1473,8 +1467,8 @@ def __init__( name: Optional[str] = None, description: Optional[str] = None, field_definition_values: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Gets or sets the name of the connection. :paramtype name: str @@ -1492,7 +1486,7 @@ def __init__( class ContentHash(_serialization.Model): """Definition of the runbook property type. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar algorithm: Gets or sets the content hash algorithm used to hash the content. Required. :vartype algorithm: str @@ -1510,7 +1504,7 @@ class ContentHash(_serialization.Model): "value": {"key": "value", "type": "str"}, } - def __init__(self, *, algorithm: str, value: str, **kwargs): + def __init__(self, *, algorithm: str, value: str, **kwargs: Any) -> None: """ :keyword algorithm: Gets or sets the content hash algorithm used to hash the content. Required. :paramtype algorithm: str @@ -1525,11 +1519,11 @@ def __init__(self, *, algorithm: str, value: str, **kwargs): class ContentLink(_serialization.Model): """Definition of the content link. - :ivar uri: Gets or sets the uri of the runbook content. + :ivar uri: Sets the uri of the content. :vartype uri: str - :ivar content_hash: Gets or sets the hash. + :ivar content_hash: Sets the hash. :vartype content_hash: ~azure.mgmt.automation.models.ContentHash - :ivar version: Gets or sets the version of the content. + :ivar version: Sets the version of the content. :vartype version: str """ @@ -1545,14 +1539,14 @@ def __init__( uri: Optional[str] = None, content_hash: Optional["_models.ContentHash"] = None, version: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ - :keyword uri: Gets or sets the uri of the runbook content. + :keyword uri: Sets the uri of the content. :paramtype uri: str - :keyword content_hash: Gets or sets the hash. + :keyword content_hash: Sets the hash. :paramtype content_hash: ~azure.mgmt.automation.models.ContentHash - :keyword version: Gets or sets the version of the content. + :keyword version: Sets the version of the content. :paramtype version: str """ super().__init__(**kwargs) @@ -1589,8 +1583,8 @@ def __init__( type: Optional[Union[str, "_models.ContentSourceType"]] = None, value: Optional[str] = None, version: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword hash: Gets or sets the hash. :paramtype hash: ~azure.mgmt.automation.models.ContentHash @@ -1650,7 +1644,7 @@ class Credential(ProxyResource): "description": {"key": "properties.description", "type": "str"}, } - def __init__(self, *, description: Optional[str] = None, **kwargs): + def __init__(self, *, description: Optional[str] = None, **kwargs: Any) -> None: """ :keyword description: Gets or sets the description. :paramtype description: str @@ -1665,7 +1659,7 @@ def __init__(self, *, description: Optional[str] = None, **kwargs): class CredentialCreateOrUpdateParameters(_serialization.Model): """The parameters supplied to the create or update credential operation. - All 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 name of the credential. Required. :vartype name: str @@ -1690,7 +1684,9 @@ class CredentialCreateOrUpdateParameters(_serialization.Model): "description": {"key": "properties.description", "type": "str"}, } - def __init__(self, *, name: str, user_name: str, password: str, description: Optional[str] = None, **kwargs): + def __init__( + self, *, name: str, user_name: str, password: str, description: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword name: Gets or sets the name of the credential. Required. :paramtype name: str @@ -1723,8 +1719,8 @@ class CredentialListResult(_serialization.Model): } def __init__( - self, *, value: Optional[List["_models.Credential"]] = None, next_link: Optional[str] = None, **kwargs - ): + self, *, value: Optional[List["_models.Credential"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: Gets or sets a list of credentials. :paramtype value: list[~azure.mgmt.automation.models.Credential] @@ -1763,8 +1759,8 @@ def __init__( user_name: Optional[str] = None, password: Optional[str] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Gets or sets the name of the credential. :paramtype name: str @@ -1830,8 +1826,8 @@ def __init__( automation_account_resource_id: Optional[str] = None, automation_account_id: Optional[str] = None, location_properties_location: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword id: The resource id. :paramtype id: str @@ -1870,7 +1866,7 @@ class DeletedAutomationAccountListResult(_serialization.Model): "value": {"key": "value", "type": "[DeletedAutomationAccount]"}, } - def __init__(self, *, value: Optional[List["_models.DeletedAutomationAccount"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.DeletedAutomationAccount"]] = None, **kwargs: Any) -> None: """ :keyword value: Gets or sets the list of deleted automation accounts. :paramtype value: list[~azure.mgmt.automation.models.DeletedAutomationAccount] @@ -1893,7 +1889,7 @@ class Dimension(_serialization.Model): "display_name": {"key": "displayName", "type": "str"}, } - def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = None, **kwargs): + def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = None, **kwargs: Any) -> None: """ :keyword name: The name of the dimension. :paramtype name: str @@ -1993,8 +1989,8 @@ def __init__( status: Optional[Union[str, "_models.JobStatus"]] = None, status_details: Optional[str] = None, parameters: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword configuration: Gets or sets the configuration. :paramtype configuration: ~azure.mgmt.automation.models.DscConfigurationAssociationProperty @@ -2033,7 +2029,7 @@ def __init__( class DscCompilationJobCreateParameters(_serialization.Model): """The parameters supplied to the create compilation job operation. - All 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 name of the resource. :vartype name: str @@ -2072,8 +2068,8 @@ def __init__( tags: Optional[Dict[str, str]] = None, parameters: Optional[Dict[str, str]] = None, increment_node_configuration_build: Optional[bool] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Gets or sets name of the resource. :paramtype name: str @@ -2113,8 +2109,12 @@ class DscCompilationJobListResult(_serialization.Model): } def __init__( - self, *, value: Optional[List["_models.DscCompilationJob"]] = None, next_link: Optional[str] = None, **kwargs - ): + self, + *, + value: Optional[List["_models.DscCompilationJob"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: """ :keyword value: Gets or sets a list of Dsc Compilation jobs. :paramtype value: list[~azure.mgmt.automation.models.DscCompilationJob] @@ -2208,8 +2208,8 @@ def __init__( last_modified_time: Optional[datetime.datetime] = None, node_configuration_count: Optional[int] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -2265,7 +2265,7 @@ class DscConfigurationAssociationProperty(_serialization.Model): "name": {"key": "name", "type": "str"}, } - def __init__(self, *, name: Optional[str] = None, **kwargs): + def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: """ :keyword name: Gets or sets the name of the Dsc configuration. :paramtype name: str @@ -2277,7 +2277,7 @@ def __init__(self, *, name: Optional[str] = None, **kwargs): class DscConfigurationCreateOrUpdateParameters(_serialization.Model): """The parameters supplied to the create or update configuration operation. - All 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 name of the resource. :vartype name: str @@ -2323,8 +2323,8 @@ def __init__( log_progress: Optional[bool] = None, parameters: Optional[Dict[str, "_models.DscConfigurationParameter"]] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Gets or sets name of the resource. :paramtype name: str @@ -2377,8 +2377,8 @@ def __init__( value: Optional[List["_models.DscConfiguration"]] = None, next_link: Optional[str] = None, total_count: Optional[int] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword value: Gets or sets a list of configurations. :paramtype value: list[~azure.mgmt.automation.models.DscConfiguration] @@ -2421,8 +2421,8 @@ def __init__( is_mandatory: Optional[bool] = None, position: Optional[int] = None, default_value: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword type: Gets or sets the type of the parameter. :paramtype type: str @@ -2480,8 +2480,8 @@ def __init__( source: Optional["_models.ContentSource"] = None, parameters: Optional[Dict[str, "_models.DscConfigurationParameter"]] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Gets or sets name of the resource. :paramtype name: str @@ -2551,8 +2551,8 @@ def __init__( certificate_id: Optional[str] = None, refresh_frequency_mins: Optional[int] = None, allow_module_overwrite: Optional[bool] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword configuration_mode_frequency_mins: Gets or sets the ConfigurationModeFrequencyMins value of the meta configuration. @@ -2658,8 +2658,8 @@ def __init__( total_count: Optional[int] = None, extension_handler: Optional[List["_models.DscNodeExtensionHandlerAssociationProperty"]] = None, name_properties_node_configuration_name: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword last_seen: Gets or sets the last seen time of the node. :paramtype last_seen: ~datetime.datetime @@ -2750,8 +2750,8 @@ def __init__( source: Optional[str] = None, node_count: Optional[int] = None, increment_node_configuration_build: Optional[bool] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword last_modified_time: Gets or sets the last modified time. :paramtype last_modified_time: ~datetime.datetime @@ -2776,7 +2776,7 @@ def __init__( self.increment_node_configuration_build = increment_node_configuration_build -class DscNodeConfigurationCreateOrUpdateParameters(_serialization.Model): +class DscNodeConfigurationCreateOrUpdateParameters(_serialization.Model): # pylint: disable=name-too-long """The parameters supplied to the create or update node configuration operation. :ivar name: Name of the node configuration. @@ -2808,8 +2808,8 @@ def __init__( source: Optional["_models.ContentSource"] = None, configuration: Optional["_models.DscConfigurationAssociationProperty"] = None, increment_node_configuration_build: Optional[bool] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Name of the node configuration. :paramtype name: str @@ -2854,8 +2854,8 @@ def __init__( value: Optional[List["_models.DscNodeConfiguration"]] = None, next_link: Optional[str] = None, total_count: Optional[int] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword value: Gets or sets a list of Dsc node configurations. :paramtype value: list[~azure.mgmt.automation.models.DscNodeConfiguration] @@ -2870,7 +2870,7 @@ def __init__( self.total_count = total_count -class DscNodeExtensionHandlerAssociationProperty(_serialization.Model): +class DscNodeExtensionHandlerAssociationProperty(_serialization.Model): # pylint: disable=name-too-long """The dsc extensionHandler property associated with the node. :ivar name: Gets or sets the name of the extension handler. @@ -2884,7 +2884,7 @@ class DscNodeExtensionHandlerAssociationProperty(_serialization.Model): "version": {"key": "version", "type": "str"}, } - def __init__(self, *, name: Optional[str] = None, version: Optional[str] = None, **kwargs): + def __init__(self, *, name: Optional[str] = None, version: Optional[str] = None, **kwargs: Any) -> None: """ :keyword name: Gets or sets the name of the extension handler. :paramtype name: str @@ -2919,8 +2919,8 @@ def __init__( value: Optional[List["_models.DscNode"]] = None, next_link: Optional[str] = None, total_count: Optional[int] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword value: Gets or sets a list of dsc nodes. :paramtype value: list[~azure.mgmt.automation.models.DscNode] @@ -3023,8 +3023,8 @@ def __init__( i_pv6_addresses: Optional[List[str]] = None, number_of_resources: Optional[int] = None, raw_errors: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword end_time: Gets or sets the end time of the node report. :paramtype end_time: ~datetime.datetime @@ -3103,8 +3103,8 @@ class DscNodeReportListResult(_serialization.Model): } def __init__( - self, *, value: Optional[List["_models.DscNodeReport"]] = None, next_link: Optional[str] = None, **kwargs - ): + self, *, value: Optional[List["_models.DscNodeReport"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: Gets or sets a list of dsc node reports. :paramtype value: list[~azure.mgmt.automation.models.DscNodeReport] @@ -3135,8 +3135,8 @@ def __init__( *, node_id: Optional[str] = None, properties: Optional["_models.DscNodeUpdateParametersProperties"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword node_id: Gets or sets the id of the dsc node. :paramtype node_id: str @@ -3159,7 +3159,7 @@ class DscNodeUpdateParametersProperties(_serialization.Model): "name": {"key": "nodeConfiguration.name", "type": "str"}, } - def __init__(self, *, name: Optional[str] = None, **kwargs): + def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: """ :keyword name: Gets or sets the name of the dsc node configuration. :paramtype name: str @@ -3203,8 +3203,8 @@ def __init__( error_message: Optional[str] = None, locale: Optional[str] = None, error_details: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword error_source: Gets or sets the source of the error. :paramtype error_source: str @@ -3280,8 +3280,8 @@ def __init__( status: Optional[str] = None, duration_in_seconds: Optional[float] = None, start_date: Optional[datetime.datetime] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword resource_id: Gets or sets the ID of the resource. :paramtype resource_id: str @@ -3329,7 +3329,7 @@ class DscReportResourceNavigation(_serialization.Model): "resource_id": {"key": "resourceId", "type": "str"}, } - def __init__(self, *, resource_id: Optional[str] = None, **kwargs): + def __init__(self, *, resource_id: Optional[str] = None, **kwargs: Any) -> None: """ :keyword resource_id: Gets or sets the ID of the resource to navigate to. :paramtype resource_id: str @@ -3362,8 +3362,8 @@ def __init__( key_vault_properties: Optional["_models.KeyVaultProperties"] = None, key_source: Optional[Union[str, "_models.EncryptionKeySourceType"]] = None, identity: Optional["_models.EncryptionPropertiesIdentity"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword key_vault_properties: Key vault properties. :paramtype key_vault_properties: ~azure.mgmt.automation.models.KeyVaultProperties @@ -3384,7 +3384,7 @@ class EncryptionPropertiesIdentity(_serialization.Model): :ivar user_assigned_identity: The user identity used for CMK. It will be an ARM resource id in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. # pylint: disable=line-too-long :vartype user_assigned_identity: JSON """ @@ -3392,11 +3392,11 @@ class EncryptionPropertiesIdentity(_serialization.Model): "user_assigned_identity": {"key": "userAssignedIdentity", "type": "object"}, } - def __init__(self, *, user_assigned_identity: Optional[JSON] = None, **kwargs): + def __init__(self, *, user_assigned_identity: Optional[JSON] = None, **kwargs: Any) -> None: """ :keyword user_assigned_identity: The user identity used for CMK. It will be an ARM resource id in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. # pylint: disable=line-too-long :paramtype user_assigned_identity: JSON """ super().__init__(**kwargs) @@ -3417,7 +3417,7 @@ class ErrorResponse(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code. :paramtype code: str @@ -3432,7 +3432,7 @@ def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, class FieldDefinition(_serialization.Model): """Definition of the connection fields. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar is_encrypted: Gets or sets the isEncrypted flag of the connection field definition. :vartype is_encrypted: bool @@ -3452,7 +3452,9 @@ class FieldDefinition(_serialization.Model): "type": {"key": "type", "type": "str"}, } - def __init__(self, *, type: str, is_encrypted: Optional[bool] = None, is_optional: Optional[bool] = None, **kwargs): + def __init__( + self, *, type: str, is_encrypted: Optional[bool] = None, is_optional: Optional[bool] = None, **kwargs: Any + ) -> None: """ :keyword is_encrypted: Gets or sets the isEncrypted flag of the connection field definition. :paramtype is_encrypted: bool @@ -3486,8 +3488,8 @@ def __init__( *, raw_content: Optional["_models.RawGraphicalRunbookContent"] = None, graph_runbook_json: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword raw_content: Raw graphical Runbook content. :paramtype raw_content: ~azure.mgmt.automation.models.RawGraphicalRunbookContent @@ -3555,8 +3557,8 @@ def __init__( vm_resource_id: Optional[str] = None, worker_type: Optional[Union[str, "_models.WorkerType"]] = None, worker_name: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword ip: Gets or sets the assigned machine IP address. :paramtype ip: str @@ -3595,7 +3597,7 @@ class HybridRunbookWorkerCreateParameters(_serialization.Model): "vm_resource_id": {"key": "properties.vmResourceId", "type": "str"}, } - def __init__(self, *, name: Optional[str] = None, vm_resource_id: Optional[str] = None, **kwargs): + def __init__(self, *, name: Optional[str] = None, vm_resource_id: Optional[str] = None, **kwargs: Any) -> None: """ :keyword name: Gets or sets the name of the resource. :paramtype name: str @@ -3647,8 +3649,8 @@ def __init__( *, group_type: Optional[Union[str, "_models.GroupTypeEnum"]] = None, credential: Optional["_models.RunAsCredentialAssociationProperty"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword group_type: Type of the HybridWorkerGroup. Known values are: "User" and "System". :paramtype group_type: str or ~azure.mgmt.automation.models.GroupTypeEnum @@ -3661,7 +3663,7 @@ def __init__( self.credential = credential -class HybridRunbookWorkerGroupCreateOrUpdateParameters(_serialization.Model): +class HybridRunbookWorkerGroupCreateOrUpdateParameters(_serialization.Model): # pylint: disable=name-too-long """The parameters supplied to the create hybrid runbook worker group operation. :ivar name: Gets or sets the name of the resource. @@ -3680,8 +3682,8 @@ def __init__( *, name: Optional[str] = None, credential: Optional["_models.RunAsCredentialAssociationProperty"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Gets or sets the name of the resource. :paramtype name: str @@ -3712,8 +3714,8 @@ def __init__( *, value: Optional[List["_models.HybridRunbookWorkerGroup"]] = None, next_link: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword value: Gets or sets a list of hybrid runbook worker groups. :paramtype value: list[~azure.mgmt.automation.models.HybridRunbookWorkerGroup] @@ -3736,7 +3738,7 @@ class HybridRunbookWorkerMoveParameters(_serialization.Model): "hybrid_runbook_worker_group_name": {"key": "hybridRunbookWorkerGroupName", "type": "str"}, } - def __init__(self, *, hybrid_runbook_worker_group_name: Optional[str] = None, **kwargs): + def __init__(self, *, hybrid_runbook_worker_group_name: Optional[str] = None, **kwargs: Any) -> None: """ :keyword hybrid_runbook_worker_group_name: Gets or sets the target hybrid runbook worker group. :paramtype hybrid_runbook_worker_group_name: str @@ -3760,8 +3762,12 @@ class HybridRunbookWorkersListResult(_serialization.Model): } def __init__( - self, *, value: Optional[List["_models.HybridRunbookWorker"]] = None, next_link: Optional[str] = None, **kwargs - ): + self, + *, + value: Optional[List["_models.HybridRunbookWorker"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: """ :keyword value: Gets or sets a list of hybrid runbook workers. :paramtype value: list[~azure.mgmt.automation.models.HybridRunbookWorker] @@ -3787,7 +3793,7 @@ class Identity(_serialization.Model): :vartype type: str or ~azure.mgmt.automation.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. # pylint: disable=line-too-long :vartype user_assigned_identities: dict[str, ~azure.mgmt.automation.models.UserAssignedIdentitiesProperties] """ @@ -3809,15 +3815,15 @@ def __init__( *, type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentitiesProperties"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.automation.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. # pylint: disable=line-too-long :paramtype user_assigned_identities: dict[str, ~azure.mgmt.automation.models.UserAssignedIdentitiesProperties] """ @@ -3916,8 +3922,8 @@ def __init__( last_status_modified_time: Optional[datetime.datetime] = None, parameters: Optional[Dict[str, str]] = None, provisioning_state: Optional[Union[str, "_models.JobProvisioningState"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword runbook: Gets or sets the runbook. :paramtype runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty @@ -4031,7 +4037,7 @@ class JobCollectionItem(ProxyResource): # pylint: disable=too-many-instance-att "run_on": {"key": "properties.runOn", "type": "str"}, } - def __init__(self, *, run_on: Optional[str] = None, **kwargs): + def __init__(self, *, run_on: Optional[str] = None, **kwargs: Any) -> None: """ :keyword run_on: Specifies the runOn group name where the job was executed. :paramtype run_on: str @@ -4072,8 +4078,8 @@ def __init__( runbook: Optional["_models.RunbookAssociationProperty"] = None, parameters: Optional[Dict[str, str]] = None, run_on: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword runbook: Gets or sets the runbook. :paramtype runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty @@ -4109,7 +4115,7 @@ class JobListResultV2(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.JobCollectionItem"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.JobCollectionItem"]] = None, **kwargs: Any) -> None: """ :keyword value: List of jobs. :paramtype value: list[~azure.mgmt.automation.models.JobCollectionItem] @@ -4136,7 +4142,7 @@ class JobNavigation(_serialization.Model): "id": {"key": "id", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None @@ -4190,8 +4196,8 @@ def __init__( runbook: Optional["_models.RunbookAssociationProperty"] = None, run_on: Optional[str] = None, parameters: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword job_schedule_id: Gets or sets the id of job schedule. :paramtype job_schedule_id: str @@ -4218,7 +4224,7 @@ def __init__( class JobScheduleCreateParameters(_serialization.Model): """The parameters supplied to the create job schedule operation. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar schedule: Gets or sets the schedule. Required. :vartype schedule: ~azure.mgmt.automation.models.ScheduleAssociationProperty @@ -4249,8 +4255,8 @@ def __init__( runbook: "_models.RunbookAssociationProperty", run_on: Optional[str] = None, parameters: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword schedule: Gets or sets the schedule. Required. :paramtype schedule: ~azure.mgmt.automation.models.ScheduleAssociationProperty @@ -4283,8 +4289,8 @@ class JobScheduleListResult(_serialization.Model): } def __init__( - self, *, value: Optional[List["_models.JobSchedule"]] = None, next_link: Optional[str] = None, **kwargs - ): + self, *, value: Optional[List["_models.JobSchedule"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: Gets or sets a list of job schedules. :paramtype value: list[~azure.mgmt.automation.models.JobSchedule] @@ -4336,8 +4342,8 @@ def __init__( stream_text: Optional[str] = None, summary: Optional[str] = None, value: Optional[Dict[str, JSON]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword id: Gets or sets the id of the resource. :paramtype id: str @@ -4379,7 +4385,9 @@ class JobStreamListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.JobStream"]] = None, next_link: Optional[str] = None, **kwargs): + def __init__( + self, *, value: Optional[List["_models.JobStream"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: A list of job streams. :paramtype value: list[~azure.mgmt.automation.models.JobStream] @@ -4416,7 +4424,7 @@ class Key(_serialization.Model): "value": {"key": "Value", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.key_name = None @@ -4435,7 +4443,7 @@ class KeyListResult(_serialization.Model): "keys": {"key": "keys", "type": "[Key]"}, } - def __init__(self, *, keys: Optional[List["_models.Key"]] = None, **kwargs): + def __init__(self, *, keys: Optional[List["_models.Key"]] = None, **kwargs: Any) -> None: """ :keyword keys: Lists the automation keys. :paramtype keys: list[~azure.mgmt.automation.models.Key] @@ -4467,8 +4475,8 @@ def __init__( keyvault_uri: Optional[str] = None, key_name: Optional[str] = None, key_version: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword keyvault_uri: The URI of the key vault key used to encrypt data. :paramtype keyvault_uri: str @@ -4500,7 +4508,7 @@ class LinkedWorkspace(_serialization.Model): "id": {"key": "id", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None @@ -4535,8 +4543,8 @@ def __init__( excluded_package_name_masks: Optional[List[str]] = None, included_package_name_masks: Optional[List[str]] = None, reboot_setting: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword included_package_classifications: Update classifications included in the software update configuration. Known values are: "Unclassified", "Critical", "Security", and "Other". @@ -4579,8 +4587,8 @@ def __init__( name: Optional[str] = None, display_name: Optional[str] = None, blob_duration: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: The name of the specification. :paramtype name: str @@ -4630,8 +4638,8 @@ def __init__( unit: Optional[str] = None, aggregation_type: Optional[str] = None, dimensions: Optional[List["_models.Dimension"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: The name of the metric. :paramtype name: str @@ -4670,33 +4678,33 @@ class Module(TrackedResource): # pylint: disable=too-many-instance-attributes :vartype tags: dict[str, str] :ivar location: The Azure Region where the resource lives. :vartype location: str - :ivar etag: Gets or sets the etag of the resource. + :ivar etag: Gets the etag of the resource. :vartype etag: str - :ivar is_global: Gets or sets the isGlobal flag of the module. + :ivar is_global: Gets the isGlobal flag of the module. :vartype is_global: bool - :ivar version: Gets or sets the version of the module. + :ivar version: Gets the version of the module. :vartype version: str - :ivar size_in_bytes: Gets or sets the size in bytes of the module. + :ivar size_in_bytes: Gets the size in bytes of the module. :vartype size_in_bytes: int - :ivar activity_count: Gets or sets the activity count of the module. + :ivar activity_count: Gets the activity count of the module. :vartype activity_count: int - :ivar provisioning_state: Gets or sets the provisioning state of the module. Known values are: + :ivar provisioning_state: Gets the provisioning state of the module. Known values are: "Created", "Creating", "StartingImportModuleRunbook", "RunningImportModuleRunbook", "ContentRetrieved", "ContentDownloaded", "ContentValidated", "ConnectionTypeImported", "ContentStored", "ModuleDataStored", "ActivitiesStored", "ModuleImportRunbookComplete", - "Succeeded", "Failed", "Cancelled", and "Updating". + "Succeeded", "Failed", "Canceled", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.automation.models.ModuleProvisioningState :ivar content_link: Gets or sets the contentLink of the module. :vartype content_link: ~azure.mgmt.automation.models.ContentLink - :ivar error: Gets or sets the error info of the module. + :ivar error: Gets the error info of the module. :vartype error: ~azure.mgmt.automation.models.ModuleErrorInfo - :ivar creation_time: Gets or sets the creation time. + :ivar creation_time: Gets the creation time. :vartype creation_time: ~datetime.datetime - :ivar last_modified_time: Gets or sets the last modified time. + :ivar last_modified_time: Gets the last modified time. :vartype last_modified_time: ~datetime.datetime :ivar description: Gets or sets the description. :vartype description: str - :ivar is_composite: Gets or sets type of module, if its composite or not. + :ivar is_composite: Gets type of module, if its composite or not. :vartype is_composite: bool """ @@ -4743,40 +4751,40 @@ def __init__( last_modified_time: Optional[datetime.datetime] = None, description: Optional[str] = None, is_composite: Optional[bool] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword location: The Azure Region where the resource lives. :paramtype location: str - :keyword etag: Gets or sets the etag of the resource. + :keyword etag: Gets the etag of the resource. :paramtype etag: str - :keyword is_global: Gets or sets the isGlobal flag of the module. + :keyword is_global: Gets the isGlobal flag of the module. :paramtype is_global: bool - :keyword version: Gets or sets the version of the module. + :keyword version: Gets the version of the module. :paramtype version: str - :keyword size_in_bytes: Gets or sets the size in bytes of the module. + :keyword size_in_bytes: Gets the size in bytes of the module. :paramtype size_in_bytes: int - :keyword activity_count: Gets or sets the activity count of the module. + :keyword activity_count: Gets the activity count of the module. :paramtype activity_count: int - :keyword provisioning_state: Gets or sets the provisioning state of the module. Known values - are: "Created", "Creating", "StartingImportModuleRunbook", "RunningImportModuleRunbook", + :keyword provisioning_state: Gets the provisioning state of the module. Known values are: + "Created", "Creating", "StartingImportModuleRunbook", "RunningImportModuleRunbook", "ContentRetrieved", "ContentDownloaded", "ContentValidated", "ConnectionTypeImported", "ContentStored", "ModuleDataStored", "ActivitiesStored", "ModuleImportRunbookComplete", - "Succeeded", "Failed", "Cancelled", and "Updating". + "Succeeded", "Failed", "Canceled", and "Updating". :paramtype provisioning_state: str or ~azure.mgmt.automation.models.ModuleProvisioningState :keyword content_link: Gets or sets the contentLink of the module. :paramtype content_link: ~azure.mgmt.automation.models.ContentLink - :keyword error: Gets or sets the error info of the module. + :keyword error: Gets the error info of the module. :paramtype error: ~azure.mgmt.automation.models.ModuleErrorInfo - :keyword creation_time: Gets or sets the creation time. + :keyword creation_time: Gets the creation time. :paramtype creation_time: ~datetime.datetime - :keyword last_modified_time: Gets or sets the last modified time. + :keyword last_modified_time: Gets the last modified time. :paramtype last_modified_time: ~datetime.datetime :keyword description: Gets or sets the description. :paramtype description: str - :keyword is_composite: Gets or sets type of module, if its composite or not. + :keyword is_composite: Gets type of module, if its composite or not. :paramtype is_composite: bool """ super().__init__(tags=tags, location=location, **kwargs) @@ -4797,15 +4805,15 @@ def __init__( class ModuleCreateOrUpdateParameters(_serialization.Model): """The parameters supplied to the create or update module operation. - All 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 name of the resource. + :ivar name: Sets name of the resource. :vartype name: str - :ivar location: Gets or sets the location of the resource. + :ivar location: Sets the location of the resource. :vartype location: str - :ivar tags: Gets or sets the tags attached to the resource. + :ivar tags: Sets the tags attached to the resource. :vartype tags: dict[str, str] - :ivar content_link: Gets or sets the module content link. Required. + :ivar content_link: Sets the hash. Required. :vartype content_link: ~azure.mgmt.automation.models.ContentLink """ @@ -4827,16 +4835,16 @@ def __init__( name: Optional[str] = None, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ - :keyword name: Gets or sets name of the resource. + :keyword name: Sets name of the resource. :paramtype name: str - :keyword location: Gets or sets the location of the resource. + :keyword location: Sets the location of the resource. :paramtype location: str - :keyword tags: Gets or sets the tags attached to the resource. + :keyword tags: Sets the tags attached to the resource. :paramtype tags: dict[str, str] - :keyword content_link: Gets or sets the module content link. Required. + :keyword content_link: Sets the hash. Required. :paramtype content_link: ~azure.mgmt.automation.models.ContentLink """ super().__init__(**kwargs) @@ -4849,9 +4857,9 @@ def __init__( class ModuleErrorInfo(_serialization.Model): """Definition of the module error info type. - :ivar code: Gets or sets the error code. + :ivar code: Gets the error code. :vartype code: str - :ivar message: Gets or sets the error message. + :ivar message: Gets the error message. :vartype message: str """ @@ -4860,11 +4868,11 @@ class ModuleErrorInfo(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword code: Gets or sets the error code. + :keyword code: Gets the error code. :paramtype code: str - :keyword message: Gets or sets the error message. + :keyword message: Gets the error message. :paramtype message: str """ super().__init__(**kwargs) @@ -4875,9 +4883,9 @@ def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, class ModuleListResult(_serialization.Model): """The response model for the list module operation. - :ivar value: Gets or sets a list of modules. + :ivar value: Gets a list of modules. :vartype value: list[~azure.mgmt.automation.models.Module] - :ivar next_link: Gets or sets the next link. + :ivar next_link: Gets the next link. :vartype next_link: str """ @@ -4886,11 +4894,13 @@ class ModuleListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.Module"]] = None, next_link: Optional[str] = None, **kwargs): + def __init__( + self, *, value: Optional[List["_models.Module"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ - :keyword value: Gets or sets a list of modules. + :keyword value: Gets a list of modules. :paramtype value: list[~azure.mgmt.automation.models.Module] - :keyword next_link: Gets or sets the next link. + :keyword next_link: Gets the next link. :paramtype next_link: str """ super().__init__(**kwargs) @@ -4901,16 +4911,23 @@ def __init__(self, *, value: Optional[List["_models.Module"]] = None, next_link: class ModuleUpdateParameters(_serialization.Model): """The parameters supplied to the update module operation. - :ivar name: Gets or sets name of the resource. + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Sets name of the resource. :vartype name: str - :ivar location: Gets or sets the location of the resource. + :ivar location: Sets the location of the resource. :vartype location: str - :ivar tags: Gets or sets the tags attached to the resource. + :ivar tags: Sets the tags attached to the resource. :vartype tags: dict[str, str] - :ivar content_link: Gets or sets the module content link. + :ivar content_link: Sets the module content link. :vartype content_link: ~azure.mgmt.automation.models.ContentLink """ + _validation = { + "name": {"readonly": True}, + "location": {"readonly": True}, + } + _attribute_map = { "name": {"key": "name", "type": "str"}, "location": {"key": "location", "type": "str"}, @@ -4921,25 +4938,19 @@ class ModuleUpdateParameters(_serialization.Model): def __init__( self, *, - name: Optional[str] = None, - location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, content_link: Optional["_models.ContentLink"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ - :keyword name: Gets or sets name of the resource. - :paramtype name: str - :keyword location: Gets or sets the location of the resource. - :paramtype location: str - :keyword tags: Gets or sets the tags attached to the resource. + :keyword tags: Sets the tags attached to the resource. :paramtype tags: dict[str, str] - :keyword content_link: Gets or sets the module content link. + :keyword content_link: Sets the module content link. :paramtype content_link: ~azure.mgmt.automation.models.ContentLink """ super().__init__(**kwargs) - self.name = name - self.location = location + self.name = None + self.location = None self.tags = tags self.content_link = content_link @@ -4959,8 +4970,8 @@ class NodeCount(_serialization.Model): } def __init__( - self, *, name: Optional[str] = None, properties: Optional["_models.NodeCountProperties"] = None, **kwargs - ): + self, *, name: Optional[str] = None, properties: Optional["_models.NodeCountProperties"] = None, **kwargs: Any + ) -> None: """ :keyword name: Gets the name of a count type. :paramtype name: str @@ -4983,7 +4994,7 @@ class NodeCountProperties(_serialization.Model): "count": {"key": "count", "type": "int"}, } - def __init__(self, *, count: Optional[int] = None, **kwargs): + def __init__(self, *, count: Optional[int] = None, **kwargs: Any) -> None: """ :keyword count: Gets the count for the name. :paramtype count: int @@ -5007,8 +5018,8 @@ class NodeCounts(_serialization.Model): } def __init__( - self, *, value: Optional[List["_models.NodeCount"]] = None, total_count: Optional[int] = None, **kwargs - ): + self, *, value: Optional[List["_models.NodeCount"]] = None, total_count: Optional[int] = None, **kwargs: Any + ) -> None: """ :keyword value: Gets an array of counts. :paramtype value: list[~azure.mgmt.automation.models.NodeCount] @@ -5034,7 +5045,9 @@ class NonAzureQueryProperties(_serialization.Model): "workspace_id": {"key": "workspaceId", "type": "str"}, } - def __init__(self, *, function_alias: Optional[str] = None, workspace_id: Optional[str] = None, **kwargs): + def __init__( + self, *, function_alias: Optional[str] = None, workspace_id: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword function_alias: Log Analytics Saved Search name. :paramtype function_alias: str @@ -5077,8 +5090,8 @@ def __init__( display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, service_specification: Optional["_models.OperationPropertiesFormatServiceSpecification"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str @@ -5124,8 +5137,8 @@ def __init__( resource: Optional[str] = None, operation: Optional[str] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword provider: Service provider: Microsoft.Automation. :paramtype provider: str @@ -5154,7 +5167,7 @@ class OperationListResult(_serialization.Model): "value": {"key": "value", "type": "[Operation]"}, } - def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwargs: Any) -> None: """ :keyword value: List of Automation operations supported by the Automation resource provider. :paramtype value: list[~azure.mgmt.automation.models.Operation] @@ -5163,7 +5176,7 @@ def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwarg self.value = value -class OperationPropertiesFormatServiceSpecification(_serialization.Model): +class OperationPropertiesFormatServiceSpecification(_serialization.Model): # pylint: disable=name-too-long """Specification of the service. :ivar metric_specifications: Operation service specification. @@ -5182,8 +5195,8 @@ def __init__( *, metric_specifications: Optional[List["_models.MetricSpecification"]] = None, log_specifications: Optional[List["_models.LogSpecification"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword metric_specifications: Operation service specification. :paramtype metric_specifications: list[~azure.mgmt.automation.models.MetricSpecification] @@ -5240,8 +5253,8 @@ def __init__( private_endpoint: Optional["_models.PrivateEndpointProperty"] = None, group_ids: Optional[List[str]] = None, private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionStateProperty"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword private_endpoint: Private endpoint which the connection belongs to. :paramtype private_endpoint: ~azure.mgmt.automation.models.PrivateEndpointProperty @@ -5269,7 +5282,7 @@ class PrivateEndpointConnectionListResult(_serialization.Model): "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, } - def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs: Any) -> None: """ :keyword value: Array of private endpoint connections. :paramtype value: list[~azure.mgmt.automation.models.PrivateEndpointConnection] @@ -5289,7 +5302,7 @@ class PrivateEndpointProperty(_serialization.Model): "id": {"key": "id", "type": "str"}, } - def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin """ :keyword id: Resource id of the private endpoint. :paramtype id: str @@ -5331,7 +5344,7 @@ class PrivateLinkResource(ProxyResource): "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.group_id = None @@ -5349,7 +5362,7 @@ class PrivateLinkResourceListResult(_serialization.Model): "value": {"key": "value", "type": "[PrivateLinkResource]"}, } - def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs: Any) -> None: """ :keyword value: Array of private link resources. :paramtype value: list[~azure.mgmt.automation.models.PrivateLinkResource] @@ -5358,7 +5371,7 @@ def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = Non self.value = value -class PrivateLinkServiceConnectionStateProperty(_serialization.Model): +class PrivateLinkServiceConnectionStateProperty(_serialization.Model): # pylint: disable=name-too-long """Connection State of the Private Endpoint Connection. Variables are only populated by the server, and will be ignored when sending a request. @@ -5382,7 +5395,7 @@ class PrivateLinkServiceConnectionStateProperty(_serialization.Model): "actions_required": {"key": "actionsRequired", "type": "str"}, } - def __init__(self, *, status: Optional[str] = None, description: Optional[str] = None, **kwargs): + def __init__(self, *, status: Optional[str] = None, description: Optional[str] = None, **kwargs: Any) -> None: """ :keyword status: The private link service connection status. :paramtype status: str @@ -5398,7 +5411,7 @@ def __init__(self, *, status: Optional[str] = None, description: Optional[str] = class PythonPackageCreateParameters(_serialization.Model): """The parameters supplied to the create or update module operation. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar tags: Gets or sets the tags attached to the resource. :vartype tags: dict[str, str] @@ -5415,7 +5428,9 @@ class PythonPackageCreateParameters(_serialization.Model): "content_link": {"key": "properties.contentLink", "type": "ContentLink"}, } - def __init__(self, *, content_link: "_models.ContentLink", tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__( + self, *, content_link: "_models.ContentLink", tags: Optional[Dict[str, str]] = None, **kwargs: Any + ) -> None: """ :keyword tags: Gets or sets the tags attached to the resource. :paramtype tags: dict[str, str] @@ -5438,7 +5453,7 @@ class PythonPackageUpdateParameters(_serialization.Model): "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword tags: Gets or sets the tags attached to the resource. :paramtype tags: dict[str, str] @@ -5471,8 +5486,8 @@ def __init__( schema_version: Optional[str] = None, runbook_definition: Optional[str] = None, runbook_type: Optional[Union[str, "_models.GraphRunbookType"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword schema_version: Schema version of the serializer. :paramtype schema_version: str @@ -5499,7 +5514,7 @@ class RunAsCredentialAssociationProperty(_serialization.Model): "name": {"key": "name", "type": "str"}, } - def __init__(self, *, name: Optional[str] = None, **kwargs): + def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: """ :keyword name: Gets or sets the name of the credential. :paramtype name: str @@ -5527,7 +5542,7 @@ class Runbook(TrackedResource): # pylint: disable=too-many-instance-attributes :vartype etag: str :ivar runbook_type: Gets or sets the type of the runbook. Known values are: "Script", "Graph", "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", "GraphPowerShell", "Python2", - and "Python3". + "Python3", and "PowerShell72". :vartype runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum :ivar publish_content_link: Gets or sets the published runbook content link. :vartype publish_content_link: ~azure.mgmt.automation.models.ContentLink @@ -5612,8 +5627,8 @@ def __init__( creation_time: Optional[datetime.datetime] = None, last_modified_time: Optional[datetime.datetime] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -5623,7 +5638,7 @@ def __init__( :paramtype etag: str :keyword runbook_type: Gets or sets the type of the runbook. Known values are: "Script", "Graph", "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", "GraphPowerShell", - "Python2", and "Python3". + "Python2", "Python3", and "PowerShell72". :paramtype runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum :keyword publish_content_link: Gets or sets the published runbook content link. :paramtype publish_content_link: ~azure.mgmt.automation.models.ContentLink @@ -5686,7 +5701,7 @@ class RunbookAssociationProperty(_serialization.Model): "name": {"key": "name", "type": "str"}, } - def __init__(self, *, name: Optional[str] = None, **kwargs): + def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: """ :keyword name: Gets or sets the name of the runbook. :paramtype name: str @@ -5698,7 +5713,7 @@ def __init__(self, *, name: Optional[str] = None, **kwargs): class RunbookCreateOrUpdateDraftParameters(_serialization.Model): """The parameters supplied to the create or update runbook operation. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar runbook_content: Content of the Runbook. Required. :vartype runbook_content: str @@ -5712,7 +5727,7 @@ class RunbookCreateOrUpdateDraftParameters(_serialization.Model): "runbook_content": {"key": "runbookContent", "type": "str"}, } - def __init__(self, *, runbook_content: str, **kwargs): + def __init__(self, *, runbook_content: str, **kwargs: Any) -> None: """ :keyword runbook_content: Content of the Runbook. Required. :paramtype runbook_content: str @@ -5724,7 +5739,7 @@ def __init__(self, *, runbook_content: str, **kwargs): class RunbookCreateOrUpdateDraftProperties(_serialization.Model): """The parameters supplied to the create or update draft runbook properties. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar log_verbose: Gets or sets verbose log option. :vartype log_verbose: bool @@ -5732,7 +5747,7 @@ class RunbookCreateOrUpdateDraftProperties(_serialization.Model): :vartype log_progress: bool :ivar runbook_type: Gets or sets the type of the runbook. Required. Known values are: "Script", "Graph", "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", "GraphPowerShell", - "Python2", and "Python3". + "Python2", "Python3", and "PowerShell72". :vartype runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum :ivar draft: Gets or sets the draft runbook properties. Required. :vartype draft: ~azure.mgmt.automation.models.RunbookDraft @@ -5765,8 +5780,8 @@ def __init__( log_progress: Optional[bool] = None, description: Optional[str] = None, log_activity_trace: Optional[int] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword log_verbose: Gets or sets verbose log option. :paramtype log_verbose: bool @@ -5774,7 +5789,7 @@ def __init__( :paramtype log_progress: bool :keyword runbook_type: Gets or sets the type of the runbook. Required. Known values are: "Script", "Graph", "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", - "GraphPowerShell", "Python2", and "Python3". + "GraphPowerShell", "Python2", "Python3", and "PowerShell72". :paramtype runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum :keyword draft: Gets or sets the draft runbook properties. Required. :paramtype draft: ~azure.mgmt.automation.models.RunbookDraft @@ -5795,7 +5810,7 @@ def __init__( class RunbookCreateOrUpdateParameters(_serialization.Model): """The parameters supplied to the create or update runbook operation. - All 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 name of the resource. :vartype name: str @@ -5809,7 +5824,7 @@ class RunbookCreateOrUpdateParameters(_serialization.Model): :vartype log_progress: bool :ivar runbook_type: Gets or sets the type of the runbook. Required. Known values are: "Script", "Graph", "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", "GraphPowerShell", - "Python2", and "Python3". + "Python2", "Python3", and "PowerShell72". :vartype runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum :ivar draft: Gets or sets the draft runbook properties. :vartype draft: ~azure.mgmt.automation.models.RunbookDraft @@ -5851,8 +5866,8 @@ def __init__( publish_content_link: Optional["_models.ContentLink"] = None, description: Optional[str] = None, log_activity_trace: Optional[int] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Gets or sets the name of the resource. :paramtype name: str @@ -5866,7 +5881,7 @@ def __init__( :paramtype log_progress: bool :keyword runbook_type: Gets or sets the type of the runbook. Required. Known values are: "Script", "Graph", "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", - "GraphPowerShell", "Python2", and "Python3". + "GraphPowerShell", "Python2", "Python3", and "PowerShell72". :paramtype runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum :keyword draft: Gets or sets the draft runbook properties. :paramtype draft: ~azure.mgmt.automation.models.RunbookDraft @@ -5925,8 +5940,8 @@ def __init__( last_modified_time: Optional[datetime.datetime] = None, parameters: Optional[Dict[str, "_models.RunbookParameter"]] = None, output_types: Optional[List[str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword in_edit: Gets or sets whether runbook is in edit mode. :paramtype in_edit: bool @@ -5962,7 +5977,7 @@ class RunbookDraftUndoEditResult(_serialization.Model): "LengthRequired", "PreconditionFailed", "RequestEntityTooLarge", "RequestUriTooLong", "UnsupportedMediaType", "RequestedRangeNotSatisfiable", "ExpectationFailed", "UpgradeRequired", "InternalServerError", "NotImplemented", "BadGateway", "ServiceUnavailable", "GatewayTimeout", - and "HttpVersionNotSupported". + "HttpVersionNotSupported", and "Continue". :vartype status_code: str or ~azure.mgmt.automation.models.HttpStatusCode :ivar request_id: :vartype request_id: str @@ -5978,8 +5993,8 @@ def __init__( *, status_code: Optional[Union[str, "_models.HttpStatusCode"]] = None, request_id: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword status_code: Known values are: "Continue", "SwitchingProtocols", "OK", "Created", "Accepted", "NonAuthoritativeInformation", "NoContent", "ResetContent", "PartialContent", @@ -5990,7 +6005,7 @@ def __init__( "LengthRequired", "PreconditionFailed", "RequestEntityTooLarge", "RequestUriTooLong", "UnsupportedMediaType", "RequestedRangeNotSatisfiable", "ExpectationFailed", "UpgradeRequired", "InternalServerError", "NotImplemented", "BadGateway", "ServiceUnavailable", "GatewayTimeout", - and "HttpVersionNotSupported". + "HttpVersionNotSupported", and "Continue". :paramtype status_code: str or ~azure.mgmt.automation.models.HttpStatusCode :keyword request_id: :paramtype request_id: str @@ -6014,7 +6029,9 @@ class RunbookListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.Runbook"]] = None, next_link: Optional[str] = None, **kwargs): + def __init__( + self, *, value: Optional[List["_models.Runbook"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: Gets or sets a list of runbooks. :paramtype value: list[~azure.mgmt.automation.models.Runbook] @@ -6054,8 +6071,8 @@ def __init__( is_mandatory: Optional[bool] = None, position: Optional[int] = None, default_value: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword type: Gets or sets the type of the parameter. :paramtype type: str @@ -6113,8 +6130,8 @@ def __init__( log_verbose: Optional[bool] = None, log_progress: Optional[bool] = None, log_activity_trace: Optional[int] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Gets or sets the name of the resource. :paramtype name: str @@ -6226,8 +6243,8 @@ def __init__( creation_time: Optional[datetime.datetime] = None, last_modified_time: Optional[datetime.datetime] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword start_time: Gets or sets the start time of the schedule. :paramtype start_time: ~datetime.datetime @@ -6285,7 +6302,7 @@ class ScheduleAssociationProperty(_serialization.Model): "name": {"key": "name", "type": "str"}, } - def __init__(self, *, name: Optional[str] = None, **kwargs): + def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: """ :keyword name: Gets or sets the name of the Schedule. :paramtype name: str @@ -6297,7 +6314,7 @@ def __init__(self, *, name: Optional[str] = None, **kwargs): class ScheduleCreateOrUpdateParameters(_serialization.Model): """The parameters supplied to the create or update schedule operation. - All 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 name of the Schedule. Required. :vartype name: str @@ -6346,8 +6363,8 @@ def __init__( interval: Optional[Any] = None, time_zone: Optional[str] = None, advanced_schedule: Optional["_models.AdvancedSchedule"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Gets or sets the name of the Schedule. Required. :paramtype name: str @@ -6392,7 +6409,9 @@ class ScheduleListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.Schedule"]] = None, next_link: Optional[str] = None, **kwargs): + def __init__( + self, *, value: Optional[List["_models.Schedule"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: Gets or sets a list of schedules. :paramtype value: list[~azure.mgmt.automation.models.Schedule] @@ -6427,8 +6446,8 @@ def __init__( name: Optional[str] = None, description: Optional[str] = None, is_enabled: Optional[bool] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Gets or sets the name of the Schedule. :paramtype name: str @@ -6446,7 +6465,7 @@ def __init__( class Sku(_serialization.Model): """The account SKU. - All 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 of the account. Required. Known values are: "Free" and "Basic". @@ -6473,8 +6492,8 @@ def __init__( name: Union[str, "_models.SkuNameEnum"], family: Optional[str] = None, capacity: Optional[int] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Gets or sets the SKU name of the account. Required. Known values are: "Free" and "Basic". @@ -6495,7 +6514,7 @@ class SoftwareUpdateConfiguration(_serialization.Model): # pylint: disable=too- 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: Resource name. :vartype name: str @@ -6560,8 +6579,8 @@ def __init__( schedule_info: "_models.SUCScheduleProperties", error: Optional["_models.ErrorResponse"] = None, tasks: Optional["_models.SoftwareUpdateConfigurationTasks"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword update_configuration: update specific properties for the Software update configuration. Required. @@ -6588,7 +6607,7 @@ def __init__( self.tasks = tasks -class SoftwareUpdateConfigurationCollectionItem(_serialization.Model): +class SoftwareUpdateConfigurationCollectionItem(_serialization.Model): # pylint: disable=name-too-long """Software update configuration collection item properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -6648,8 +6667,8 @@ def __init__( frequency: Optional[Union[str, "_models.ScheduleFrequency"]] = None, start_time: Optional[datetime.datetime] = None, next_run: Optional[datetime.datetime] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword update_configuration: Update specific properties of the software update configuration. :paramtype update_configuration: ~azure.mgmt.automation.models.UpdateConfiguration @@ -6687,7 +6706,9 @@ class SoftwareUpdateConfigurationListResult(_serialization.Model): "value": {"key": "value", "type": "[SoftwareUpdateConfigurationCollectionItem]"}, } - def __init__(self, *, value: Optional[List["_models.SoftwareUpdateConfigurationCollectionItem"]] = None, **kwargs): + def __init__( + self, *, value: Optional[List["_models.SoftwareUpdateConfigurationCollectionItem"]] = None, **kwargs: Any + ) -> None: """ :keyword value: outer object returned when listing all software update configurations. :paramtype value: list[~azure.mgmt.automation.models.SoftwareUpdateConfigurationCollectionItem] @@ -6788,8 +6809,8 @@ def __init__( software_update_configuration: Optional["_models.UpdateConfigurationNavigation"] = None, job: Optional["_models.JobNavigation"] = None, error: Optional["_models.ErrorResponse"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword software_update_configuration: software update configuration triggered this run. :paramtype software_update_configuration: @@ -6820,7 +6841,7 @@ def __init__( self.error = error -class SoftwareUpdateConfigurationMachineRunListResult(_serialization.Model): +class SoftwareUpdateConfigurationMachineRunListResult(_serialization.Model): # pylint: disable=name-too-long """result of listing all software update configuration machine runs. :ivar value: outer object returned when listing all software update configuration machine runs. @@ -6839,8 +6860,8 @@ def __init__( *, value: Optional[List["_models.SoftwareUpdateConfigurationMachineRun"]] = None, next_link: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword value: outer object returned when listing all software update configuration machine runs. @@ -6933,8 +6954,8 @@ def __init__( *, software_update_configuration: Optional["_models.UpdateConfigurationNavigation"] = None, tasks: Optional["_models.SoftwareUpdateConfigurationRunTasks"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword software_update_configuration: software update configuration triggered this run. :paramtype software_update_configuration: @@ -6979,8 +7000,8 @@ def __init__( *, value: Optional[List["_models.SoftwareUpdateConfigurationRun"]] = None, next_link: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword value: outer object returned when listing all software update configuration runs. :paramtype value: list[~azure.mgmt.automation.models.SoftwareUpdateConfigurationRun] @@ -6992,7 +7013,7 @@ def __init__( self.next_link = next_link -class SoftwareUpdateConfigurationRunTaskProperties(_serialization.Model): +class SoftwareUpdateConfigurationRunTaskProperties(_serialization.Model): # pylint: disable=name-too-long """Task properties of the software update configuration. :ivar status: The status of the task. @@ -7010,8 +7031,8 @@ class SoftwareUpdateConfigurationRunTaskProperties(_serialization.Model): } def __init__( - self, *, status: Optional[str] = None, source: Optional[str] = None, job_id: Optional[str] = None, **kwargs - ): + self, *, status: Optional[str] = None, source: Optional[str] = None, job_id: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword status: The status of the task. :paramtype status: str @@ -7045,8 +7066,8 @@ def __init__( *, pre_task: Optional["_models.SoftwareUpdateConfigurationRunTaskProperties"] = None, post_task: Optional["_models.SoftwareUpdateConfigurationRunTaskProperties"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword pre_task: Pre task properties. :paramtype pre_task: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRunTaskProperties @@ -7078,8 +7099,8 @@ def __init__( *, pre_task: Optional["_models.TaskProperties"] = None, post_task: Optional["_models.TaskProperties"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword pre_task: Pre task properties. :paramtype pre_task: ~azure.mgmt.automation.models.TaskProperties @@ -7157,8 +7178,8 @@ def __init__( description: Optional[str] = None, creation_time: Optional[datetime.datetime] = None, last_modified_time: Optional[datetime.datetime] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword repo_url: The repo url of the source control. :paramtype repo_url: str @@ -7245,8 +7266,8 @@ def __init__( source_type: Optional[Union[str, "_models.SourceType"]] = None, security_token: Optional["_models.SourceControlSecurityTokenProperties"] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword repo_url: The repo url of the source control. :paramtype repo_url: str @@ -7293,8 +7314,8 @@ class SourceControlListResult(_serialization.Model): } def __init__( - self, *, value: Optional[List["_models.SourceControl"]] = None, next_link: Optional[str] = None, **kwargs - ): + self, *, value: Optional[List["_models.SourceControl"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: The list of source controls. :paramtype value: list[~azure.mgmt.automation.models.SourceControl] @@ -7335,8 +7356,8 @@ def __init__( access_token: Optional[str] = None, refresh_token: Optional[str] = None, token_type: Optional[Union[str, "_models.TokenType"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword access_token: The access token. :paramtype access_token: str @@ -7405,8 +7426,8 @@ def __init__( source_control_sync_job_id: Optional[str] = None, provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, sync_type: Optional[Union[str, "_models.SyncType"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword source_control_sync_job_id: The source control sync job id. :paramtype source_control_sync_job_id: str @@ -7477,8 +7498,8 @@ def __init__( provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, sync_type: Optional[Union[str, "_models.SyncType"]] = None, exception: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword id: The id of the job. :paramtype id: str @@ -7506,7 +7527,7 @@ def __init__( class SourceControlSyncJobCreateParameters(_serialization.Model): """The parameters supplied to the create source control sync job operation. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar commit_id: The commit id of the source control sync job. If not syncing to a commitId, enter an empty string. Required. @@ -7521,7 +7542,7 @@ class SourceControlSyncJobCreateParameters(_serialization.Model): "commit_id": {"key": "properties.commitId", "type": "str"}, } - def __init__(self, *, commit_id: str, **kwargs): + def __init__(self, *, commit_id: str, **kwargs: Any) -> None: """ :keyword commit_id: The commit id of the source control sync job. If not syncing to a commitId, enter an empty string. Required. @@ -7546,8 +7567,12 @@ class SourceControlSyncJobListResult(_serialization.Model): } def __init__( - self, *, value: Optional[List["_models.SourceControlSyncJob"]] = None, next_link: Optional[str] = None, **kwargs - ): + self, + *, + value: Optional[List["_models.SourceControlSyncJob"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: """ :keyword value: The list of source control sync jobs. :paramtype value: list[~azure.mgmt.automation.models.SourceControlSyncJob] @@ -7595,8 +7620,8 @@ def __init__( source_control_sync_job_stream_id: Optional[str] = None, summary: Optional[str] = None, stream_type: Optional[Union[str, "_models.StreamType"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword source_control_sync_job_stream_id: The sync job stream id. :paramtype source_control_sync_job_stream_id: str @@ -7657,8 +7682,8 @@ def __init__( stream_type: Optional[Union[str, "_models.StreamType"]] = None, stream_text: Optional[str] = None, value: Optional[Dict[str, JSON]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword source_control_sync_job_stream_id: The sync job stream id. :paramtype source_control_sync_job_stream_id: str @@ -7701,7 +7726,7 @@ class SourceControlSyncJobStreamsListBySyncJob(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.SourceControlSyncJobStream"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.SourceControlSyncJobStream"]] = None, **kwargs: Any) -> None: """ :keyword value: The list of source control sync job streams. :paramtype value: list[~azure.mgmt.automation.models.SourceControlSyncJobStream] @@ -7746,8 +7771,8 @@ def __init__( publish_runbook: Optional[bool] = None, security_token: Optional["_models.SourceControlSecurityTokenProperties"] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword branch: The repo branch of the source control. :paramtype branch: str @@ -7804,7 +7829,7 @@ class Statistics(_serialization.Model): "id": {"key": "id", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.counter_property = None @@ -7825,7 +7850,7 @@ class StatisticsListResult(_serialization.Model): "value": {"key": "value", "type": "[Statistics]"}, } - def __init__(self, *, value: Optional[List["_models.Statistics"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.Statistics"]] = None, **kwargs: Any) -> None: """ :keyword value: Gets or sets a list of statistics. :paramtype value: list[~azure.mgmt.automation.models.Statistics] @@ -7907,8 +7932,8 @@ def __init__( creation_time: Optional[datetime.datetime] = None, last_modified_time: Optional[datetime.datetime] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword start_time: Gets or sets the start time of the schedule. :paramtype start_time: ~datetime.datetime @@ -7992,8 +8017,8 @@ def __init__( last_modified_by: Optional[str] = None, last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword created_by: The identity that created the resource. :paramtype created_by: str @@ -8039,8 +8064,8 @@ def __init__( *, tags: Optional[Dict[str, List[str]]] = None, filter_operator: Optional[Union[str, "_models.TagOperators"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword tags: Dictionary of tags with its list of values. :paramtype tags: dict[str, list[str]] @@ -8072,8 +8097,8 @@ def __init__( *, azure_queries: Optional[List["_models.AzureQueryProperties"]] = None, non_azure_queries: Optional[List["_models.NonAzureQueryProperties"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword azure_queries: List of Azure queries in the software update configuration. :paramtype azure_queries: list[~azure.mgmt.automation.models.AzureQueryProperties] @@ -8099,7 +8124,9 @@ class TaskProperties(_serialization.Model): "source": {"key": "source", "type": "str"}, } - def __init__(self, *, parameters: Optional[Dict[str, str]] = None, source: Optional[str] = None, **kwargs): + def __init__( + self, *, parameters: Optional[Dict[str, str]] = None, source: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword parameters: Gets or sets the parameters of the task. :paramtype parameters: dict[str, str] @@ -8167,8 +8194,8 @@ def __init__( last_status_modified_time: Optional[datetime.datetime] = None, parameters: Optional[Dict[str, str]] = None, log_activity_trace: Optional[int] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword creation_time: Gets or sets the creation time of the test job. :paramtype creation_time: ~datetime.datetime @@ -8223,7 +8250,9 @@ class TestJobCreateParameters(_serialization.Model): "run_on": {"key": "runOn", "type": "str"}, } - def __init__(self, *, parameters: Optional[Dict[str, str]] = None, run_on: Optional[str] = None, **kwargs): + def __init__( + self, *, parameters: Optional[Dict[str, str]] = None, run_on: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword parameters: Gets or sets the parameters of the test job. :paramtype parameters: dict[str, str] @@ -8250,7 +8279,7 @@ class TypeField(_serialization.Model): "type": {"key": "type", "type": "str"}, } - def __init__(self, *, name: Optional[str] = None, type: Optional[str] = None, **kwargs): + def __init__(self, *, name: Optional[str] = None, type: Optional[str] = None, **kwargs: Any) -> None: """ :keyword name: Gets or sets the name of the field. :paramtype name: str @@ -8273,7 +8302,7 @@ class TypeFieldListResult(_serialization.Model): "value": {"key": "value", "type": "[TypeField]"}, } - def __init__(self, *, value: Optional[List["_models.TypeField"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.TypeField"]] = None, **kwargs: Any) -> None: """ :keyword value: Gets or sets a list of fields. :paramtype value: list[~azure.mgmt.automation.models.TypeField] @@ -8285,7 +8314,7 @@ def __init__(self, *, value: Optional[List["_models.TypeField"]] = None, **kwarg class UpdateConfiguration(_serialization.Model): """Update specific properties of the software update configuration. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar operating_system: operating system of target machines. Required. Known values are: "Windows" and "Linux". @@ -8331,8 +8360,8 @@ def __init__( azure_virtual_machines: Optional[List[str]] = None, non_azure_computer_names: Optional[List[str]] = None, targets: Optional["_models.TargetProperties"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword operating_system: operating system of target machines. Required. Known values are: "Windows" and "Linux". @@ -8381,7 +8410,7 @@ class UpdateConfigurationNavigation(_serialization.Model): "name": {"key": "name", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.name = None @@ -8422,8 +8451,8 @@ def __init__( current_value: Optional[float] = None, limit: Optional[int] = None, throttle_status: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword id: Gets or sets the id of the resource. :paramtype id: str @@ -8461,7 +8490,7 @@ class UsageCounterName(_serialization.Model): "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs): + def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs: Any) -> None: """ :keyword value: Gets or sets the usage counter name. :paramtype value: str @@ -8484,7 +8513,7 @@ class UsageListResult(_serialization.Model): "value": {"key": "value", "type": "[Usage]"}, } - def __init__(self, *, value: Optional[List["_models.Usage"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.Usage"]] = None, **kwargs: Any) -> None: """ :keyword value: Gets or sets usage. :paramtype value: list[~azure.mgmt.automation.models.Usage] @@ -8514,7 +8543,7 @@ class UserAssignedIdentitiesProperties(_serialization.Model): "client_id": {"key": "clientId", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.principal_id = None @@ -8569,8 +8598,8 @@ def __init__( creation_time: Optional[datetime.datetime] = None, last_modified_time: Optional[datetime.datetime] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword value: Gets or sets the value of the variable. :paramtype value: str @@ -8594,7 +8623,7 @@ def __init__( class VariableCreateOrUpdateParameters(_serialization.Model): """The parameters supplied to the create or update variable operation. - All 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 name of the variable. Required. :vartype name: str @@ -8624,8 +8653,8 @@ def __init__( value: Optional[str] = None, description: Optional[str] = None, is_encrypted: Optional[bool] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Gets or sets the name of the variable. Required. :paramtype name: str @@ -8657,7 +8686,9 @@ class VariableListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.Variable"]] = None, next_link: Optional[str] = None, **kwargs): + def __init__( + self, *, value: Optional[List["_models.Variable"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: Gets or sets a list of variables. :paramtype value: list[~azure.mgmt.automation.models.Variable] @@ -8687,8 +8718,13 @@ class VariableUpdateParameters(_serialization.Model): } def __init__( - self, *, name: Optional[str] = None, value: Optional[str] = None, description: Optional[str] = None, **kwargs - ): + self, + *, + name: Optional[str] = None, + value: Optional[str] = None, + description: Optional[str] = None, + **kwargs: Any + ) -> None: """ :keyword name: Gets or sets the name of the variable. :paramtype name: str @@ -8781,8 +8817,8 @@ def __init__( script_parameters: Optional[Dict[str, str]] = None, script_run_on: Optional[str] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword etag: Gets or sets the etag of the resource. :paramtype etag: str @@ -8833,7 +8869,9 @@ class WatcherListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.Watcher"]] = None, next_link: Optional[str] = None, **kwargs): + def __init__( + self, *, value: Optional[List["_models.Watcher"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: Gets or sets a list of watchers. :paramtype value: list[~azure.mgmt.automation.models.Watcher] @@ -8860,7 +8898,9 @@ class WatcherUpdateParameters(_serialization.Model): "execution_frequency_in_seconds": {"key": "properties.executionFrequencyInSeconds", "type": "int"}, } - def __init__(self, *, name: Optional[str] = None, execution_frequency_in_seconds: Optional[int] = None, **kwargs): + def __init__( + self, *, name: Optional[str] = None, execution_frequency_in_seconds: Optional[int] = None, **kwargs: Any + ) -> None: """ :keyword name: Gets or sets the name of the resource. :paramtype name: str @@ -8946,8 +8986,8 @@ def __init__( last_modified_time: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword is_enabled: Gets or sets the value of the enabled flag of the webhook. :paramtype is_enabled: bool @@ -8990,7 +9030,7 @@ def __init__( class WebhookCreateOrUpdateParameters(_serialization.Model): """The parameters supplied to the create or update webhook operation. - All 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 name of the webhook. Required. :vartype name: str @@ -9032,8 +9072,8 @@ def __init__( parameters: Optional[Dict[str, str]] = None, runbook: Optional["_models.RunbookAssociationProperty"] = None, run_on: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Gets or sets the name of the webhook. Required. :paramtype name: str @@ -9074,7 +9114,9 @@ class WebhookListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.Webhook"]] = None, next_link: Optional[str] = None, **kwargs): + def __init__( + self, *, value: Optional[List["_models.Webhook"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: Gets or sets a list of webhooks. :paramtype value: list[~azure.mgmt.automation.models.Webhook] @@ -9117,8 +9159,8 @@ def __init__( run_on: Optional[str] = None, parameters: Optional[Dict[str, str]] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Gets or sets the name of the webhook. :paramtype name: str @@ -9170,8 +9212,8 @@ def __init__( excluded_kb_numbers: Optional[List[str]] = None, included_kb_numbers: Optional[List[str]] = None, reboot_setting: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword included_update_classifications: Update classification included in the software update configuration. A comma separated string with required values. Known values are: "Unclassified", diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/__init__.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/__init__.py index ceadd5d1de73..98093c1e0571 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/__init__.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/__init__.py @@ -38,6 +38,7 @@ from ._module_operations import ModuleOperations from ._object_data_types_operations import ObjectDataTypesOperations from ._fields_operations import FieldsOperations +from ._power_shell72_module_operations import PowerShell72ModuleOperations from ._operations import Operations from ._automation_client_operations import AutomationClientOperationsMixin from ._python2_package_operations import Python2PackageOperations @@ -91,6 +92,7 @@ "ModuleOperations", "ObjectDataTypesOperations", "FieldsOperations", + "PowerShell72ModuleOperations", "Operations", "AutomationClientOperationsMixin", "Python2PackageOperations", diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_activity_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_activity_operations.py index 7838406aef1b..e56bccdda419 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_activity_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_activity_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +19,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -51,7 +50,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -69,7 +68,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -86,7 +85,7 @@ def build_list_by_module_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -103,7 +102,7 @@ def build_list_by_module_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -144,6 +143,9 @@ def get( ) -> _models.Activity: """Retrieve the activity in the module identified by module name and activity name. + .. seealso:: + - http://aka.ms/azureautomationsdk/activityoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -152,12 +154,11 @@ def get( :type module_name: str :param activity_name: The name of activity. Required. :type activity_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Activity or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Activity :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -168,25 +169,24 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.Activity] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, module_name=module_name, activity_name=activity_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -196,16 +196,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Activity", pipeline_response) + deserialized = self._deserialize("Activity", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities/{activityName}" - } + return deserialized # type: ignore @distributed_trace def list_by_module( @@ -213,13 +209,15 @@ def list_by_module( ) -> Iterable["_models.Activity"]: """Retrieve a list of activities in the module identified by module name. + .. seealso:: + - http://aka.ms/azureautomationsdk/activityoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param module_name: The name of module. Required. :type module_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Activity or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.Activity] :raises ~azure.core.exceptions.HttpResponseError: @@ -227,10 +225,10 @@ def list_by_module( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.ActivityListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -241,25 +239,22 @@ def list_by_module( def prepare_request(next_link=None): if not next_link: - request = build_list_by_module_request( + _request = build_list_by_module_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, module_name=module_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_module.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ActivityListResult", pipeline_response) @@ -269,10 +264,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -284,7 +280,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_module.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_agent_registration_information_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_agent_registration_information_operations.py index d87013f69d5a..432c29caa36e 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_agent_registration_information_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_agent_registration_information_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,20 +19,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -45,9 +45,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +61,7 @@ def build_get_request( "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,9 +78,7 @@ def build_regenerate_key_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -99,7 +95,7 @@ def build_regenerate_key_request( "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -135,16 +131,18 @@ def __init__(self, *args, **kwargs): def get(self, resource_group_name: str, automation_account_name: str, **kwargs: Any) -> _models.AgentRegistration: """Retrieve the automation agent registration information. + .. seealso:: + - http://aka.ms/azureautomationsdk/agentregistrationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AgentRegistration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AgentRegistration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -155,25 +153,22 @@ def get(self, resource_group_name: str, automation_account_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.AgentRegistration] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -183,16 +178,12 @@ def get(self, resource_group_name: str, automation_account_name: str, **kwargs: error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AgentRegistration", pipeline_response) + deserialized = self._deserialize("AgentRegistration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation" - } + return deserialized # type: ignore @overload def regenerate_key( @@ -206,6 +197,9 @@ def regenerate_key( ) -> _models.AgentRegistration: """Regenerate a primary or secondary agent registration key. + .. seealso:: + - http://aka.ms/azureautomationsdk/agentregistrationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -215,7 +209,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: AgentRegistration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AgentRegistration :raises ~azure.core.exceptions.HttpResponseError: @@ -226,23 +219,25 @@ def regenerate_key( self, resource_group_name: str, automation_account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.AgentRegistration: """Regenerate a primary or secondary agent registration key. + .. seealso:: + - http://aka.ms/azureautomationsdk/agentregistrationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param parameters: The name of the agent registration key to be regenerated. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AgentRegistration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AgentRegistration :raises ~azure.core.exceptions.HttpResponseError: @@ -253,27 +248,27 @@ def regenerate_key( self, resource_group_name: str, automation_account_name: str, - parameters: Union[_models.AgentRegistrationRegenerateKeyParameter, IO], + parameters: Union[_models.AgentRegistrationRegenerateKeyParameter, IO[bytes]], **kwargs: Any ) -> _models.AgentRegistration: """Regenerate a primary or secondary agent registration key. + .. seealso:: + - http://aka.ms/azureautomationsdk/agentregistrationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str - :param parameters: The name of the agent registration key to be regenerated. Is either a model - type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.AgentRegistrationRegenerateKeyParameter or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 name of the agent registration key to be regenerated. Is either a + AgentRegistrationRegenerateKeyParameter type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.AgentRegistrationRegenerateKeyParameter or + IO[bytes] :return: AgentRegistration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AgentRegistration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -284,21 +279,19 @@ def regenerate_key( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AgentRegistration] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "AgentRegistrationRegenerateKeyParameter") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, @@ -306,15 +299,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -324,13 +316,9 @@ def regenerate_key( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AgentRegistration", pipeline_response) + deserialized = self._deserialize("AgentRegistration", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation/regenerateKey" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_automation_account_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_automation_account_operations.py index 3820d0877719..71a8be8c4611 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_automation_account_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_automation_account_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +20,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -46,7 +46,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -63,7 +63,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -82,7 +82,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -99,7 +99,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -118,7 +118,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -134,7 +134,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -151,7 +151,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -167,7 +167,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -182,7 +182,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -197,7 +197,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -212,7 +212,7 @@ def build_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: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -223,7 +223,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -265,6 +265,9 @@ def update( ) -> _models.AutomationAccount: """Update an automation account. + .. seealso:: + - http://aka.ms/azureautomationsdk/automationaccountoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -274,7 +277,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: AutomationAccount or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -285,23 +287,25 @@ def update( self, resource_group_name: str, automation_account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.AutomationAccount: """Update an automation account. + .. seealso:: + - http://aka.ms/azureautomationsdk/automationaccountoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param parameters: Parameters supplied to the update automation 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: AutomationAccount or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -312,27 +316,26 @@ def update( self, resource_group_name: str, automation_account_name: str, - parameters: Union[_models.AutomationAccountUpdateParameters, IO], + parameters: Union[_models.AutomationAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.AutomationAccount: """Update an automation account. + .. seealso:: + - http://aka.ms/azureautomationsdk/automationaccountoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str - :param parameters: Parameters supplied to the update automation account. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.AutomationAccountUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Parameters supplied to the update automation account. Is either a + AutomationAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.AutomationAccountUpdateParameters or IO[bytes] :return: AutomationAccount or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -343,19 +346,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AutomationAccount] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "AutomationAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, @@ -363,15 +366,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -381,16 +383,12 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AutomationAccount", pipeline_response) + deserialized = self._deserialize("AutomationAccount", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -404,6 +402,9 @@ def create_or_update( ) -> _models.AutomationAccount: """Create or update automation account. + .. seealso:: + - http://aka.ms/azureautomationsdk/automationaccountoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -413,7 +414,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: AutomationAccount or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -424,23 +424,25 @@ def create_or_update( self, resource_group_name: str, automation_account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.AutomationAccount: """Create or update automation account. + .. seealso:: + - http://aka.ms/azureautomationsdk/automationaccountoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param parameters: Parameters supplied to the create or update automation 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: AutomationAccount or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -451,27 +453,27 @@ def create_or_update( self, resource_group_name: str, automation_account_name: str, - parameters: Union[_models.AutomationAccountCreateOrUpdateParameters, IO], + parameters: Union[_models.AutomationAccountCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.AutomationAccount: """Create or update automation account. + .. seealso:: + - http://aka.ms/azureautomationsdk/automationaccountoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param parameters: Parameters supplied to the create or update automation account. Is either a - model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.AutomationAccountCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + AutomationAccountCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.AutomationAccountCreateOrUpdateParameters or + IO[bytes] :return: AutomationAccount or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -482,19 +484,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AutomationAccount] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "AutomationAccountCreateOrUpdateParameters") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, @@ -502,15 +504,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -521,36 +522,34 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("AutomationAccount", pipeline_response) + deserialized = self._deserialize("AutomationAccount", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("AutomationAccount", pipeline_response) + deserialized = self._deserialize("AutomationAccount", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}" - } - @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, **kwargs: Any ) -> None: """Delete an automation account. + .. seealso:: + - http://aka.ms/azureautomationsdk/automationaccountoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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, @@ -561,23 +560,22 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -588,26 +586,24 @@ 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.Automation/automationAccounts/{automationAccountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get(self, resource_group_name: str, automation_account_name: str, **kwargs: Any) -> _models.AutomationAccount: """Get information about an Automation Account. + .. seealso:: + - http://aka.ms/azureautomationsdk/automationaccountoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AutomationAccount or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -618,23 +614,22 @@ def get(self, resource_group_name: str, automation_account_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.AutomationAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -644,24 +639,22 @@ def get(self, resource_group_name: str, automation_account_name: str, **kwargs: error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AutomationAccount", pipeline_response) + deserialized = self._deserialize("AutomationAccount", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}" - } + return deserialized # type: ignore @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.AutomationAccount"]: """Retrieve a list of accounts within a given resource group. + .. seealso:: + - http://aka.ms/azureautomationsdk/automationaccountoperations + :param resource_group_name: Name of an Azure Resource group. 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 AutomationAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.AutomationAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -669,10 +662,10 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.AutomationAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -683,23 +676,20 @@ 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.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AutomationAccountListResult", pipeline_response) @@ -709,10 +699,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -725,17 +716,12 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts" - } - @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.AutomationAccount"]: """Lists the Automation Accounts within an Azure subscription. Retrieve a list of accounts within a given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AutomationAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.AutomationAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -743,10 +729,10 @@ def list(self, **kwargs: Any) -> Iterable["_models.AutomationAccount"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.AutomationAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -757,22 +743,19 @@ def list(self, **kwargs: Any) -> Iterable["_models.AutomationAccount"]: 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.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AutomationAccountListResult", pipeline_response) @@ -782,10 +765,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -797,5 +781,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Automation/automationAccounts"} diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_automation_client_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_automation_client_operations.py index cdfd540f5d97..21ed4eda0cae 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_automation_client_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_automation_client_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,20 +19,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -39,13 +39,13 @@ _SERIALIZER.client_side_validation = False -def build_convert_graph_runbook_content_request( +def build_convert_graph_runbook_content_request( # pylint: disable=name-too-long resource_group_name: str, automation_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: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -62,7 +62,7 @@ def build_convert_graph_runbook_content_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,6 +76,7 @@ def build_convert_graph_runbook_content_request( class AutomationClientOperationsMixin(AutomationClientMixinABC): + @overload def convert_graph_runbook_content( self, @@ -97,7 +98,6 @@ def convert_graph_runbook_content( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: GraphicalRunbookContent or the result of cls(response) :rtype: ~azure.mgmt.automation.models.GraphicalRunbookContent :raises ~azure.core.exceptions.HttpResponseError: @@ -108,7 +108,7 @@ def convert_graph_runbook_content( self, resource_group_name: str, automation_account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -120,11 +120,10 @@ def convert_graph_runbook_content( :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param parameters: Input data describing the graphical runbook. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: GraphicalRunbookContent or the result of cls(response) :rtype: ~azure.mgmt.automation.models.GraphicalRunbookContent :raises ~azure.core.exceptions.HttpResponseError: @@ -135,7 +134,7 @@ def convert_graph_runbook_content( self, resource_group_name: str, automation_account_name: str, - parameters: Union[_models.GraphicalRunbookContent, IO], + parameters: Union[_models.GraphicalRunbookContent, IO[bytes]], **kwargs: Any ) -> _models.GraphicalRunbookContent: """Post operation to serialize or deserialize GraphRunbookContent. @@ -144,18 +143,14 @@ def convert_graph_runbook_content( :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str - :param parameters: Input data describing the graphical runbook. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.automation.models.GraphicalRunbookContent or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Input data describing the graphical runbook. Is either a + GraphicalRunbookContent type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.GraphicalRunbookContent or IO[bytes] :return: GraphicalRunbookContent or the result of cls(response) :rtype: ~azure.mgmt.automation.models.GraphicalRunbookContent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -166,19 +161,19 @@ def convert_graph_runbook_content( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.GraphicalRunbookContent] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "GraphicalRunbookContent") - request = build_convert_graph_runbook_content_request( + _request = build_convert_graph_runbook_content_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, @@ -186,15 +181,14 @@ def convert_graph_runbook_content( content_type=content_type, json=_json, content=_content, - template_url=self.convert_graph_runbook_content.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -204,13 +198,9 @@ def convert_graph_runbook_content( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GraphicalRunbookContent", pipeline_response) + deserialized = self._deserialize("GraphicalRunbookContent", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - convert_graph_runbook_content.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/convertGraphRunbookContent" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_certificate_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_certificate_operations.py index 163a32be6348..cb9dad9e51fe 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_certificate_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_certificate_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +20,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -46,7 +46,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +63,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -97,7 +97,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +114,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -132,7 +132,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -151,7 +151,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -169,7 +169,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -188,7 +188,7 @@ def build_list_by_automation_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -204,7 +204,7 @@ def build_list_by_automation_account_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -240,18 +240,20 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the certificate. + .. seealso:: + - http://aka.ms/azureautomationsdk/certificateoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param certificate_name: The name of certificate. Required. :type certificate_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, @@ -262,24 +264,23 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, certificate_name=certificate_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -290,11 +291,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.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -302,18 +299,20 @@ def get( ) -> _models.Certificate: """Retrieve the certificate identified by certificate name. + .. seealso:: + - http://aka.ms/azureautomationsdk/certificateoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param certificate_name: The name of certificate. Required. :type certificate_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -324,24 +323,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.Certificate] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, certificate_name=certificate_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -351,16 +349,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Certificate", pipeline_response) + deserialized = self._deserialize("Certificate", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -375,6 +369,9 @@ def create_or_update( ) -> _models.Certificate: """Create a certificate. + .. seealso:: + - http://aka.ms/azureautomationsdk/certificateoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -388,7 +385,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: Certificate or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: @@ -400,13 +396,16 @@ def create_or_update( resource_group_name: str, automation_account_name: str, certificate_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Certificate: """Create a certificate. + .. seealso:: + - http://aka.ms/azureautomationsdk/certificateoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -416,11 +415,10 @@ def create_or_update( :type certificate_name: str :param parameters: The parameters supplied to the create or update certificate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: @@ -432,11 +430,14 @@ def create_or_update( resource_group_name: str, automation_account_name: str, certificate_name: str, - parameters: Union[_models.CertificateCreateOrUpdateParameters, IO], + parameters: Union[_models.CertificateCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Certificate: """Create a certificate. + .. seealso:: + - http://aka.ms/azureautomationsdk/certificateoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -445,17 +446,14 @@ def create_or_update( Required. :type certificate_name: str :param parameters: The parameters supplied to the create or update certificate operation. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.CertificateCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 CertificateCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.CertificateCreateOrUpdateParameters or + IO[bytes] :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -466,19 +464,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Certificate] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CertificateCreateOrUpdateParameters") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, certificate_name=certificate_name, @@ -487,15 +485,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -506,20 +503,16 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("Certificate", pipeline_response) + deserialized = self._deserialize("Certificate", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("Certificate", pipeline_response) + deserialized = self._deserialize("Certificate", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}" - } - @overload def update( self, @@ -533,6 +526,9 @@ def update( ) -> _models.Certificate: """Update a certificate. + .. seealso:: + - http://aka.ms/azureautomationsdk/certificateoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -544,7 +540,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: Certificate or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: @@ -556,13 +551,16 @@ def update( resource_group_name: str, automation_account_name: str, certificate_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Certificate: """Update a certificate. + .. seealso:: + - http://aka.ms/azureautomationsdk/certificateoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -570,11 +568,10 @@ def update( :param certificate_name: The parameters supplied to the update certificate operation. Required. :type certificate_name: str :param parameters: The parameters supplied to the update certificate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: @@ -586,11 +583,14 @@ def update( resource_group_name: str, automation_account_name: str, certificate_name: str, - parameters: Union[_models.CertificateUpdateParameters, IO], + parameters: Union[_models.CertificateUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Certificate: """Update a certificate. + .. seealso:: + - http://aka.ms/azureautomationsdk/certificateoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -598,17 +598,13 @@ def update( :param certificate_name: The parameters supplied to the update certificate operation. Required. :type certificate_name: str :param parameters: The parameters supplied to the update certificate operation. Is either a - model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.CertificateUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + CertificateUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.CertificateUpdateParameters or IO[bytes] :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -619,19 +615,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Certificate] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CertificateUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, certificate_name=certificate_name, @@ -640,15 +636,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -658,16 +653,12 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Certificate", pipeline_response) + deserialized = self._deserialize("Certificate", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -675,11 +666,13 @@ def list_by_automation_account( ) -> Iterable["_models.Certificate"]: """Retrieve a list of certificates. + .. seealso:: + - http://aka.ms/azureautomationsdk/certificateoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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 Certificate or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.Certificate] :raises ~azure.core.exceptions.HttpResponseError: @@ -687,10 +680,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.CertificateListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -701,24 +694,21 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("CertificateListResult", pipeline_response) @@ -728,10 +718,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -743,7 +734,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_connection_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_connection_operations.py index 408ac1066f5d..c719315530db 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_connection_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_connection_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +20,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -46,7 +46,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +63,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -97,7 +97,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +114,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -132,7 +132,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -151,7 +151,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -169,7 +169,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -188,7 +188,7 @@ def build_list_by_automation_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -204,7 +204,7 @@ def build_list_by_automation_account_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -240,18 +240,20 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the connection. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectionoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param connection_name: The name of connection. Required. :type 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, @@ -262,24 +264,23 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, connection_name=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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -290,11 +291,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.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -302,18 +299,20 @@ def get( ) -> _models.Connection: """Retrieve the connection identified by connection name. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectionoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param connection_name: The name of connection. Required. :type connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Connection or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -324,24 +323,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.Connection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, connection_name=connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -351,16 +349,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Connection", pipeline_response) + deserialized = self._deserialize("Connection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -375,6 +369,9 @@ def create_or_update( ) -> _models.Connection: """Create or update a connection. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectionoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -388,7 +385,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: Connection or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection :raises ~azure.core.exceptions.HttpResponseError: @@ -400,13 +396,16 @@ def create_or_update( resource_group_name: str, automation_account_name: str, connection_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Connection: """Create or update a connection. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectionoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -416,11 +415,10 @@ def create_or_update( :type connection_name: str :param parameters: The parameters supplied to the create or update connection operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Connection or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection :raises ~azure.core.exceptions.HttpResponseError: @@ -432,11 +430,14 @@ def create_or_update( resource_group_name: str, automation_account_name: str, connection_name: str, - parameters: Union[_models.ConnectionCreateOrUpdateParameters, IO], + parameters: Union[_models.ConnectionCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Connection: """Create or update a connection. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectionoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -445,17 +446,13 @@ def create_or_update( Required. :type connection_name: str :param parameters: The parameters supplied to the create or update connection operation. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.ConnectionCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 ConnectionCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.ConnectionCreateOrUpdateParameters or IO[bytes] :return: Connection or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -466,19 +463,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Connection] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ConnectionCreateOrUpdateParameters") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, connection_name=connection_name, @@ -487,15 +484,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -506,20 +502,16 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("Connection", pipeline_response) + deserialized = self._deserialize("Connection", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("Connection", pipeline_response) + deserialized = self._deserialize("Connection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}" - } - @overload def update( self, @@ -533,6 +525,9 @@ def update( ) -> _models.Connection: """Update a connection. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectionoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -544,7 +539,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: Connection or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection :raises ~azure.core.exceptions.HttpResponseError: @@ -556,13 +550,16 @@ def update( resource_group_name: str, automation_account_name: str, connection_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Connection: """Update a connection. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectionoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -570,11 +567,10 @@ def update( :param connection_name: The parameters supplied to the update a connection operation. Required. :type connection_name: str :param parameters: The parameters supplied to the update a connection operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Connection or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection :raises ~azure.core.exceptions.HttpResponseError: @@ -586,11 +582,14 @@ def update( resource_group_name: str, automation_account_name: str, connection_name: str, - parameters: Union[_models.ConnectionUpdateParameters, IO], + parameters: Union[_models.ConnectionUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Connection: """Update a connection. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectionoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -598,17 +597,13 @@ def update( :param connection_name: The parameters supplied to the update a connection operation. Required. :type connection_name: str :param parameters: The parameters supplied to the update a connection operation. Is either a - model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.ConnectionUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ConnectionUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.ConnectionUpdateParameters or IO[bytes] :return: Connection or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -619,19 +614,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Connection] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ConnectionUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, connection_name=connection_name, @@ -640,15 +635,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -658,16 +652,12 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Connection", pipeline_response) + deserialized = self._deserialize("Connection", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -675,11 +665,13 @@ def list_by_automation_account( ) -> Iterable["_models.Connection"]: """Retrieve a list of connections. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectionoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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 Connection or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.Connection] :raises ~azure.core.exceptions.HttpResponseError: @@ -687,10 +679,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.ConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -701,24 +693,21 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ConnectionListResult", pipeline_response) @@ -728,10 +717,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -743,7 +733,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_connection_type_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_connection_type_operations.py index e0e5c3a1146e..9a14aca6204c 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_connection_type_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_connection_type_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +20,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -50,7 +50,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -67,7 +67,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -88,7 +88,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -105,7 +105,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -126,7 +126,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -144,7 +144,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -163,7 +163,7 @@ def build_list_by_automation_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -179,7 +179,7 @@ def build_list_by_automation_account_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -215,18 +215,20 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the connection type. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectiontypeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param connection_type_name: The name of connection type. Required. :type connection_type_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, @@ -237,24 +239,23 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, connection_type_name=connection_type_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -265,11 +266,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.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -277,18 +274,20 @@ def get( ) -> _models.ConnectionType: """Retrieve the connection type identified by connection type name. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectiontypeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param connection_type_name: The name of connection type. Required. :type connection_type_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ConnectionType or the result of cls(response) :rtype: ~azure.mgmt.automation.models.ConnectionType :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -299,24 +298,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.ConnectionType] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, connection_type_name=connection_type_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -326,16 +324,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ConnectionType", pipeline_response) + deserialized = self._deserialize("ConnectionType", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -350,6 +344,9 @@ def create_or_update( ) -> _models.ConnectionType: """Create a connection type. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectiontypeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -363,7 +360,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: ConnectionType or the result of cls(response) :rtype: ~azure.mgmt.automation.models.ConnectionType :raises ~azure.core.exceptions.HttpResponseError: @@ -375,13 +371,16 @@ def create_or_update( resource_group_name: str, automation_account_name: str, connection_type_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.ConnectionType: """Create a connection type. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectiontypeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -391,11 +390,10 @@ def create_or_update( :type connection_type_name: str :param parameters: The parameters supplied to the create or update connection type operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ConnectionType or the result of cls(response) :rtype: ~azure.mgmt.automation.models.ConnectionType :raises ~azure.core.exceptions.HttpResponseError: @@ -407,11 +405,14 @@ def create_or_update( resource_group_name: str, automation_account_name: str, connection_type_name: str, - parameters: Union[_models.ConnectionTypeCreateOrUpdateParameters, IO], + parameters: Union[_models.ConnectionTypeCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.ConnectionType: """Create a connection type. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectiontypeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -420,17 +421,14 @@ def create_or_update( operation. Required. :type connection_type_name: str :param parameters: The parameters supplied to the create or update connection type operation. - Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.ConnectionTypeCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 ConnectionTypeCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.ConnectionTypeCreateOrUpdateParameters or + IO[bytes] :return: ConnectionType or the result of cls(response) :rtype: ~azure.mgmt.automation.models.ConnectionType :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -441,19 +439,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ConnectionType] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ConnectionTypeCreateOrUpdateParameters") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, connection_type_name=connection_type_name, @@ -462,15 +460,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -480,16 +477,12 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ConnectionType", pipeline_response) + deserialized = self._deserialize("ConnectionType", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -497,11 +490,13 @@ def list_by_automation_account( ) -> Iterable["_models.ConnectionType"]: """Retrieve a list of connection types. + .. seealso:: + - http://aka.ms/azureautomationsdk/connectiontypeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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 ConnectionType or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.ConnectionType] :raises ~azure.core.exceptions.HttpResponseError: @@ -509,10 +504,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.ConnectionTypeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -523,24 +518,21 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ConnectionTypeListResult", pipeline_response) @@ -550,10 +542,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -565,7 +558,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_credential_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_credential_operations.py index 375027ade7c8..87be07fae68f 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_credential_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_credential_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +20,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -46,7 +46,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +63,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -97,7 +97,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +114,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -132,7 +132,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -151,7 +151,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -169,7 +169,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -188,7 +188,7 @@ def build_list_by_automation_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -204,7 +204,7 @@ def build_list_by_automation_account_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -240,18 +240,20 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the credential. + .. seealso:: + - http://aka.ms/azureautomationsdk/credentialoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param credential_name: The name of credential. Required. :type credential_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, @@ -262,24 +264,23 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, credential_name=credential_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -290,11 +291,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.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -302,18 +299,20 @@ def get( ) -> _models.Credential: """Retrieve the credential identified by credential name. + .. seealso:: + - http://aka.ms/azureautomationsdk/credentialoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param credential_name: The name of credential. Required. :type credential_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Credential or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -324,24 +323,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.Credential] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, credential_name=credential_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -351,16 +349,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Credential", pipeline_response) + deserialized = self._deserialize("Credential", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -375,6 +369,9 @@ def create_or_update( ) -> _models.Credential: """Create a credential. + .. seealso:: + - http://aka.ms/azureautomationsdk/credentialoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -388,7 +385,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: Credential or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential :raises ~azure.core.exceptions.HttpResponseError: @@ -400,13 +396,16 @@ def create_or_update( resource_group_name: str, automation_account_name: str, credential_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Credential: """Create a credential. + .. seealso:: + - http://aka.ms/azureautomationsdk/credentialoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -416,11 +415,10 @@ def create_or_update( :type credential_name: str :param parameters: The parameters supplied to the create or update credential operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Credential or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential :raises ~azure.core.exceptions.HttpResponseError: @@ -432,11 +430,14 @@ def create_or_update( resource_group_name: str, automation_account_name: str, credential_name: str, - parameters: Union[_models.CredentialCreateOrUpdateParameters, IO], + parameters: Union[_models.CredentialCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Credential: """Create a credential. + .. seealso:: + - http://aka.ms/azureautomationsdk/credentialoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -445,17 +446,13 @@ def create_or_update( Required. :type credential_name: str :param parameters: The parameters supplied to the create or update credential operation. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.CredentialCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 CredentialCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.CredentialCreateOrUpdateParameters or IO[bytes] :return: Credential or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -466,19 +463,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Credential] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CredentialCreateOrUpdateParameters") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, credential_name=credential_name, @@ -487,15 +484,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -506,20 +502,16 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("Credential", pipeline_response) + deserialized = self._deserialize("Credential", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("Credential", pipeline_response) + deserialized = self._deserialize("Credential", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}" - } - @overload def update( self, @@ -533,6 +525,9 @@ def update( ) -> _models.Credential: """Update a credential. + .. seealso:: + - http://aka.ms/azureautomationsdk/credentialoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -544,7 +539,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: Credential or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential :raises ~azure.core.exceptions.HttpResponseError: @@ -556,13 +550,16 @@ def update( resource_group_name: str, automation_account_name: str, credential_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Credential: """Update a credential. + .. seealso:: + - http://aka.ms/azureautomationsdk/credentialoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -570,11 +567,10 @@ def update( :param credential_name: The parameters supplied to the Update credential operation. Required. :type credential_name: str :param parameters: The parameters supplied to the Update credential operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Credential or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential :raises ~azure.core.exceptions.HttpResponseError: @@ -586,11 +582,14 @@ def update( resource_group_name: str, automation_account_name: str, credential_name: str, - parameters: Union[_models.CredentialUpdateParameters, IO], + parameters: Union[_models.CredentialUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Credential: """Update a credential. + .. seealso:: + - http://aka.ms/azureautomationsdk/credentialoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -598,17 +597,13 @@ def update( :param credential_name: The parameters supplied to the Update credential operation. Required. :type credential_name: str :param parameters: The parameters supplied to the Update credential operation. Is either a - model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.CredentialUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + CredentialUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.CredentialUpdateParameters or IO[bytes] :return: Credential or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -619,19 +614,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Credential] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CredentialUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, credential_name=credential_name, @@ -640,15 +635,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -658,16 +652,12 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Credential", pipeline_response) + deserialized = self._deserialize("Credential", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -675,11 +665,13 @@ def list_by_automation_account( ) -> Iterable["_models.Credential"]: """Retrieve a list of credentials. + .. seealso:: + - http://aka.ms/azureautomationsdk/credentialoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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 Credential or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.Credential] :raises ~azure.core.exceptions.HttpResponseError: @@ -687,10 +679,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.CredentialListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -701,24 +693,21 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("CredentialListResult", pipeline_response) @@ -728,10 +717,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -742,7 +732,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_deleted_automation_accounts_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_deleted_automation_accounts_operations.py index d6ac5231db4d..2546b87a3051 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_deleted_automation_accounts_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_deleted_automation_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,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, TypeVar +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,20 +18,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -43,7 +42,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -54,7 +53,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -88,12 +87,11 @@ def __init__(self, *args, **kwargs): def list_by_subscription(self, **kwargs: Any) -> _models.DeletedAutomationAccountListResult: """Retrieve deleted automation account. - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedAutomationAccountListResult or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DeletedAutomationAccountListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -104,21 +102,20 @@ def list_by_subscription(self, **kwargs: Any) -> _models.DeletedAutomationAccoun _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-01-31"] = kwargs.pop("api_version", _params.pop("api-version", "2022-01-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-31")) cls: ClsType[_models.DeletedAutomationAccountListResult] = kwargs.pop("cls", None) - request = build_list_by_subscription_request( + _request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -128,13 +125,9 @@ def list_by_subscription(self, **kwargs: Any) -> _models.DeletedAutomationAccoun error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DeletedAutomationAccountListResult", pipeline_response) + deserialized = self._deserialize("DeletedAutomationAccountListResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Automation/deletedAutomationAccounts" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_compilation_job_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_compilation_job_operations.py index b8d498a822ea..df0d3d4fe343 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_compilation_job_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_compilation_job_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,9 +20,8 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -29,12 +29,12 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -52,9 +52,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -72,7 +70,7 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -95,9 +93,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -114,7 +110,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -136,9 +132,7 @@ def build_list_by_automation_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -154,7 +148,7 @@ def build_list_by_automation_account_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -178,9 +172,7 @@ def build_get_stream_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -198,7 +190,7 @@ def build_get_stream_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -233,10 +225,10 @@ def _create_initial( resource_group_name: str, automation_account_name: str, compilation_job_name: str, - parameters: Union[_models.DscCompilationJobCreateParameters, IO], + parameters: Union[_models.DscCompilationJobCreateParameters, IO[bytes]], **kwargs: Any - ) -> _models.DscCompilationJob: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -247,21 +239,19 @@ def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DscCompilationJob] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DscCompilationJobCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, compilation_job_name=compilation_job_name, @@ -270,34 +260,30 @@ 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.url = self._client.format_url(_request.url) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: + response.read() # Load the body in memory and close the socket 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("DscCompilationJob", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) 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.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -312,6 +298,9 @@ def begin_create( ) -> LROPoller[_models.DscCompilationJob]: """Creates the Dsc compilation job of the configuration. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscconfigurationcompilejoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -323,14 +312,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 DscCompilationJob or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.automation.models.DscCompilationJob] @@ -343,13 +324,16 @@ def begin_create( resource_group_name: str, automation_account_name: str, compilation_job_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.DscCompilationJob]: """Creates the Dsc compilation job of the configuration. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscconfigurationcompilejoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -357,18 +341,10 @@ def begin_create( :param compilation_job_name: The DSC configuration Id. Required. :type compilation_job_name: str :param parameters: The parameters supplied to the create compilation job operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. 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 DscCompilationJob or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.automation.models.DscCompilationJob] @@ -381,11 +357,14 @@ def begin_create( resource_group_name: str, automation_account_name: str, compilation_job_name: str, - parameters: Union[_models.DscCompilationJobCreateParameters, IO], + parameters: Union[_models.DscCompilationJobCreateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.DscCompilationJob]: """Creates the Dsc compilation job of the configuration. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscconfigurationcompilejoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -393,19 +372,8 @@ def begin_create( :param compilation_job_name: The DSC configuration Id. Required. :type compilation_job_name: str :param parameters: The parameters supplied to the create compilation job operation. Is either a - model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.DscCompilationJobCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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. + DscCompilationJobCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.DscCompilationJobCreateParameters or IO[bytes] :return: An instance of LROPoller that returns either DscCompilationJob or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.automation.models.DscCompilationJob] @@ -414,9 +382,7 @@ def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DscCompilationJob] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -435,12 +401,13 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DscCompilationJob", pipeline_response) + deserialized = self._deserialize("DscCompilationJob", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -450,17 +417,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.DscCompilationJob].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.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}" - } + return LROPoller[_models.DscCompilationJob]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def get( @@ -468,18 +433,20 @@ def get( ) -> _models.DscCompilationJob: """Retrieve the Dsc configuration compilation job identified by job id. + .. seealso:: + - http://aka.ms/azureautomationsdk/dsccompilationjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param compilation_job_name: The DSC configuration Id. Required. :type compilation_job_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DscCompilationJob or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscCompilationJob :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -490,26 +457,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.DscCompilationJob] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, compilation_job_name=compilation_job_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -519,16 +483,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DscCompilationJob", pipeline_response) + deserialized = self._deserialize("DscCompilationJob", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -536,13 +496,15 @@ def list_by_automation_account( ) -> Iterable["_models.DscCompilationJob"]: """Retrieve a list of dsc compilation jobs. + .. seealso:: + - http://aka.ms/azureautomationsdk/compilationjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param filter: The filter to apply on the operation. 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 DscCompilationJob or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.DscCompilationJob] :raises ~azure.core.exceptions.HttpResponseError: @@ -550,12 +512,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.DscCompilationJobListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,25 +526,22 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DscCompilationJobListResult", pipeline_response) @@ -594,10 +551,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -610,16 +568,15 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs" - } - @distributed_trace def get_stream( self, resource_group_name: str, automation_account_name: str, job_id: str, job_stream_id: str, **kwargs: Any ) -> _models.JobStream: """Retrieve the job stream identified by job stream id. + .. seealso:: + - http://aka.ms/azureautomationsdk/jobstreamoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -628,12 +585,11 @@ def get_stream( :type job_id: str :param job_stream_id: The job stream id. Required. :type job_stream_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: JobStream or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobStream :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -644,27 +600,24 @@ def get_stream( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.JobStream] = kwargs.pop("cls", None) - request = build_get_stream_request( + _request = build_get_stream_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_id=job_id, job_stream_id=job_stream_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_stream.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -674,13 +627,9 @@ def get_stream( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("JobStream", pipeline_response) + deserialized = self._deserialize("JobStream", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_stream.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams/{jobStreamId}" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_compilation_job_stream_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_compilation_job_stream_operations.py index 7e4fd8be18a1..99ee084c7e5c 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_compilation_job_stream_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_compilation_job_stream_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, TypeVar +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,20 +18,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -45,9 +44,7 @@ def build_list_by_job_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -64,7 +61,7 @@ def build_list_by_job_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -100,18 +97,20 @@ def list_by_job( ) -> _models.JobStreamListResult: """Retrieve all the job streams for the compilation Job. + .. seealso:: + - http://aka.ms/azureautomationsdk/jobstreamoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param job_id: The job id. Required. :type job_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: JobStreamListResult or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobStreamListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -122,26 +121,23 @@ def list_by_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.JobStreamListResult] = kwargs.pop("cls", None) - request = build_list_by_job_request( + _request = build_list_by_job_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_id=job_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_job.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -151,13 +147,9 @@ def list_by_job( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("JobStreamListResult", pipeline_response) + deserialized = self._deserialize("JobStreamListResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_job.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_configuration_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_configuration_operations.py index c32539930fd6..c5f06ed5b1e6 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_configuration_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_configuration_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Iterator, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, Iterable, Iterator, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +19,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -46,7 +45,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +62,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +79,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -97,7 +96,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +113,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -132,7 +131,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -151,7 +150,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -169,7 +168,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -188,7 +187,7 @@ def build_get_content_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "text/powershell") # Construct URL @@ -205,7 +204,7 @@ def build_get_content_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -230,7 +229,7 @@ def build_list_by_automation_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -246,7 +245,7 @@ def build_list_by_automation_account_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -290,18 +289,20 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the dsc configuration identified by configuration name. + .. seealso:: + - http://aka.ms/azureautomationsdk/configurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param configuration_name: The configuration name. Required. :type configuration_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, @@ -312,24 +313,23 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, configuration_name=configuration_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -340,11 +340,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.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -352,18 +348,20 @@ def get( ) -> _models.DscConfiguration: """Retrieve the configuration identified by configuration name. + .. seealso:: + - http://aka.ms/azureautomationsdk/configurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param configuration_name: The configuration name. Required. :type configuration_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DscConfiguration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -374,24 +372,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.DscConfiguration] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, configuration_name=configuration_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -401,16 +398,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DscConfiguration", pipeline_response) + deserialized = self._deserialize("DscConfiguration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -425,6 +418,9 @@ def create_or_update( ) -> _models.DscConfiguration: """Create the configuration identified by configuration name. + .. seealso:: + - http://aka.ms/azureautomationsdk/configurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -436,7 +432,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: DscConfiguration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration :raises ~azure.core.exceptions.HttpResponseError: @@ -455,6 +450,9 @@ def create_or_update( ) -> _models.DscConfiguration: """Create the configuration identified by configuration name. + .. seealso:: + - http://aka.ms/azureautomationsdk/configurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -466,7 +464,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for string body. Default value is None. :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DscConfiguration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration :raises ~azure.core.exceptions.HttpResponseError: @@ -483,24 +480,23 @@ def create_or_update( ) -> _models.DscConfiguration: """Create the configuration identified by configuration name. + .. seealso:: + - http://aka.ms/azureautomationsdk/configurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param configuration_name: The create or update parameters for configuration. Required. :type configuration_name: str - :param parameters: The create or update parameters for configuration. Is either a model type or - a string type. Required. + :param parameters: The create or update parameters for configuration. Is either a + DscConfigurationCreateOrUpdateParameters type or a str type. Required. :type parameters: ~azure.mgmt.automation.models.DscConfigurationCreateOrUpdateParameters or str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/plain; charset=utf-8'. Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DscConfiguration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -511,7 +507,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DscConfiguration] = kwargs.pop("cls", None) @@ -523,7 +519,7 @@ def create_or_update( elif isinstance(parameters, str): _content = self._serialize.body(parameters, "str") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, configuration_name=configuration_name, @@ -532,15 +528,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -551,20 +546,16 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("DscConfiguration", pipeline_response) + deserialized = self._deserialize("DscConfiguration", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("DscConfiguration", pipeline_response) + deserialized = self._deserialize("DscConfiguration", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}" - } - @overload def update( self, @@ -578,6 +569,9 @@ def update( ) -> _models.DscConfiguration: """Create the configuration identified by configuration name. + .. seealso:: + - http://aka.ms/azureautomationsdk/configurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -589,7 +583,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: DscConfiguration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration :raises ~azure.core.exceptions.HttpResponseError: @@ -608,6 +601,9 @@ def update( ) -> _models.DscConfiguration: """Create the configuration identified by configuration name. + .. seealso:: + - http://aka.ms/azureautomationsdk/configurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -619,7 +615,6 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for string body. Default value is None. :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DscConfiguration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration :raises ~azure.core.exceptions.HttpResponseError: @@ -636,24 +631,23 @@ def update( ) -> _models.DscConfiguration: """Create the configuration identified by configuration name. + .. seealso:: + - http://aka.ms/azureautomationsdk/configurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param configuration_name: The create or update parameters for configuration. Required. :type configuration_name: str - :param parameters: The create or update parameters for configuration. Is either a model type or - a string type. Default value is None. + :param parameters: The create or update parameters for configuration. Is either a + DscConfigurationUpdateParameters type or a str type. Default value is None. :type parameters: ~azure.mgmt.automation.models.DscConfigurationUpdateParameters or str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/plain; charset=utf-8'. Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DscConfiguration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -664,7 +658,7 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DscConfiguration] = kwargs.pop("cls", None) @@ -682,7 +676,7 @@ def update( else: _content = None - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, configuration_name=configuration_name, @@ -691,15 +685,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -709,16 +702,12 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DscConfiguration", pipeline_response) + deserialized = self._deserialize("DscConfiguration", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}" - } + return deserialized # type: ignore @distributed_trace def get_content( @@ -726,18 +715,20 @@ def get_content( ) -> Iterator[bytes]: """Retrieve the configuration script identified by configuration name. + .. seealso:: + - http://aka.ms/azureautomationsdk/configurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param configuration_name: The configuration name. Required. :type configuration_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Iterator of the response bytes or the result of cls(response) + :return: Iterator[bytes] or the result of cls(response) :rtype: Iterator[bytes] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -748,29 +739,29 @@ def get_content( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_get_content_request( + _request = build_get_content_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, configuration_name=configuration_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_content.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=True, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: + response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -781,10 +772,6 @@ def get_content( return deserialized # type: ignore - get_content.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}/content" - } - @distributed_trace def list_by_automation_account( self, @@ -798,6 +785,9 @@ def list_by_automation_account( ) -> Iterable["_models.DscConfiguration"]: """Retrieve a list of configurations. + .. seealso:: + - http://aka.ms/azureautomationsdk/configurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -810,7 +800,6 @@ def list_by_automation_account( :type top: int :param inlinecount: Return total rows. Default value is None. :type inlinecount: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DscConfiguration or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.DscConfiguration] :raises ~azure.core.exceptions.HttpResponseError: @@ -818,10 +807,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.DscConfigurationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -832,7 +821,7 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, @@ -841,19 +830,16 @@ def prepare_request(next_link=None): top=top, inlinecount=inlinecount, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DscConfigurationListResult", pipeline_response) @@ -863,10 +849,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -878,7 +865,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_node_configuration_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_node_configuration_operations.py index 9d05b99c479b..737f505845de 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_node_configuration_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_node_configuration_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,9 +20,8 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -29,12 +29,12 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -52,7 +52,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -69,7 +69,7 @@ def build_delete_request( "nodeConfigurationName": _SERIALIZER.url("node_configuration_name", node_configuration_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -90,7 +90,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -107,7 +107,7 @@ def build_get_request( "nodeConfigurationName": _SERIALIZER.url("node_configuration_name", node_configuration_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -128,7 +128,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -146,7 +146,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -173,7 +173,7 @@ def build_list_by_automation_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -189,7 +189,7 @@ def build_list_by_automation_account_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -233,18 +233,20 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the Dsc node configurations by node configuration. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodeconfigurations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param node_configuration_name: The Dsc node configuration name. Required. :type node_configuration_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, @@ -255,24 +257,23 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, node_configuration_name=node_configuration_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -283,11 +284,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.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -295,18 +292,20 @@ def get( ) -> _models.DscNodeConfiguration: """Retrieve the Dsc node configurations by node configuration. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodeconfigurations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param node_configuration_name: The Dsc node configuration name. Required. :type node_configuration_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DscNodeConfiguration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNodeConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -317,24 +316,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.DscNodeConfiguration] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, node_configuration_name=node_configuration_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -344,26 +342,22 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DscNodeConfiguration", pipeline_response) + deserialized = self._deserialize("DscNodeConfiguration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, automation_account_name: str, node_configuration_name: str, - parameters: Union[_models.DscNodeConfigurationCreateOrUpdateParameters, IO], + parameters: Union[_models.DscNodeConfigurationCreateOrUpdateParameters, IO[bytes]], **kwargs: Any - ) -> Optional[_models.DscNodeConfiguration]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -374,19 +368,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.DscNodeConfiguration]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DscNodeConfigurationCreateOrUpdateParameters") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, node_configuration_name=node_configuration_name, @@ -395,36 +389,34 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None + if response.status_code == 200: + deserialized = response.stream_download(self._client._pipeline) + if response.status_code == 201: - deserialized = self._deserialize("DscNodeConfiguration", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}" - } + return deserialized # type: ignore @overload def begin_create_or_update( @@ -436,9 +428,12 @@ def begin_create_or_update( *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: + ) -> LROPoller[_models.DscNodeConfiguration]: """Create the node configuration identified by node configuration name. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodeconfigurations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -450,14 +445,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either DscNodeConfiguration or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.automation.models.DscNodeConfiguration] @@ -470,13 +457,16 @@ def begin_create_or_update( resource_group_name: str, automation_account_name: str, node_configuration_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: + ) -> LROPoller[_models.DscNodeConfiguration]: """Create the node configuration identified by node configuration name. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodeconfigurations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -484,18 +474,10 @@ def begin_create_or_update( :param node_configuration_name: The Dsc node configuration name. Required. :type node_configuration_name: str :param parameters: The create or update parameters for configuration. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. 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 DscNodeConfiguration or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.automation.models.DscNodeConfiguration] @@ -508,32 +490,24 @@ def begin_create_or_update( resource_group_name: str, automation_account_name: str, node_configuration_name: str, - parameters: Union[_models.DscNodeConfigurationCreateOrUpdateParameters, IO], + parameters: Union[_models.DscNodeConfigurationCreateOrUpdateParameters, IO[bytes]], **kwargs: Any - ) -> LROPoller[None]: + ) -> LROPoller[_models.DscNodeConfiguration]: """Create the node configuration identified by node configuration name. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodeconfigurations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param node_configuration_name: The Dsc node configuration name. Required. :type node_configuration_name: str - :param parameters: The create or update parameters for configuration. Is either a model type or - a IO type. Required. + :param parameters: The create or update parameters for configuration. Is either a + DscNodeConfigurationCreateOrUpdateParameters type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.automation.models.DscNodeConfigurationCreateOrUpdateParameters or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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. + IO[bytes] :return: An instance of LROPoller that returns either DscNodeConfiguration or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.automation.models.DscNodeConfiguration] @@ -542,7 +516,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -561,12 +535,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DscNodeConfiguration", pipeline_response) + deserialized = self._deserialize("DscNodeConfiguration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -576,17 +551,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.DscNodeConfiguration].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}" - } + return LROPoller[_models.DscNodeConfiguration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list_by_automation_account( @@ -601,6 +574,9 @@ def list_by_automation_account( ) -> Iterable["_models.DscNodeConfiguration"]: """Retrieve a list of dsc node configurations. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodeconfigurations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -613,7 +589,6 @@ def list_by_automation_account( :type top: int :param inlinecount: Return total rows. Default value is None. :type inlinecount: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DscNodeConfiguration or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.DscNodeConfiguration] @@ -622,10 +597,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.DscNodeConfigurationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -636,7 +611,7 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, @@ -645,19 +620,16 @@ def prepare_request(next_link=None): top=top, inlinecount=inlinecount, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DscNodeConfigurationListResult", pipeline_response) @@ -667,10 +639,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -682,7 +655,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_node_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_node_operations.py index b3a9240a65ac..a6235f98883c 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_node_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_node_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +20,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -46,9 +46,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -65,7 +63,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -82,9 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -101,7 +97,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -118,9 +114,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -138,7 +132,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -165,9 +159,7 @@ def build_list_by_automation_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -183,7 +175,7 @@ def build_list_by_automation_account_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -227,18 +219,20 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the dsc node identified by node id. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param node_id: The node id. Required. :type node_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, @@ -249,26 +243,23 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, node_id=node_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -279,11 +270,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.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -291,18 +278,20 @@ def get( ) -> _models.DscNode: """Retrieve the dsc node identified by node id. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param node_id: The node id. Required. :type node_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DscNode or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNode :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -313,26 +302,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.DscNode] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, node_id=node_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -342,16 +328,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DscNode", pipeline_response) + deserialized = self._deserialize("DscNode", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}" - } + return deserialized # type: ignore @overload def update( @@ -366,6 +348,9 @@ def update( ) -> _models.DscNode: """Update the dsc node. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -377,7 +362,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: DscNode or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNode :raises ~azure.core.exceptions.HttpResponseError: @@ -389,13 +373,16 @@ def update( resource_group_name: str, automation_account_name: str, node_id: str, - dsc_node_update_parameters: IO, + dsc_node_update_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.DscNode: """Update the dsc node. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -403,11 +390,10 @@ def update( :param node_id: Parameters supplied to the update dsc node. Required. :type node_id: str :param dsc_node_update_parameters: Parameters supplied to the update dsc node. Required. - :type dsc_node_update_parameters: IO + :type dsc_node_update_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DscNode or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNode :raises ~azure.core.exceptions.HttpResponseError: @@ -419,11 +405,14 @@ def update( resource_group_name: str, automation_account_name: str, node_id: str, - dsc_node_update_parameters: Union[_models.DscNodeUpdateParameters, IO], + dsc_node_update_parameters: Union[_models.DscNodeUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.DscNode: """Update the dsc node. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -431,17 +420,14 @@ def update( :param node_id: Parameters supplied to the update dsc node. Required. :type node_id: str :param dsc_node_update_parameters: Parameters supplied to the update dsc node. Is either a - model type or a IO type. Required. - :type dsc_node_update_parameters: ~azure.mgmt.automation.models.DscNodeUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + DscNodeUpdateParameters type or a IO[bytes] type. Required. + :type dsc_node_update_parameters: ~azure.mgmt.automation.models.DscNodeUpdateParameters or + IO[bytes] :return: DscNode or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNode :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -452,21 +438,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DscNode] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(dsc_node_update_parameters, (IO, bytes)): + if isinstance(dsc_node_update_parameters, (IOBase, bytes)): _content = dsc_node_update_parameters else: _json = self._serialize.body(dsc_node_update_parameters, "DscNodeUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, node_id=node_id, @@ -475,15 +459,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -493,16 +476,12 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DscNode", pipeline_response) + deserialized = self._deserialize("DscNode", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -517,6 +496,9 @@ def list_by_automation_account( ) -> Iterable["_models.DscNode"]: """Retrieve a list of dsc nodes. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -529,7 +511,6 @@ def list_by_automation_account( :type top: int :param inlinecount: Return total rows. Default value is None. :type inlinecount: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DscNode or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.DscNode] :raises ~azure.core.exceptions.HttpResponseError: @@ -537,12 +518,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.DscNodeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -553,7 +532,7 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, @@ -562,19 +541,16 @@ def prepare_request(next_link=None): top=top, inlinecount=inlinecount, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DscNodeListResult", pipeline_response) @@ -584,10 +560,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -599,7 +576,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_fields_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_fields_operations.py index 97511e77ab4f..efb203bc0b0c 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_fields_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_fields_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +19,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -51,7 +50,7 @@ def build_list_by_type_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -69,7 +68,7 @@ def build_list_by_type_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -105,6 +104,9 @@ def list_by_type( ) -> Iterable["_models.TypeField"]: """Retrieve a list of fields of a given type identified by module name. + .. seealso:: + - http://aka.ms/azureautomationsdk/typefieldoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -113,7 +115,6 @@ def list_by_type( :type module_name: str :param type_name: The name of type. Required. :type type_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TypeField or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.TypeField] :raises ~azure.core.exceptions.HttpResponseError: @@ -121,10 +122,10 @@ def list_by_type( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.TypeFieldListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -135,26 +136,23 @@ def list_by_type( def prepare_request(next_link=None): if not next_link: - request = build_list_by_type_request( + _request = build_list_by_type_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, module_name=module_name, type_name=type_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_type.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("TypeFieldListResult", pipeline_response) @@ -164,10 +162,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -179,7 +178,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_type.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/types/{typeName}/fields" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_hybrid_runbook_worker_group_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_hybrid_runbook_worker_group_operations.py index 50ecad63e97e..ffb306533d26 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_hybrid_runbook_worker_group_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_hybrid_runbook_worker_group_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +20,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -50,7 +50,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -69,7 +69,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -90,7 +90,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -109,7 +109,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -130,7 +130,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -150,7 +150,7 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -173,7 +173,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -193,7 +193,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -217,7 +217,7 @@ def build_list_by_automation_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -233,7 +233,7 @@ def build_list_by_automation_account_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -275,18 +275,20 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete a hybrid runbook worker group. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkergroupoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. Required. :type hybrid_runbook_worker_group_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, @@ -297,24 +299,23 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -325,11 +326,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.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -341,18 +338,20 @@ def get( ) -> _models.HybridRunbookWorkerGroup: """Retrieve a hybrid runbook worker group. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkergroupoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. Required. :type hybrid_runbook_worker_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridRunbookWorkerGroup or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -363,24 +362,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.HybridRunbookWorkerGroup] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -390,16 +388,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("HybridRunbookWorkerGroup", pipeline_response) + deserialized = self._deserialize("HybridRunbookWorkerGroup", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}" - } + return deserialized # type: ignore @overload def create( @@ -414,6 +408,9 @@ def create( ) -> _models.HybridRunbookWorkerGroup: """Create a hybrid runbook worker group. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkergroupoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -427,7 +424,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: HybridRunbookWorkerGroup or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup :raises ~azure.core.exceptions.HttpResponseError: @@ -439,13 +435,16 @@ def create( resource_group_name: str, automation_account_name: str, hybrid_runbook_worker_group_name: str, - hybrid_runbook_worker_group_creation_parameters: IO, + hybrid_runbook_worker_group_creation_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.HybridRunbookWorkerGroup: """Create a hybrid runbook worker group. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkergroupoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -454,11 +453,10 @@ def create( :type hybrid_runbook_worker_group_name: str :param hybrid_runbook_worker_group_creation_parameters: The create or update parameters for hybrid runbook worker group. Required. - :type hybrid_runbook_worker_group_creation_parameters: IO + :type hybrid_runbook_worker_group_creation_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridRunbookWorkerGroup or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup :raises ~azure.core.exceptions.HttpResponseError: @@ -471,12 +469,15 @@ def create( automation_account_name: str, hybrid_runbook_worker_group_name: str, hybrid_runbook_worker_group_creation_parameters: Union[ - _models.HybridRunbookWorkerGroupCreateOrUpdateParameters, IO + _models.HybridRunbookWorkerGroupCreateOrUpdateParameters, IO[bytes] ], **kwargs: Any ) -> _models.HybridRunbookWorkerGroup: """Create a hybrid runbook worker group. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkergroupoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -484,18 +485,15 @@ def create( :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. Required. :type hybrid_runbook_worker_group_name: str :param hybrid_runbook_worker_group_creation_parameters: The create or update parameters for - hybrid runbook worker group. Is either a model type or a IO type. Required. + hybrid runbook worker group. Is either a HybridRunbookWorkerGroupCreateOrUpdateParameters type + or a IO[bytes] type. Required. :type hybrid_runbook_worker_group_creation_parameters: - ~azure.mgmt.automation.models.HybridRunbookWorkerGroupCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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.automation.models.HybridRunbookWorkerGroupCreateOrUpdateParameters or IO[bytes] :return: HybridRunbookWorkerGroup or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -506,21 +504,21 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.HybridRunbookWorkerGroup] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(hybrid_runbook_worker_group_creation_parameters, (IO, bytes)): + if isinstance(hybrid_runbook_worker_group_creation_parameters, (IOBase, bytes)): _content = hybrid_runbook_worker_group_creation_parameters else: _json = self._serialize.body( hybrid_runbook_worker_group_creation_parameters, "HybridRunbookWorkerGroupCreateOrUpdateParameters" ) - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, @@ -529,15 +527,14 @@ def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -548,20 +545,16 @@ def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("HybridRunbookWorkerGroup", pipeline_response) + deserialized = self._deserialize("HybridRunbookWorkerGroup", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("HybridRunbookWorkerGroup", pipeline_response) + deserialized = self._deserialize("HybridRunbookWorkerGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}" - } - @overload def update( self, @@ -575,6 +568,9 @@ def update( ) -> _models.HybridRunbookWorkerGroup: """Update a hybrid runbook worker group. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkergroupoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -588,7 +584,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: HybridRunbookWorkerGroup or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup :raises ~azure.core.exceptions.HttpResponseError: @@ -600,13 +595,16 @@ def update( resource_group_name: str, automation_account_name: str, hybrid_runbook_worker_group_name: str, - hybrid_runbook_worker_group_updation_parameters: IO, + hybrid_runbook_worker_group_updation_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.HybridRunbookWorkerGroup: """Update a hybrid runbook worker group. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkergroupoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -615,11 +613,10 @@ def update( :type hybrid_runbook_worker_group_name: str :param hybrid_runbook_worker_group_updation_parameters: The hybrid runbook worker group. Required. - :type hybrid_runbook_worker_group_updation_parameters: IO + :type hybrid_runbook_worker_group_updation_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridRunbookWorkerGroup or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup :raises ~azure.core.exceptions.HttpResponseError: @@ -632,12 +629,15 @@ def update( automation_account_name: str, hybrid_runbook_worker_group_name: str, hybrid_runbook_worker_group_updation_parameters: Union[ - _models.HybridRunbookWorkerGroupCreateOrUpdateParameters, IO + _models.HybridRunbookWorkerGroupCreateOrUpdateParameters, IO[bytes] ], **kwargs: Any ) -> _models.HybridRunbookWorkerGroup: """Update a hybrid runbook worker group. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkergroupoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -645,18 +645,14 @@ def update( :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. Required. :type hybrid_runbook_worker_group_name: str :param hybrid_runbook_worker_group_updation_parameters: The hybrid runbook worker group. Is - either a model type or a IO type. Required. + either a HybridRunbookWorkerGroupCreateOrUpdateParameters type or a IO[bytes] type. Required. :type hybrid_runbook_worker_group_updation_parameters: - ~azure.mgmt.automation.models.HybridRunbookWorkerGroupCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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.automation.models.HybridRunbookWorkerGroupCreateOrUpdateParameters or IO[bytes] :return: HybridRunbookWorkerGroup or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -667,21 +663,21 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.HybridRunbookWorkerGroup] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(hybrid_runbook_worker_group_updation_parameters, (IO, bytes)): + if isinstance(hybrid_runbook_worker_group_updation_parameters, (IOBase, bytes)): _content = hybrid_runbook_worker_group_updation_parameters else: _json = self._serialize.body( hybrid_runbook_worker_group_updation_parameters, "HybridRunbookWorkerGroupCreateOrUpdateParameters" ) - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, @@ -690,15 +686,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -708,16 +703,12 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("HybridRunbookWorkerGroup", pipeline_response) + deserialized = self._deserialize("HybridRunbookWorkerGroup", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -725,13 +716,15 @@ def list_by_automation_account( ) -> Iterable["_models.HybridRunbookWorkerGroup"]: """Retrieve a list of hybrid runbook worker groups. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkergroupoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param filter: The filter to apply on the operation. 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 HybridRunbookWorkerGroup or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.HybridRunbookWorkerGroup] @@ -740,10 +733,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.HybridRunbookWorkerGroupsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -754,25 +747,22 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("HybridRunbookWorkerGroupsListResult", pipeline_response) @@ -782,10 +772,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -797,7 +788,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_hybrid_runbook_workers_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_hybrid_runbook_workers_operations.py index a5f04677e394..c5cf682c9e6c 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_hybrid_runbook_workers_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_hybrid_runbook_workers_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +20,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -51,7 +51,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +71,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,7 +93,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -113,7 +113,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -135,7 +135,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -156,7 +156,7 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -180,7 +180,7 @@ def build_move_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -201,7 +201,7 @@ def build_move_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -214,7 +214,7 @@ def build_move_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_hybrid_runbook_worker_group_request( +def build_list_by_hybrid_runbook_worker_group_request( # pylint: disable=name-too-long resource_group_name: str, automation_account_name: str, hybrid_runbook_worker_group_name: str, @@ -226,7 +226,7 @@ def build_list_by_hybrid_runbook_worker_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -245,7 +245,7 @@ def build_list_by_hybrid_runbook_worker_group_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -288,6 +288,9 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete a hybrid runbook worker. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkeroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -296,12 +299,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type hybrid_runbook_worker_group_name: str :param hybrid_runbook_worker_id: The hybrid runbook worker id. Required. :type hybrid_runbook_worker_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, @@ -312,25 +314,24 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, hybrid_runbook_worker_id=hybrid_runbook_worker_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -341,11 +342,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.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -358,6 +355,9 @@ def get( ) -> _models.HybridRunbookWorker: """Retrieve a hybrid runbook worker. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkeroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -366,12 +366,11 @@ def get( :type hybrid_runbook_worker_group_name: str :param hybrid_runbook_worker_id: The hybrid runbook worker id. Required. :type hybrid_runbook_worker_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridRunbookWorker or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorker :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -382,25 +381,24 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.HybridRunbookWorker] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, hybrid_runbook_worker_id=hybrid_runbook_worker_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -410,16 +408,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("HybridRunbookWorker", pipeline_response) + deserialized = self._deserialize("HybridRunbookWorker", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}" - } + return deserialized # type: ignore @overload def create( @@ -435,6 +429,9 @@ def create( ) -> _models.HybridRunbookWorker: """Create a hybrid runbook worker. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkeroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -450,7 +447,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: HybridRunbookWorker or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorker :raises ~azure.core.exceptions.HttpResponseError: @@ -463,13 +459,16 @@ def create( automation_account_name: str, hybrid_runbook_worker_group_name: str, hybrid_runbook_worker_id: str, - hybrid_runbook_worker_creation_parameters: IO, + hybrid_runbook_worker_creation_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.HybridRunbookWorker: """Create a hybrid runbook worker. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkeroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -480,11 +479,10 @@ def create( :type hybrid_runbook_worker_id: str :param hybrid_runbook_worker_creation_parameters: The create or update parameters for hybrid runbook worker. Required. - :type hybrid_runbook_worker_creation_parameters: IO + :type hybrid_runbook_worker_creation_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridRunbookWorker or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorker :raises ~azure.core.exceptions.HttpResponseError: @@ -497,11 +495,14 @@ def create( automation_account_name: str, hybrid_runbook_worker_group_name: str, hybrid_runbook_worker_id: str, - hybrid_runbook_worker_creation_parameters: Union[_models.HybridRunbookWorkerCreateParameters, IO], + hybrid_runbook_worker_creation_parameters: Union[_models.HybridRunbookWorkerCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.HybridRunbookWorker: """Create a hybrid runbook worker. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkeroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -511,18 +512,15 @@ def create( :param hybrid_runbook_worker_id: The hybrid runbook worker id. Required. :type hybrid_runbook_worker_id: str :param hybrid_runbook_worker_creation_parameters: The create or update parameters for hybrid - runbook worker. Is either a model type or a IO type. Required. + runbook worker. Is either a HybridRunbookWorkerCreateParameters type or a IO[bytes] type. + Required. :type hybrid_runbook_worker_creation_parameters: - ~azure.mgmt.automation.models.HybridRunbookWorkerCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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.automation.models.HybridRunbookWorkerCreateParameters or IO[bytes] :return: HybridRunbookWorker or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorker :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -533,21 +531,21 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.HybridRunbookWorker] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(hybrid_runbook_worker_creation_parameters, (IO, bytes)): + if isinstance(hybrid_runbook_worker_creation_parameters, (IOBase, bytes)): _content = hybrid_runbook_worker_creation_parameters else: _json = self._serialize.body( hybrid_runbook_worker_creation_parameters, "HybridRunbookWorkerCreateParameters" ) - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, @@ -557,15 +555,14 @@ def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -576,20 +573,16 @@ def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("HybridRunbookWorker", pipeline_response) + deserialized = self._deserialize("HybridRunbookWorker", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("HybridRunbookWorker", pipeline_response) + deserialized = self._deserialize("HybridRunbookWorker", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}" - } - @overload def move( # pylint: disable=inconsistent-return-statements self, @@ -604,6 +597,9 @@ def move( # pylint: disable=inconsistent-return-statements ) -> None: """Move a hybrid worker to a different group. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkeroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -619,7 +615,6 @@ def move( # 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: @@ -632,13 +627,16 @@ def move( # pylint: disable=inconsistent-return-statements automation_account_name: str, hybrid_runbook_worker_group_name: str, hybrid_runbook_worker_id: str, - hybrid_runbook_worker_move_parameters: IO, + hybrid_runbook_worker_move_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> None: """Move a hybrid worker to a different group. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkeroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -649,11 +647,10 @@ def move( # pylint: disable=inconsistent-return-statements :type hybrid_runbook_worker_id: str :param hybrid_runbook_worker_move_parameters: The hybrid runbook worker move parameters. Required. - :type hybrid_runbook_worker_move_parameters: IO + :type hybrid_runbook_worker_move_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default 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: @@ -666,11 +663,14 @@ def move( # pylint: disable=inconsistent-return-statements automation_account_name: str, hybrid_runbook_worker_group_name: str, hybrid_runbook_worker_id: str, - hybrid_runbook_worker_move_parameters: Union[_models.HybridRunbookWorkerMoveParameters, IO], + hybrid_runbook_worker_move_parameters: Union[_models.HybridRunbookWorkerMoveParameters, IO[bytes]], **kwargs: Any ) -> None: """Move a hybrid worker to a different group. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkeroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -680,18 +680,14 @@ def move( # pylint: disable=inconsistent-return-statements :param hybrid_runbook_worker_id: The hybrid runbook worker id. Required. :type hybrid_runbook_worker_id: str :param hybrid_runbook_worker_move_parameters: The hybrid runbook worker move parameters. Is - either a model type or a IO type. Required. + either a HybridRunbookWorkerMoveParameters type or a IO[bytes] type. Required. :type hybrid_runbook_worker_move_parameters: - ~azure.mgmt.automation.models.HybridRunbookWorkerMoveParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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.automation.models.HybridRunbookWorkerMoveParameters 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, @@ -702,19 +698,19 @@ def move( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(hybrid_runbook_worker_move_parameters, (IO, bytes)): + if isinstance(hybrid_runbook_worker_move_parameters, (IOBase, bytes)): _content = hybrid_runbook_worker_move_parameters else: _json = self._serialize.body(hybrid_runbook_worker_move_parameters, "HybridRunbookWorkerMoveParameters") - request = build_move_request( + _request = build_move_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, @@ -724,15 +720,14 @@ def move( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.move.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -743,11 +738,7 @@ def move( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - move.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}/move" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_by_hybrid_runbook_worker_group( @@ -760,6 +751,9 @@ def list_by_hybrid_runbook_worker_group( ) -> Iterable["_models.HybridRunbookWorker"]: """Retrieve a list of hybrid runbook workers. + .. seealso:: + - http://aka.ms/azureautomationsdk/hybridrunbookworkeroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -768,7 +762,6 @@ def list_by_hybrid_runbook_worker_group( :type hybrid_runbook_worker_group_name: str :param filter: The filter to apply on the operation. 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 HybridRunbookWorker or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.HybridRunbookWorker] :raises ~azure.core.exceptions.HttpResponseError: @@ -776,10 +769,10 @@ def list_by_hybrid_runbook_worker_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.HybridRunbookWorkersListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -790,26 +783,23 @@ def list_by_hybrid_runbook_worker_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_hybrid_runbook_worker_group_request( + _request = build_list_by_hybrid_runbook_worker_group_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_hybrid_runbook_worker_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("HybridRunbookWorkersListResult", pipeline_response) @@ -819,10 +809,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -834,7 +825,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_hybrid_runbook_worker_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_operations.py index 1f32175053c2..9e1f6a24bc27 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +20,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -52,7 +52,7 @@ def build_get_output_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "text/plain") # Construct URL @@ -69,7 +69,7 @@ def build_get_output_request( "jobName": _SERIALIZER.url("job_name", job_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -94,7 +94,7 @@ def build_get_runbook_content_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "text/powershell") # Construct URL @@ -111,7 +111,7 @@ def build_get_runbook_content_request( "jobName": _SERIALIZER.url("job_name", job_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -136,7 +136,7 @@ def build_suspend_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -153,7 +153,7 @@ def build_suspend_request( "jobName": _SERIALIZER.url("job_name", job_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -178,7 +178,7 @@ def build_stop_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -195,7 +195,7 @@ def build_stop_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -220,7 +220,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -237,7 +237,7 @@ def build_get_request( "jobName": _SERIALIZER.url("job_name", job_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -262,7 +262,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -280,7 +280,7 @@ def build_create_request( "jobName": _SERIALIZER.url("job_name", job_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -307,7 +307,7 @@ def build_list_by_automation_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -323,7 +323,7 @@ def build_list_by_automation_account_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -350,7 +350,7 @@ def build_resume_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -367,7 +367,7 @@ def build_resume_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -410,6 +410,9 @@ def get_output( ) -> str: """Retrieve the job output identified by job name. + .. seealso:: + - http://aka.ms/azureautomationsdk/joboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -418,12 +421,11 @@ def get_output( :type job_name: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: str or the result of cls(response) :rtype: str :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,25 +436,24 @@ def get_output( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[str] = kwargs.pop("cls", None) - request = build_get_output_request( + _request = build_get_output_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_name=job_name, subscription_id=self._config.subscription_id, client_request_id=client_request_id, api_version=api_version, - template_url=self.get_output.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -461,16 +462,12 @@ def get_output( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("str", pipeline_response) + deserialized = self._deserialize("str", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_output.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/output" - } + return deserialized # type: ignore @distributed_trace def get_runbook_content( @@ -483,6 +480,9 @@ def get_runbook_content( ) -> str: """Retrieve the runbook content of the job identified by job name. + .. seealso:: + - http://aka.ms/azureautomationsdk/joboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -491,12 +491,11 @@ def get_runbook_content( :type job_name: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: str or the result of cls(response) :rtype: str :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -507,25 +506,24 @@ def get_runbook_content( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[str] = kwargs.pop("cls", None) - request = build_get_runbook_content_request( + _request = build_get_runbook_content_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_name=job_name, subscription_id=self._config.subscription_id, client_request_id=client_request_id, api_version=api_version, - template_url=self.get_runbook_content.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -534,16 +532,12 @@ def get_runbook_content( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("str", pipeline_response) + deserialized = self._deserialize("str", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_runbook_content.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/runbookContent" - } + return deserialized # type: ignore @distributed_trace def suspend( # pylint: disable=inconsistent-return-statements @@ -556,6 +550,9 @@ def suspend( # pylint: disable=inconsistent-return-statements ) -> None: """Suspend the job identified by job name. + .. seealso:: + - http://aka.ms/azureautomationsdk/joboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -564,12 +561,11 @@ def suspend( # pylint: disable=inconsistent-return-statements :type job_name: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_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, @@ -580,25 +576,24 @@ def suspend( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_suspend_request( + _request = build_suspend_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_name=job_name, subscription_id=self._config.subscription_id, client_request_id=client_request_id, api_version=api_version, - template_url=self.suspend.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -609,11 +604,7 @@ def suspend( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - suspend.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/suspend" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def stop( # pylint: disable=inconsistent-return-statements @@ -626,6 +617,9 @@ def stop( # pylint: disable=inconsistent-return-statements ) -> None: """Stop the job identified by jobName. + .. seealso:: + - http://aka.ms/azureautomationsdk/joboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -634,12 +628,11 @@ def stop( # pylint: disable=inconsistent-return-statements :type job_name: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_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, @@ -650,25 +643,24 @@ def stop( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_name=job_name, subscription_id=self._config.subscription_id, client_request_id=client_request_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -679,11 +671,7 @@ def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -696,6 +684,9 @@ def get( ) -> _models.Job: """Retrieve the job identified by job name. + .. seealso:: + - http://aka.ms/azureautomationsdk/joboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -704,12 +695,11 @@ def get( :type job_name: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Job or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Job :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -720,25 +710,24 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.Job] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_name=job_name, subscription_id=self._config.subscription_id, client_request_id=client_request_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -748,16 +737,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Job", pipeline_response) + deserialized = self._deserialize("Job", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}" - } + return deserialized # type: ignore @overload def create( @@ -773,6 +758,9 @@ def create( ) -> _models.Job: """Create a job of the runbook. + .. seealso:: + - http://aka.ms/azureautomationsdk/joboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -786,7 +774,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: Job or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Job :raises ~azure.core.exceptions.HttpResponseError: @@ -798,7 +785,7 @@ def create( resource_group_name: str, automation_account_name: str, job_name: str, - parameters: IO, + parameters: IO[bytes], client_request_id: Optional[str] = None, *, content_type: str = "application/json", @@ -806,6 +793,9 @@ def create( ) -> _models.Job: """Create a job of the runbook. + .. seealso:: + - http://aka.ms/azureautomationsdk/joboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -813,13 +803,12 @@ def create( :param job_name: The job name. Required. :type job_name: str :param parameters: The parameters supplied to the create job operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: 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: Job or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Job :raises ~azure.core.exceptions.HttpResponseError: @@ -831,32 +820,31 @@ def create( resource_group_name: str, automation_account_name: str, job_name: str, - parameters: Union[_models.JobCreateParameters, IO], + parameters: Union[_models.JobCreateParameters, IO[bytes]], client_request_id: Optional[str] = None, **kwargs: Any ) -> _models.Job: """Create a job of the runbook. + .. seealso:: + - http://aka.ms/azureautomationsdk/joboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param job_name: The job name. Required. :type job_name: str - :param parameters: The parameters supplied to the create job operation. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.JobCreateParameters or IO + :param parameters: The parameters supplied to the create job operation. Is either a + JobCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.JobCreateParameters or IO[bytes] :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: 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: Job or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Job :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -867,19 +855,19 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Job] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "JobCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_name=job_name, @@ -889,15 +877,14 @@ def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -907,16 +894,12 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Job", pipeline_response) + deserialized = self._deserialize("Job", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -929,6 +912,9 @@ def list_by_automation_account( ) -> Iterable["_models.JobCollectionItem"]: """Retrieve a list of jobs. + .. seealso:: + - http://aka.ms/azureautomationsdk/joboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -937,7 +923,6 @@ def list_by_automation_account( :type filter: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either JobCollectionItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.JobCollectionItem] :raises ~azure.core.exceptions.HttpResponseError: @@ -945,10 +930,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.JobListResultV2] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -959,26 +944,23 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, filter=filter, client_request_id=client_request_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("JobListResultV2", pipeline_response) @@ -988,10 +970,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1004,10 +987,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs" - } - @distributed_trace def resume( # pylint: disable=inconsistent-return-statements self, @@ -1019,6 +998,9 @@ def resume( # pylint: disable=inconsistent-return-statements ) -> None: """Resume the job identified by jobName. + .. seealso:: + - http://aka.ms/azureautomationsdk/joboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -1027,12 +1009,11 @@ def resume( # pylint: disable=inconsistent-return-statements :type job_name: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_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, @@ -1043,25 +1024,24 @@ def resume( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_resume_request( + _request = build_resume_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_name=job_name, subscription_id=self._config.subscription_id, client_request_id=client_request_id, api_version=api_version, - template_url=self.resume.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1072,8 +1052,4 @@ def resume( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - resume.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/resume" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_schedule_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_schedule_operations.py index b5dce81f200f..c3fe06d4f1f2 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_schedule_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_schedule_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +20,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -46,7 +46,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +63,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -97,7 +97,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +114,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -132,7 +132,7 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -156,7 +156,7 @@ def build_list_by_automation_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -172,7 +172,7 @@ def build_list_by_automation_account_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -210,18 +210,20 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the job schedule identified by job schedule name. + .. seealso:: + - http://aka.ms/azureautomationsdk/jobscheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param job_schedule_id: The job schedule name. Required. :type job_schedule_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, @@ -232,24 +234,23 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_schedule_id=job_schedule_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -260,11 +261,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.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -272,18 +269,20 @@ def get( ) -> _models.JobSchedule: """Retrieve the job schedule identified by job schedule name. + .. seealso:: + - http://aka.ms/azureautomationsdk/jobscheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param job_schedule_id: The job schedule name. Required. :type job_schedule_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: JobSchedule or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobSchedule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -294,24 +293,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.JobSchedule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_schedule_id=job_schedule_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -321,16 +319,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("JobSchedule", pipeline_response) + deserialized = self._deserialize("JobSchedule", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}" - } + return deserialized # type: ignore @overload def create( @@ -345,6 +339,9 @@ def create( ) -> _models.JobSchedule: """Create a job schedule. + .. seealso:: + - http://aka.ms/azureautomationsdk/jobscheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -356,7 +353,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: JobSchedule or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobSchedule :raises ~azure.core.exceptions.HttpResponseError: @@ -368,13 +364,16 @@ def create( resource_group_name: str, automation_account_name: str, job_schedule_id: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.JobSchedule: """Create a job schedule. + .. seealso:: + - http://aka.ms/azureautomationsdk/jobscheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -382,11 +381,10 @@ def create( :param job_schedule_id: The job schedule name. Required. :type job_schedule_id: str :param parameters: The parameters supplied to the create job schedule operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: JobSchedule or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobSchedule :raises ~azure.core.exceptions.HttpResponseError: @@ -398,11 +396,14 @@ def create( resource_group_name: str, automation_account_name: str, job_schedule_id: str, - parameters: Union[_models.JobScheduleCreateParameters, IO], + parameters: Union[_models.JobScheduleCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.JobSchedule: """Create a job schedule. + .. seealso:: + - http://aka.ms/azureautomationsdk/jobscheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -410,17 +411,13 @@ def create( :param job_schedule_id: The job schedule name. Required. :type job_schedule_id: str :param parameters: The parameters supplied to the create job schedule operation. Is either a - model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.JobScheduleCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + JobScheduleCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.JobScheduleCreateParameters or IO[bytes] :return: JobSchedule or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobSchedule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -431,19 +428,19 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobSchedule] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "JobScheduleCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_schedule_id=job_schedule_id, @@ -452,15 +449,14 @@ def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -470,16 +466,12 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("JobSchedule", pipeline_response) + deserialized = self._deserialize("JobSchedule", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -487,13 +479,15 @@ def list_by_automation_account( ) -> Iterable["_models.JobSchedule"]: """Retrieve a list of job schedules. + .. seealso:: + - http://aka.ms/azureautomationsdk/jobscheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param filter: The filter to apply on the operation. 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 JobSchedule or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.JobSchedule] :raises ~azure.core.exceptions.HttpResponseError: @@ -501,10 +495,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.JobScheduleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -515,25 +509,22 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("JobScheduleListResult", pipeline_response) @@ -543,10 +534,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -558,7 +550,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_stream_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_stream_operations.py index 0052d87dde4d..b672ed872ce5 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_stream_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_stream_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +19,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -53,7 +52,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +70,7 @@ def build_get_request( "jobStreamId": _SERIALIZER.url("job_stream_id", job_stream_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -97,7 +96,7 @@ def build_list_by_job_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -114,7 +113,7 @@ def build_list_by_job_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -160,6 +159,9 @@ def get( ) -> _models.JobStream: """Retrieve the job stream identified by job stream id. + .. seealso:: + - http://aka.ms/azureautomationsdk/jobstreamoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -170,12 +172,11 @@ def get( :type job_stream_id: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: JobStream or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobStream :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -186,10 +187,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.JobStream] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_name=job_name, @@ -197,15 +198,14 @@ def get( subscription_id=self._config.subscription_id, client_request_id=client_request_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -215,16 +215,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("JobStream", pipeline_response) + deserialized = self._deserialize("JobStream", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams/{jobStreamId}" - } + return deserialized # type: ignore @distributed_trace def list_by_job( @@ -238,6 +234,9 @@ def list_by_job( ) -> Iterable["_models.JobStream"]: """Retrieve a list of jobs streams identified by job name. + .. seealso:: + - http://aka.ms/azureautomationsdk/jobstreamoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -248,7 +247,6 @@ def list_by_job( :type filter: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either JobStream or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.JobStream] :raises ~azure.core.exceptions.HttpResponseError: @@ -256,10 +254,10 @@ def list_by_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.JobStreamListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -270,7 +268,7 @@ def list_by_job( def prepare_request(next_link=None): if not next_link: - request = build_list_by_job_request( + _request = build_list_by_job_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, job_name=job_name, @@ -278,19 +276,16 @@ def prepare_request(next_link=None): filter=filter, client_request_id=client_request_id, api_version=api_version, - template_url=self.list_by_job.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("JobStreamListResult", pipeline_response) @@ -300,10 +295,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -315,7 +311,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_job.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_keys_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_keys_operations.py index 65d3c2d4f59d..ea7c48ad486f 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_keys_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_keys_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, TypeVar +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,20 +18,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -45,7 +44,7 @@ def build_list_by_automation_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +60,7 @@ def build_list_by_automation_account_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -101,12 +100,11 @@ def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: KeyListResult or the result of cls(response) :rtype: ~azure.mgmt.automation.models.KeyListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -117,23 +115,22 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.KeyListResult] = kwargs.pop("cls", None) - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -143,13 +140,9 @@ def list_by_automation_account( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("KeyListResult", pipeline_response) + deserialized = self._deserialize("KeyListResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/listKeys" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_linked_workspace_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_linked_workspace_operations.py index 3e65082d6b94..21bc461ee57a 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_linked_workspace_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_linked_workspace_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, TypeVar +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,20 +18,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -45,7 +44,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +60,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -95,16 +94,18 @@ def __init__(self, *args, **kwargs): def get(self, resource_group_name: str, automation_account_name: str, **kwargs: Any) -> _models.LinkedWorkspace: """Retrieve the linked workspace for the account id. + .. seealso:: + - http://aka.ms/azureautomationsdk/linkedworkspaceoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LinkedWorkspace or the result of cls(response) :rtype: ~azure.mgmt.automation.models.LinkedWorkspace :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -115,23 +116,22 @@ def get(self, resource_group_name: str, automation_account_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.LinkedWorkspace] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -141,13 +141,9 @@ def get(self, resource_group_name: str, automation_account_name: str, **kwargs: error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("LinkedWorkspace", pipeline_response) + deserialized = self._deserialize("LinkedWorkspace", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/linkedWorkspace" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_module_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_module_operations.py index 2631b4144265..15ad76f177ea 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_module_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_module_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +20,21 @@ ) 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.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -46,7 +48,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +65,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +82,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -97,7 +99,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +116,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -132,7 +134,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -151,7 +153,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -169,7 +171,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -188,7 +190,7 @@ def build_list_by_automation_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -204,7 +206,7 @@ def build_list_by_automation_account_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -240,18 +242,20 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the module by name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param module_name: The module name. Required. :type module_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, @@ -262,24 +266,23 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, module_name=module_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -290,11 +293,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.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -302,18 +301,20 @@ def get( ) -> _models.Module: """Retrieve the module identified by module name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param module_name: The module name. Required. :type module_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -324,24 +325,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.Module] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, module_name=module_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -351,19 +351,84 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Module", pipeline_response) + deserialized = self._deserialize("Module", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}" - } + def _create_or_update_initial( + self, + resource_group_name: str, + automation_account_name: str, + module_name: str, + parameters: Union[_models.ModuleCreateOrUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ModuleCreateOrUpdateParameters") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + response.read() # Load the body in memory and close the socket + 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 = response.stream_download(self._client._pipeline) + + if response.status_code == 201: + deserialized = response.stream_download(self._client._pipeline) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @overload - def create_or_update( + def begin_create_or_update( self, resource_group_name: str, automation_account_name: str, @@ -372,9 +437,12 @@ def create_or_update( *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Module: + ) -> LROPoller[_models.Module]: """Create or Update the module identified by module name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -386,25 +454,27 @@ 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: Module or the result of cls(response) - :rtype: ~azure.mgmt.automation.models.Module + :return: An instance of LROPoller that returns either Module or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.automation.models.Module] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update( + def begin_create_or_update( self, resource_group_name: str, automation_account_name: str, module_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Module: + ) -> LROPoller[_models.Module]: """Create or Update the module identified by module name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -412,109 +482,92 @@ def create_or_update( :param module_name: The name of module. Required. :type module_name: str :param parameters: The create or update parameters for module. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Module or the result of cls(response) - :rtype: ~azure.mgmt.automation.models.Module + :return: An instance of LROPoller that returns either Module or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.automation.models.Module] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def create_or_update( + def begin_create_or_update( self, resource_group_name: str, automation_account_name: str, module_name: str, - parameters: Union[_models.ModuleCreateOrUpdateParameters, IO], + parameters: Union[_models.ModuleCreateOrUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.Module: + ) -> LROPoller[_models.Module]: """Create or Update the module identified by module name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param module_name: The name of module. Required. :type module_name: str - :param parameters: The create or update parameters for module. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.automation.models.ModuleCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Module or the result of cls(response) - :rtype: ~azure.mgmt.automation.models.Module + :param parameters: The create or update parameters for module. Is either a + ModuleCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.ModuleCreateOrUpdateParameters or IO[bytes] + :return: An instance of LROPoller that returns either Module or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.automation.models.Module] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Module] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ModuleCreateOrUpdateParameters") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - automation_account_name=automation_account_name, - module_name=module_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Module", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + 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.Module].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Module]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - 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("Module", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Module", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}" - } - @overload def update( self, @@ -528,6 +581,9 @@ def update( ) -> _models.Module: """Update the module identified by module name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -539,7 +595,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: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: @@ -551,13 +606,16 @@ def update( resource_group_name: str, automation_account_name: str, module_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Module: """Update the module identified by module name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -565,11 +623,10 @@ def update( :param module_name: The name of module. Required. :type module_name: str :param parameters: The update parameters for module. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: @@ -581,29 +638,28 @@ def update( resource_group_name: str, automation_account_name: str, module_name: str, - parameters: Union[_models.ModuleUpdateParameters, IO], + parameters: Union[_models.ModuleUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Module: """Update the module identified by module name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param module_name: The name of module. Required. :type module_name: str - :param parameters: The update parameters for module. Is either a model type or a IO type. - Required. - :type parameters: ~azure.mgmt.automation.models.ModuleUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 update parameters for module. Is either a ModuleUpdateParameters type or + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.ModuleUpdateParameters or IO[bytes] :return: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -614,19 +670,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Module] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ModuleUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, module_name=module_name, @@ -635,15 +691,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -653,16 +708,12 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Module", pipeline_response) + deserialized = self._deserialize("Module", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -670,11 +721,13 @@ def list_by_automation_account( ) -> Iterable["_models.Module"]: """Retrieve a list of modules. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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 Module or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.Module] :raises ~azure.core.exceptions.HttpResponseError: @@ -682,10 +735,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.ModuleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -696,24 +749,21 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ModuleListResult", pipeline_response) @@ -723,10 +773,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -738,7 +789,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_node_count_information_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_node_count_information_operations.py index efe79673ab61..e29e688bedd3 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_node_count_information_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_node_count_information_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, TypeVar, Union +from typing import Any, Callable, Dict, Optional, Type, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,20 +18,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -49,9 +48,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -68,7 +65,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -108,6 +105,9 @@ def get( ) -> _models.NodeCounts: """Retrieve counts for Dsc Nodes. + .. seealso:: + - http://aka.ms/azureautomationsdk/nodecounts + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -115,12 +115,11 @@ def get( :param count_type: The type of counts to retrieve. Known values are: "status" and "nodeconfiguration". Required. :type count_type: str or ~azure.mgmt.automation.models.CountType - :keyword callable cls: A custom type or function that will be passed the direct response :return: NodeCounts or the result of cls(response) :rtype: ~azure.mgmt.automation.models.NodeCounts :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -131,26 +130,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.NodeCounts] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, count_type=count_type, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -160,13 +156,9 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("NodeCounts", pipeline_response) + deserialized = self._deserialize("NodeCounts", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodecounts/{countType}" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_node_reports_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_node_reports_operations.py index fa13f6eca28c..775259ec179f 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_node_reports_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_node_reports_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,24 +19,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC if sys.version_info >= (3, 9): 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 JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -57,9 +52,7 @@ def build_list_by_node_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -76,7 +69,7 @@ def build_list_by_node_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -100,9 +93,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -120,7 +111,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -142,9 +133,7 @@ def build_get_content_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -162,7 +151,7 @@ def build_get_content_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -203,6 +192,9 @@ def list_by_node( ) -> Iterable["_models.DscNodeReport"]: """Retrieve the Dsc node report list by node id. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodereportoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -211,7 +203,6 @@ def list_by_node( :type node_id: str :param filter: The filter to apply on the operation. 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 DscNodeReport or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.DscNodeReport] :raises ~azure.core.exceptions.HttpResponseError: @@ -219,12 +210,10 @@ def list_by_node( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.DscNodeReportListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -235,26 +224,23 @@ def list_by_node( def prepare_request(next_link=None): if not next_link: - request = build_list_by_node_request( + _request = build_list_by_node_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, node_id=node_id, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_node.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DscNodeReportListResult", pipeline_response) @@ -264,10 +250,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -280,16 +267,15 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_node.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports" - } - @distributed_trace def get( self, resource_group_name: str, automation_account_name: str, node_id: str, report_id: str, **kwargs: Any ) -> _models.DscNodeReport: """Retrieve the Dsc node report data by node id and report id. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodereportoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -298,12 +284,11 @@ def get( :type node_id: str :param report_id: The report id. Required. :type report_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DscNodeReport or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNodeReport :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -314,27 +299,24 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.DscNodeReport] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, node_id=node_id, report_id=report_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -344,16 +326,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DscNodeReport", pipeline_response) + deserialized = self._deserialize("DscNodeReport", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}" - } + return deserialized # type: ignore @distributed_trace def get_content( @@ -361,6 +339,9 @@ def get_content( ) -> JSON: """Retrieve the Dsc node reports by node id and report id. + .. seealso:: + - http://aka.ms/azureautomationsdk/dscnodereportoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -369,12 +350,11 @@ def get_content( :type node_id: str :param report_id: The report id. Required. :type report_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: JSON or the result of cls(response) :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -385,27 +365,24 @@ def get_content( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_get_content_request( + _request = build_get_content_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, node_id=node_id, report_id=report_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_content.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -415,13 +392,9 @@ def get_content( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("object", pipeline_response) + deserialized = self._deserialize("object", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_content.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}/content" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_object_data_types_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_object_data_types_operations.py index a0bd570f9776..c007ce4e0904 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_object_data_types_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_object_data_types_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +19,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -40,7 +39,7 @@ _SERIALIZER.client_side_validation = False -def build_list_fields_by_module_and_type_request( +def build_list_fields_by_module_and_type_request( # pylint: disable=name-too-long resource_group_name: str, automation_account_name: str, module_name: str, @@ -51,7 +50,7 @@ def build_list_fields_by_module_and_type_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -69,7 +68,7 @@ def build_list_fields_by_module_and_type_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -86,7 +85,7 @@ def build_list_fields_by_type_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -103,7 +102,7 @@ def build_list_fields_by_type_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -139,6 +138,9 @@ def list_fields_by_module_and_type( ) -> Iterable["_models.TypeField"]: """Retrieve a list of fields of a given type identified by module name. + .. seealso:: + - http://aka.ms/azureautomationsdk/objectdatatypeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -147,7 +149,6 @@ def list_fields_by_module_and_type( :type module_name: str :param type_name: The name of type. Required. :type type_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TypeField or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.TypeField] :raises ~azure.core.exceptions.HttpResponseError: @@ -155,10 +156,10 @@ def list_fields_by_module_and_type( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.TypeFieldListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -169,26 +170,23 @@ def list_fields_by_module_and_type( def prepare_request(next_link=None): if not next_link: - request = build_list_fields_by_module_and_type_request( + _request = build_list_fields_by_module_and_type_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, module_name=module_name, type_name=type_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_fields_by_module_and_type.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("TypeFieldListResult", pipeline_response) @@ -198,10 +196,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -214,23 +213,21 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_fields_by_module_and_type.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/objectDataTypes/{typeName}/fields" - } - @distributed_trace def list_fields_by_type( self, resource_group_name: str, automation_account_name: str, type_name: str, **kwargs: Any ) -> Iterable["_models.TypeField"]: """Retrieve a list of fields of a given type across all accessible modules. + .. seealso:: + - http://aka.ms/azureautomationsdk/objectdatatypeoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param type_name: The name of type. Required. :type type_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TypeField or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.TypeField] :raises ~azure.core.exceptions.HttpResponseError: @@ -238,10 +235,10 @@ def list_fields_by_type( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.TypeFieldListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -252,25 +249,22 @@ def list_fields_by_type( def prepare_request(next_link=None): if not next_link: - request = build_list_fields_by_type_request( + _request = build_list_fields_by_type_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, type_name=type_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_fields_by_type.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("TypeFieldListResult", pipeline_response) @@ -280,10 +274,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -295,7 +290,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_fields_by_type.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/objectDataTypes/{typeName}/fields" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_operations.py index 840ce5a7ac2d..f352ec384685 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/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. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +19,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request +from .._vendor import AutomationClientMixinABC -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]] @@ -44,7 +43,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -82,7 +81,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Automation 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.automation.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -90,10 +88,10 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -104,21 +102,18 @@ 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.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -128,10 +123,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -143,5 +139,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Automation/operations"} diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_power_shell72_module_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_power_shell72_module_operations.py new file mode 100644 index 000000000000..2e33f58a6069 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_power_shell72_module_operations.py @@ -0,0 +1,810 @@ +# 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, Iterator, Optional, Type, TypeVar, Union, cast, overload + +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.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import AutomationClientMixinABC + +if sys.version_info >= (3, 9): + 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_delete_request( + resource_group_name: str, automation_account_name: str, module_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-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/powerShell72Modules/{moduleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "automationAccountName": _SERIALIZER.url( + "automation_account_name", automation_account_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-_0-9]*$" + ), + "moduleName": _SERIALIZER.url("module_name", module_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-._0-9]*$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, automation_account_name: str, module_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-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/powerShell72Modules/{moduleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "automationAccountName": _SERIALIZER.url( + "automation_account_name", automation_account_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-_0-9]*$" + ), + "moduleName": _SERIALIZER.url("module_name", module_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-._0-9]*$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, automation_account_name: str, module_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-11-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.Automation/automationAccounts/{automationAccountName}/powerShell72Modules/{moduleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "automationAccountName": _SERIALIZER.url( + "automation_account_name", automation_account_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-_0-9]*$" + ), + "moduleName": _SERIALIZER.url("module_name", module_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-._0-9]*$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + 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, automation_account_name: str, module_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-11-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.Automation/automationAccounts/{automationAccountName}/powerShell72Modules/{moduleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "automationAccountName": _SERIALIZER.url( + "automation_account_name", automation_account_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-_0-9]*$" + ), + "moduleName": _SERIALIZER.url("module_name", module_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-._0-9]*$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + 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_by_automation_account_request( + resource_group_name: str, automation_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-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/powerShell72Modules", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "automationAccountName": _SERIALIZER.url( + "automation_account_name", automation_account_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-_0-9]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PowerShell72ModuleOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`power_shell72_module` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, automation_account_name: str, module_name: str, **kwargs: Any + ) -> None: + """Delete the module by name. + + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. Required. + :type automation_account_name: str + :param module_name: The name of module. Required. + :type module_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", "2023-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 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 get( + self, resource_group_name: str, automation_account_name: str, module_name: str, **kwargs: Any + ) -> _models.Module: + """Retrieve the module identified by module name. + + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. Required. + :type automation_account_name: str + :param module_name: The name of module. Required. + :type module_name: str + :return: Module or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.Module + :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", "2023-11-01")) + cls: ClsType[_models.Module] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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("Module", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + automation_account_name: str, + module_name: str, + parameters: Union[_models.ModuleCreateOrUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ModuleCreateOrUpdateParameters") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + response.read() # Load the body in memory and close the socket + 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 = response.stream_download(self._client._pipeline) + + if response.status_code == 201: + deserialized = response.stream_download(self._client._pipeline) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + automation_account_name: str, + module_name: str, + parameters: _models.ModuleCreateOrUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Module]: + """Create or Update the module identified by module name. + + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. Required. + :type automation_account_name: str + :param module_name: The name of module. Required. + :type module_name: str + :param parameters: The create or update parameters for module. Required. + :type parameters: ~azure.mgmt.automation.models.ModuleCreateOrUpdateParameters + :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 Module or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.automation.models.Module] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + automation_account_name: str, + module_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Module]: + """Create or Update the module identified by module name. + + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. Required. + :type automation_account_name: str + :param module_name: The name of module. Required. + :type module_name: str + :param parameters: The create or update parameters for module. 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 Module or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.automation.models.Module] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + automation_account_name: str, + module_name: str, + parameters: Union[_models.ModuleCreateOrUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Module]: + """Create or Update the module identified by module name. + + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. Required. + :type automation_account_name: str + :param module_name: The name of module. Required. + :type module_name: str + :param parameters: The create or update parameters for module. Is either a + ModuleCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.ModuleCreateOrUpdateParameters or IO[bytes] + :return: An instance of LROPoller that returns either Module or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.automation.models.Module] + :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", "2023-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Module] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Module", pipeline_response.http_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.Module].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Module]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @overload + def update( + self, + resource_group_name: str, + automation_account_name: str, + module_name: str, + parameters: _models.ModuleUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Module: + """Update the module identified by module name. + + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. Required. + :type automation_account_name: str + :param module_name: The name of module. Required. + :type module_name: str + :param parameters: The update parameters for module. Required. + :type parameters: ~azure.mgmt.automation.models.ModuleUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Module or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.Module + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + automation_account_name: str, + module_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Module: + """Update the module identified by module name. + + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. Required. + :type automation_account_name: str + :param module_name: The name of module. Required. + :type module_name: str + :param parameters: The update parameters for module. 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: Module or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.Module + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + automation_account_name: str, + module_name: str, + parameters: Union[_models.ModuleUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> _models.Module: + """Update the module identified by module name. + + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. Required. + :type automation_account_name: str + :param module_name: The name of module. Required. + :type module_name: str + :param parameters: The update parameters for module. Is either a ModuleUpdateParameters type or + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.ModuleUpdateParameters or IO[bytes] + :return: Module or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.Module + :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", "2023-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Module] = 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, "ModuleUpdateParameters") + + _request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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("Module", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_automation_account( + self, resource_group_name: str, automation_account_name: str, **kwargs: Any + ) -> Iterable["_models.Module"]: + """Retrieve a list of PowerShell72 modules. + + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. Required. + :type automation_account_name: str + :return: An iterator like instance of either Module or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.Module] + :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", "2023-11-01")) + cls: ClsType[_models.ModuleListResult] = 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_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ModuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_private_endpoint_connections_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_private_endpoint_connections_operations.py index a74811f185c9..0e2fca296161 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_private_endpoint_connections_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from 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, Iterator, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,9 +20,8 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -29,12 +29,12 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -48,9 +48,7 @@ def build_list_by_automation_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,7 +64,7 @@ def build_list_by_automation_account_request( "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -87,9 +85,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -108,7 +104,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -129,9 +125,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -151,7 +145,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -174,9 +168,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -195,7 +187,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -235,7 +227,6 @@ def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.PrivateEndpointConnection] @@ -244,12 +235,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -260,24 +249,21 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -287,10 +273,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -302,10 +289,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections" - } - @distributed_trace def get( self, @@ -322,12 +305,11 @@ def get( :type automation_account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.automation.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -338,26 +320,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -366,26 +345,22 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, automation_account_name: str, private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any - ) -> Optional[_models.PrivateEndpointConnection]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -396,21 +371,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "PrivateEndpointConnection") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -419,36 +392,34 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) - if cls: - return cls(pipeline_response, deserialized, {}) + if response.status_code == 202: + deserialized = response.stream_download(self._client._pipeline) - return deserialized + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload def begin_create_or_update( @@ -474,14 +445,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.automation.models.PrivateEndpointConnection] @@ -494,7 +457,7 @@ def begin_create_or_update( resource_group_name: str, automation_account_name: str, private_endpoint_connection_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -508,18 +471,10 @@ def begin_create_or_update( :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param parameters: Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.automation.models.PrivateEndpointConnection] @@ -532,7 +487,7 @@ def begin_create_or_update( resource_group_name: str, automation_account_name: str, private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection with a given name. @@ -543,19 +498,8 @@ def begin_create_or_update( :type automation_account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :param parameters: Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.PrivateEndpointConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param parameters: Is either a PrivateEndpointConnection type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.PrivateEndpointConnection or IO[bytes] :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.automation.models.PrivateEndpointConnection] @@ -564,9 +508,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -585,12 +527,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -600,26 +543,24 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.PrivateEndpointConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return LROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, automation_account_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -630,41 +571,43 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + response.read() # Load the body in memory and close the socket 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 == 202: + deserialized = response.stream_download(self._client._pipeline) + + if response.status_code == 204: + deserialized = response.stream_download(self._client._pipeline) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -682,14 +625,6 @@ def begin_delete( :type automation_account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -697,15 +632,13 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, automation_account_name=automation_account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -715,11 +648,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -728,14 +662,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_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_private_link_resources_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_private_link_resources_operations.py index 3c4845e592ff..b23b7042f799 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_private_link_resources_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/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. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +19,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -46,9 +45,7 @@ def build_automation_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -64,7 +61,7 @@ def build_automation_request( "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -104,7 +101,6 @@ def automation( :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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 PrivateLinkResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.PrivateLinkResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -112,12 +108,10 @@ def automation( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -128,24 +122,21 @@ def automation( def prepare_request(next_link=None): if not next_link: - request = build_automation_request( + _request = build_automation_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.automation.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) @@ -155,10 +146,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -169,7 +161,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - automation.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateLinkResources" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_python2_package_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_python2_package_operations.py index 9637fdcdee3b..d4cda7d5f822 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_python2_package_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_python2_package_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +20,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -46,7 +46,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +63,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -97,7 +97,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +114,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -132,7 +132,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -151,7 +151,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -169,7 +169,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -188,7 +188,7 @@ def build_list_by_automation_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -204,7 +204,7 @@ def build_list_by_automation_account_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -240,18 +240,20 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the python 2 package by name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param package_name: The python package name. Required. :type package_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, @@ -262,24 +264,23 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, package_name=package_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -290,11 +291,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.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -302,18 +299,20 @@ def get( ) -> _models.Module: """Retrieve the python 2 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param package_name: The python package name. Required. :type package_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -324,24 +323,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.Module] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, package_name=package_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -351,16 +349,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Module", pipeline_response) + deserialized = self._deserialize("Module", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -375,6 +369,9 @@ def create_or_update( ) -> _models.Module: """Create or Update the python 2 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -386,7 +383,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: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: @@ -398,13 +394,16 @@ def create_or_update( resource_group_name: str, automation_account_name: str, package_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Module: """Create or Update the python 2 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -412,11 +411,10 @@ def create_or_update( :param package_name: The name of python package. Required. :type package_name: str :param parameters: The create or update parameters for python package. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: @@ -428,29 +426,28 @@ def create_or_update( resource_group_name: str, automation_account_name: str, package_name: str, - parameters: Union[_models.PythonPackageCreateParameters, IO], + parameters: Union[_models.PythonPackageCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.Module: """Create or Update the python 2 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param package_name: The name of python package. Required. :type package_name: str - :param parameters: The create or update parameters for python package. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.PythonPackageCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 create or update parameters for python package. Is either a + PythonPackageCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.PythonPackageCreateParameters or IO[bytes] :return: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -461,19 +458,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Module] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "PythonPackageCreateParameters") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, package_name=package_name, @@ -482,15 +479,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -501,20 +497,16 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("Module", pipeline_response) + deserialized = self._deserialize("Module", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("Module", pipeline_response) + deserialized = self._deserialize("Module", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}" - } - @overload def update( self, @@ -528,6 +520,9 @@ def update( ) -> _models.Module: """Update the python 2 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -539,7 +534,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: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: @@ -551,13 +545,16 @@ def update( resource_group_name: str, automation_account_name: str, package_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Module: """Update the python 2 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -565,11 +562,10 @@ def update( :param package_name: The name of python package. Required. :type package_name: str :param parameters: The update parameters for python package. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: @@ -581,29 +577,28 @@ def update( resource_group_name: str, automation_account_name: str, package_name: str, - parameters: Union[_models.PythonPackageUpdateParameters, IO], + parameters: Union[_models.PythonPackageUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Module: """Update the python 2 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param package_name: The name of python package. Required. :type package_name: str - :param parameters: The update parameters for python package. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.automation.models.PythonPackageUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 update parameters for python package. Is either a + PythonPackageUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.PythonPackageUpdateParameters or IO[bytes] :return: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -614,19 +609,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Module] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "PythonPackageUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, package_name=package_name, @@ -635,15 +630,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -653,16 +647,12 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Module", pipeline_response) + deserialized = self._deserialize("Module", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -670,11 +660,13 @@ def list_by_automation_account( ) -> Iterable["_models.Module"]: """Retrieve a list of python 2 packages. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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 Module or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.Module] :raises ~azure.core.exceptions.HttpResponseError: @@ -682,10 +674,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.ModuleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -696,24 +688,21 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ModuleListResult", pipeline_response) @@ -723,10 +712,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -738,7 +728,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_python3_package_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_python3_package_operations.py index 8a972064ff1b..e32316c3e08a 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_python3_package_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_python3_package_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +20,21 @@ ) 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.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -46,7 +48,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +65,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +82,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -97,7 +99,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +116,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -132,7 +134,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -151,7 +153,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -169,7 +171,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -188,7 +190,7 @@ def build_list_by_automation_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -204,7 +206,7 @@ def build_list_by_automation_account_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -240,18 +242,20 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the python 3 package by name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param package_name: The python package name. Required. :type package_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, @@ -262,24 +266,23 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, package_name=package_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -290,11 +293,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.Automation/automationAccounts/{automationAccountName}/python3Packages/{packageName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -302,18 +301,20 @@ def get( ) -> _models.Module: """Retrieve the python 3 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param package_name: The python package name. Required. :type package_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -324,24 +325,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.Module] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, package_name=package_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -351,19 +351,84 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Module", pipeline_response) + deserialized = self._deserialize("Module", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python3Packages/{packageName}" - } + def _create_or_update_initial( + self, + resource_group_name: str, + automation_account_name: str, + package_name: str, + parameters: Union[_models.PythonPackageCreateParameters, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PythonPackageCreateParameters") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + package_name=package_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + response.read() # Load the body in memory and close the socket + 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 = response.stream_download(self._client._pipeline) + + if response.status_code == 201: + deserialized = response.stream_download(self._client._pipeline) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @overload - def create_or_update( + def begin_create_or_update( self, resource_group_name: str, automation_account_name: str, @@ -372,9 +437,12 @@ def create_or_update( *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Module: + ) -> LROPoller[_models.Module]: """Create or Update the python 3 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -386,25 +454,27 @@ 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: Module or the result of cls(response) - :rtype: ~azure.mgmt.automation.models.Module + :return: An instance of LROPoller that returns either Module or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.automation.models.Module] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update( + def begin_create_or_update( self, resource_group_name: str, automation_account_name: str, package_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Module: + ) -> LROPoller[_models.Module]: """Create or Update the python 3 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -412,109 +482,92 @@ def create_or_update( :param package_name: The name of python package. Required. :type package_name: str :param parameters: The create or update parameters for python package. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Module or the result of cls(response) - :rtype: ~azure.mgmt.automation.models.Module + :return: An instance of LROPoller that returns either Module or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.automation.models.Module] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def create_or_update( + def begin_create_or_update( self, resource_group_name: str, automation_account_name: str, package_name: str, - parameters: Union[_models.PythonPackageCreateParameters, IO], + parameters: Union[_models.PythonPackageCreateParameters, IO[bytes]], **kwargs: Any - ) -> _models.Module: + ) -> LROPoller[_models.Module]: """Create or Update the python 3 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param package_name: The name of python package. Required. :type package_name: str - :param parameters: The create or update parameters for python package. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.PythonPackageCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Module or the result of cls(response) - :rtype: ~azure.mgmt.automation.models.Module + :param parameters: The create or update parameters for python package. Is either a + PythonPackageCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.PythonPackageCreateParameters or IO[bytes] + :return: An instance of LROPoller that returns either Module or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.automation.models.Module] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Module] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + package_name=package_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PythonPackageCreateParameters") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - automation_account_name=automation_account_name, - package_name=package_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Module", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + 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.Module].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Module]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - 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("Module", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Module", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python3Packages/{packageName}" - } - @overload def update( self, @@ -528,6 +581,9 @@ def update( ) -> _models.Module: """Update the python 3 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -539,7 +595,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: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: @@ -551,13 +606,16 @@ def update( resource_group_name: str, automation_account_name: str, package_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Module: """Update the python 3 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -565,11 +623,10 @@ def update( :param package_name: The name of python package. Required. :type package_name: str :param parameters: The update parameters for python package. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: @@ -581,29 +638,28 @@ def update( resource_group_name: str, automation_account_name: str, package_name: str, - parameters: Union[_models.PythonPackageUpdateParameters, IO], + parameters: Union[_models.PythonPackageUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Module: """Update the python 3 package identified by package name. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param package_name: The name of python package. Required. :type package_name: str - :param parameters: The update parameters for python package. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.automation.models.PythonPackageUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 update parameters for python package. Is either a + PythonPackageUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.PythonPackageUpdateParameters or IO[bytes] :return: Module or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -614,19 +670,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Module] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "PythonPackageUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, package_name=package_name, @@ -635,15 +691,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -653,16 +708,12 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Module", pipeline_response) + deserialized = self._deserialize("Module", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/python3Packages/{packageName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -670,11 +721,13 @@ def list_by_automation_account( ) -> Iterable["_models.Module"]: """Retrieve a list of python 3 packages. + .. seealso:: + - http://aka.ms/azureautomationsdk/moduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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 Module or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.Module] :raises ~azure.core.exceptions.HttpResponseError: @@ -682,10 +735,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.ModuleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -696,24 +749,21 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ModuleListResult", pipeline_response) @@ -723,10 +773,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -738,7 +789,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python3Packages" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_runbook_draft_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_runbook_draft_operations.py index 0168fc1dfd72..9fe53f76edb2 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_runbook_draft_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_runbook_draft_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast +from typing import Any, Callable, Dict, IO, Iterator, Optional, Type, TypeVar, Union, cast from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,9 +18,8 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -28,12 +27,12 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -47,7 +46,7 @@ def build_get_content_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "text/powershell") # Construct URL @@ -61,10 +60,10 @@ def build_get_content_request( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._]+$" ), "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, "str"), - "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z]*-*[a-zA-Z0-9]*$"), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-_0-9]*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -81,13 +80,13 @@ def build_replace_content_request( runbook_name: str, subscription_id: str, *, - content: IO, + content: IO[bytes], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -102,10 +101,10 @@ def build_replace_content_request( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._]+$" ), "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, "str"), - "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z]*-*[a-zA-Z0-9]*$"), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-_0-9]*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -124,7 +123,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -138,10 +137,10 @@ def build_get_request( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._]+$" ), "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, "str"), - "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z]*-*[a-zA-Z0-9]*$"), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-_0-9]*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -158,7 +157,7 @@ def build_undo_edit_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -172,10 +171,10 @@ def build_undo_edit_request( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._]+$" ), "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, "str"), - "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z]*-*[a-zA-Z0-9]*$"), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-_0-9]*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -211,18 +210,20 @@ def get_content( ) -> Iterator[bytes]: """Retrieve the content of runbook draft identified by runbook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookdraftoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The runbook name. Required. :type runbook_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Iterator of the response bytes or the result of cls(response) + :return: Iterator[bytes] or the result of cls(response) :rtype: Iterator[bytes] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -233,29 +234,29 @@ def get_content( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_get_content_request( + _request = build_get_content_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_content.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=True, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: + response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -266,19 +267,15 @@ def get_content( return deserialized # type: ignore - get_content.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content" - } - def _replace_content_initial( self, resource_group_name: str, automation_account_name: str, runbook_name: str, - runbook_content: IO, + runbook_content: IO[bytes], **kwargs: Any - ) -> Optional[Iterator[bytes]]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -289,13 +286,13 @@ def _replace_content_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[Iterator[bytes]]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _content = runbook_content - request = build_replace_content_request( + _request = build_replace_content_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, @@ -303,25 +300,24 @@ def _replace_content_initial( api_version=api_version, content_type=content_type, content=_content, - template_url=self._replace_content_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=True, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} if response.status_code == 200: deserialized = response.stream_download(self._client._pipeline) @@ -329,14 +325,12 @@ def _replace_content_initial( if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _replace_content_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content" - } + return deserialized # type: ignore @distributed_trace def begin_replace_content( @@ -344,11 +338,14 @@ def begin_replace_content( resource_group_name: str, automation_account_name: str, runbook_name: str, - runbook_content: IO, + runbook_content: IO[bytes], **kwargs: Any ) -> LROPoller[Iterator[bytes]]: """Replaces the runbook draft content. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookdraftoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -356,24 +353,16 @@ def begin_replace_content( :param runbook_name: The runbook name. Required. :type runbook_name: str :param runbook_content: The runbook draft content. Required. - :type runbook_content: IO - :keyword callable cls: A custom type or function that will be passed the direct response - :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 Iterator of the response bytes or the - result of cls(response) + :type runbook_content: IO[bytes] + :return: An instance of LROPoller that returns either Iterator[bytes] or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[Iterator[bytes]] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -392,12 +381,13 @@ def begin_replace_content( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = response.stream_download(self._client._pipeline) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -409,17 +399,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[Iterator[bytes]].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_replace_content.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content" - } + return LROPoller[Iterator[bytes]]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def get( @@ -427,18 +415,20 @@ def get( ) -> _models.RunbookDraft: """Retrieve the runbook draft identified by runbook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookdraftoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The runbook name. Required. :type runbook_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RunbookDraft or the result of cls(response) :rtype: ~azure.mgmt.automation.models.RunbookDraft :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -449,24 +439,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.RunbookDraft] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -476,16 +465,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RunbookDraft", pipeline_response) + deserialized = self._deserialize("RunbookDraft", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft" - } + return deserialized # type: ignore @distributed_trace def undo_edit( @@ -493,18 +478,20 @@ def undo_edit( ) -> _models.RunbookDraftUndoEditResult: """Undo draft edit to last known published state identified by runbook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookdraftoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The runbook name. Required. :type runbook_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RunbookDraftUndoEditResult or the result of cls(response) :rtype: ~azure.mgmt.automation.models.RunbookDraftUndoEditResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -515,24 +502,23 @@ def undo_edit( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.RunbookDraftUndoEditResult] = kwargs.pop("cls", None) - request = build_undo_edit_request( + _request = build_undo_edit_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.undo_edit.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -542,13 +528,9 @@ def undo_edit( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RunbookDraftUndoEditResult", pipeline_response) + deserialized = self._deserialize("RunbookDraftUndoEditResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - undo_edit.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/undoEdit" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_runbook_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_runbook_operations.py index 3b9098bee619..1e98843c6a85 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_runbook_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_runbook_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, Iterator, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,9 +20,8 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -29,12 +29,12 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -48,7 +48,7 @@ def build_publish_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,10 +62,10 @@ def build_publish_request( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._]+$" ), "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, "str"), - "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z]*-*[a-zA-Z0-9]*$"), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-_0-9]*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -82,7 +82,7 @@ def build_get_content_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "text/powershell") # Construct URL @@ -96,10 +96,10 @@ def build_get_content_request( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._]+$" ), "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, "str"), - "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z]*-*[a-zA-Z0-9]*$"), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-_0-9]*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,7 +116,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -130,10 +130,10 @@ def build_get_request( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._]+$" ), "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, "str"), - "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z]*-*[a-zA-Z0-9]*$"), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-_0-9]*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -150,7 +150,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -165,10 +165,10 @@ def build_create_or_update_request( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._]+$" ), "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, "str"), - "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z]*-*[a-zA-Z0-9]*$"), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-_0-9]*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -187,7 +187,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -202,10 +202,10 @@ def build_update_request( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._]+$" ), "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, "str"), - "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z]*-*[a-zA-Z0-9]*$"), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-_0-9]*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -224,7 +224,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -238,10 +238,10 @@ def build_delete_request( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._]+$" ), "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, "str"), - "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z]*-*[a-zA-Z0-9]*$"), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-_0-9]*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -258,7 +258,7 @@ def build_list_by_automation_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -274,7 +274,7 @@ def build_list_by_automation_account_request( "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -304,10 +304,10 @@ def __init__(self, *args, **kwargs): 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") - def _publish_initial( # pylint: disable=inconsistent-return-statements + def _publish_initial( self, resource_group_name: str, automation_account_name: str, runbook_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -318,29 +318,29 @@ def _publish_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_publish_request( + _request = build_publish_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._publish_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202]: + response.read() # Load the body in memory and close the socket 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) @@ -348,12 +348,12 @@ def _publish_initial( # pylint: disable=inconsistent-return-statements response_headers = {} response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _publish_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/publish" - } + return deserialized # type: ignore @distributed_trace def begin_publish( @@ -361,20 +361,15 @@ def begin_publish( ) -> LROPoller[None]: """Publish runbook draft. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookdraftoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The parameters supplied to the publish runbook operation. Required. :type runbook_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: @@ -382,13 +377,13 @@ def begin_publish( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-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._publish_initial( # type: ignore + raw_result = self._publish_initial( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, @@ -398,11 +393,12 @@ def begin_publish( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -411,17 +407,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_publish.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/publish" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get_content( @@ -429,18 +421,20 @@ def get_content( ) -> Iterator[bytes]: """Retrieve the content of runbook identified by runbook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The runbook name. Required. :type runbook_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Iterator of the response bytes or the result of cls(response) + :return: Iterator[bytes] or the result of cls(response) :rtype: Iterator[bytes] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -451,29 +445,29 @@ def get_content( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_get_content_request( + _request = build_get_content_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_content.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=True, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: + response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -484,28 +478,26 @@ def get_content( return deserialized # type: ignore - get_content.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/content" - } - @distributed_trace def get( self, resource_group_name: str, automation_account_name: str, runbook_name: str, **kwargs: Any ) -> _models.Runbook: """Retrieve the runbook identified by runbook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The runbook name. Required. :type runbook_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Runbook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -516,24 +508,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.Runbook] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -543,16 +534,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Runbook", pipeline_response) + deserialized = self._deserialize("Runbook", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -567,6 +554,9 @@ def create_or_update( ) -> _models.Runbook: """Create the runbook identified by runbook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -579,7 +569,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: Runbook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook :raises ~azure.core.exceptions.HttpResponseError: @@ -591,13 +580,16 @@ def create_or_update( resource_group_name: str, automation_account_name: str, runbook_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Runbook: """Create the runbook identified by runbook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -606,11 +598,10 @@ def create_or_update( :type runbook_name: str :param parameters: The create or update parameters for runbook. Provide either content link for a published runbook or draft, not both. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Runbook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook :raises ~azure.core.exceptions.HttpResponseError: @@ -622,11 +613,14 @@ def create_or_update( resource_group_name: str, automation_account_name: str, runbook_name: str, - parameters: Union[_models.RunbookCreateOrUpdateParameters, IO], + parameters: Union[_models.RunbookCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Runbook: """Create the runbook identified by runbook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -634,17 +628,14 @@ def create_or_update( :param runbook_name: The runbook name. Required. :type runbook_name: str :param parameters: The create or update parameters for runbook. Provide either content link for - a published runbook or draft, not both. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.RunbookCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + a published runbook or draft, not both. Is either a RunbookCreateOrUpdateParameters type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.RunbookCreateOrUpdateParameters or IO[bytes] :return: Runbook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -655,19 +646,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Runbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RunbookCreateOrUpdateParameters") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, @@ -676,15 +667,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -695,20 +685,16 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("Runbook", pipeline_response) + deserialized = self._deserialize("Runbook", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("Runbook", pipeline_response) + deserialized = self._deserialize("Runbook", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}" - } - @overload def update( self, @@ -722,6 +708,9 @@ def update( ) -> _models.Runbook: """Update the runbook identified by runbook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -733,7 +722,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: Runbook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook :raises ~azure.core.exceptions.HttpResponseError: @@ -745,13 +733,16 @@ def update( resource_group_name: str, automation_account_name: str, runbook_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Runbook: """Update the runbook identified by runbook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -759,11 +750,10 @@ def update( :param runbook_name: The runbook name. Required. :type runbook_name: str :param parameters: The update parameters for runbook. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Runbook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook :raises ~azure.core.exceptions.HttpResponseError: @@ -775,29 +765,28 @@ def update( resource_group_name: str, automation_account_name: str, runbook_name: str, - parameters: Union[_models.RunbookUpdateParameters, IO], + parameters: Union[_models.RunbookUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Runbook: """Update the runbook identified by runbook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The runbook name. Required. :type runbook_name: str - :param parameters: The update parameters for runbook. Is either a model type or a IO type. - Required. - :type parameters: ~azure.mgmt.automation.models.RunbookUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 update parameters for runbook. Is either a RunbookUpdateParameters type + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.RunbookUpdateParameters or IO[bytes] :return: Runbook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -808,19 +797,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Runbook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RunbookUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, @@ -829,15 +818,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -847,16 +835,12 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Runbook", pipeline_response) + deserialized = self._deserialize("Runbook", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -864,18 +848,20 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the runbook by name. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The runbook name. Required. :type runbook_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, @@ -886,24 +872,23 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -914,11 +899,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.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_by_automation_account( @@ -926,11 +907,13 @@ def list_by_automation_account( ) -> Iterable["_models.Runbook"]: """Retrieve a list of runbooks. + .. seealso:: + - http://aka.ms/azureautomationsdk/runbookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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 Runbook or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.Runbook] :raises ~azure.core.exceptions.HttpResponseError: @@ -938,10 +921,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.RunbookListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -952,24 +935,21 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RunbookListResult", pipeline_response) @@ -979,10 +959,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -994,7 +975,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_schedule_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_schedule_operations.py index 7788fca6ce08..3fde64682ae9 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_schedule_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_schedule_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +20,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -46,7 +46,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -64,7 +64,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +83,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -101,7 +101,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -120,7 +120,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -137,7 +137,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,7 +154,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -171,7 +171,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -188,7 +188,7 @@ def build_list_by_automation_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -204,7 +204,7 @@ def build_list_by_automation_account_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -247,6 +247,9 @@ def create_or_update( ) -> Optional[_models.Schedule]: """Create a schedule. + .. seealso:: + - http://aka.ms/azureautomationsdk/scheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -259,7 +262,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: Schedule or None or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule or None :raises ~azure.core.exceptions.HttpResponseError: @@ -271,13 +273,16 @@ def create_or_update( resource_group_name: str, automation_account_name: str, schedule_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> Optional[_models.Schedule]: """Create a schedule. + .. seealso:: + - http://aka.ms/azureautomationsdk/scheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -286,11 +291,10 @@ def create_or_update( :type schedule_name: str :param parameters: The parameters supplied to the create or update schedule operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule or None or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule or None :raises ~azure.core.exceptions.HttpResponseError: @@ -302,11 +306,14 @@ def create_or_update( resource_group_name: str, automation_account_name: str, schedule_name: str, - parameters: Union[_models.ScheduleCreateOrUpdateParameters, IO], + parameters: Union[_models.ScheduleCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.Schedule]: """Create a schedule. + .. seealso:: + - http://aka.ms/azureautomationsdk/scheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -314,17 +321,13 @@ def create_or_update( :param schedule_name: The schedule name. Required. :type schedule_name: str :param parameters: The parameters supplied to the create or update schedule operation. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.ScheduleCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 ScheduleCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.ScheduleCreateOrUpdateParameters or IO[bytes] :return: Schedule or None or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -335,19 +338,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.Schedule]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ScheduleCreateOrUpdateParameters") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, schedule_name=schedule_name, @@ -356,15 +359,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -376,19 +378,15 @@ def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("Schedule", pipeline_response) + deserialized = self._deserialize("Schedule", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("Schedule", pipeline_response) + deserialized = self._deserialize("Schedule", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}" - } + return deserialized # type: ignore @overload def update( @@ -403,6 +401,9 @@ def update( ) -> _models.Schedule: """Update the schedule identified by schedule name. + .. seealso:: + - http://aka.ms/azureautomationsdk/scheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -414,7 +415,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: Schedule or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule :raises ~azure.core.exceptions.HttpResponseError: @@ -426,13 +426,16 @@ def update( resource_group_name: str, automation_account_name: str, schedule_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Schedule: """Update the schedule identified by schedule name. + .. seealso:: + - http://aka.ms/azureautomationsdk/scheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -440,11 +443,10 @@ def update( :param schedule_name: The schedule name. Required. :type schedule_name: str :param parameters: The parameters supplied to the update schedule operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule :raises ~azure.core.exceptions.HttpResponseError: @@ -456,29 +458,28 @@ def update( resource_group_name: str, automation_account_name: str, schedule_name: str, - parameters: Union[_models.ScheduleUpdateParameters, IO], + parameters: Union[_models.ScheduleUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Schedule: """Update the schedule identified by schedule name. + .. seealso:: + - http://aka.ms/azureautomationsdk/scheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param schedule_name: The schedule name. Required. :type schedule_name: str - :param parameters: The parameters supplied to the update schedule operation. Is either a model - type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.ScheduleUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 supplied to the update schedule operation. Is either a + ScheduleUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.ScheduleUpdateParameters or IO[bytes] :return: Schedule or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -489,19 +490,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Schedule] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ScheduleUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, schedule_name=schedule_name, @@ -510,15 +511,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -528,16 +528,12 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Schedule", pipeline_response) + deserialized = self._deserialize("Schedule", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -545,18 +541,20 @@ def get( ) -> _models.Schedule: """Retrieve the schedule identified by schedule name. + .. seealso:: + - http://aka.ms/azureautomationsdk/scheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param schedule_name: The schedule name. Required. :type schedule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -567,24 +565,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.Schedule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, schedule_name=schedule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -594,16 +591,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Schedule", pipeline_response) + deserialized = self._deserialize("Schedule", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -611,18 +604,20 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the schedule identified by schedule name. + .. seealso:: + - http://aka.ms/azureautomationsdk/scheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param schedule_name: The schedule name. Required. :type schedule_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, @@ -633,24 +628,23 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, schedule_name=schedule_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -661,11 +655,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.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_by_automation_account( @@ -673,11 +663,13 @@ def list_by_automation_account( ) -> Iterable["_models.Schedule"]: """Retrieve a list of schedules. + .. seealso:: + - http://aka.ms/azureautomationsdk/scheduleoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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 Schedule or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.Schedule] :raises ~azure.core.exceptions.HttpResponseError: @@ -685,10 +677,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.ScheduleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -699,24 +691,21 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ScheduleListResult", pipeline_response) @@ -726,10 +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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -741,7 +731,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configuration_machine_runs_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configuration_machine_runs_operations.py index 3ad108e767be..efa75ca387b3 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configuration_machine_runs_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configuration_machine_runs_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, TypeVar +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,20 +18,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -51,7 +50,7 @@ def build_get_by_id_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +69,7 @@ def build_get_by_id_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -97,7 +96,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -113,7 +112,7 @@ def build_list_request( "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -132,7 +131,7 @@ def build_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class SoftwareUpdateConfigurationMachineRunsOperations: +class SoftwareUpdateConfigurationMachineRunsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -162,6 +161,9 @@ def get_by_id( ) -> _models.SoftwareUpdateConfigurationMachineRun: """Get a single software update configuration machine run by Id. + .. seealso:: + - http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -171,12 +173,11 @@ def get_by_id( :type software_update_configuration_machine_run_id: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationMachineRun or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationMachineRun :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -187,25 +188,24 @@ def get_by_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.SoftwareUpdateConfigurationMachineRun] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, software_update_configuration_machine_run_id=software_update_configuration_machine_run_id, subscription_id=self._config.subscription_id, client_request_id=client_request_id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -215,16 +215,12 @@ def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SoftwareUpdateConfigurationMachineRun", pipeline_response) + deserialized = self._deserialize("SoftwareUpdateConfigurationMachineRun", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns/{softwareUpdateConfigurationMachineRunId}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -239,6 +235,9 @@ def list( ) -> _models.SoftwareUpdateConfigurationMachineRunListResult: """Return list of software update configuration machine runs. + .. seealso:: + - http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -254,12 +253,11 @@ def list( :param top: Maximum number of entries returned in the results collection. Default value is None. :type top: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationMachineRunListResult or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationMachineRunListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -270,10 +268,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.SoftwareUpdateConfigurationMachineRunListResult] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, @@ -282,15 +280,14 @@ def list( skip=skip, top=top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -300,13 +297,11 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SoftwareUpdateConfigurationMachineRunListResult", pipeline_response) + deserialized = self._deserialize( + "SoftwareUpdateConfigurationMachineRunListResult", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configuration_runs_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configuration_runs_operations.py index af550b9c2421..3daf46672bde 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configuration_runs_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configuration_runs_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, TypeVar +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,20 +18,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -51,7 +50,7 @@ def build_get_by_id_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +69,7 @@ def build_get_by_id_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -97,7 +96,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -113,7 +112,7 @@ def build_list_request( "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -132,7 +131,7 @@ def build_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class SoftwareUpdateConfigurationRunsOperations: +class SoftwareUpdateConfigurationRunsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -162,6 +161,9 @@ def get_by_id( ) -> _models.SoftwareUpdateConfigurationRun: """Get a single software update configuration Run by Id. + .. seealso:: + - http://aka.ms/azureautomationsdk/softwareupdateconfigurationrunoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -171,12 +173,11 @@ def get_by_id( :type software_update_configuration_run_id: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationRun or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRun :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -187,25 +188,24 @@ def get_by_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.SoftwareUpdateConfigurationRun] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, software_update_configuration_run_id=software_update_configuration_run_id, subscription_id=self._config.subscription_id, client_request_id=client_request_id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -215,16 +215,12 @@ def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SoftwareUpdateConfigurationRun", pipeline_response) + deserialized = self._deserialize("SoftwareUpdateConfigurationRun", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns/{softwareUpdateConfigurationRunId}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -239,6 +235,9 @@ def list( ) -> _models.SoftwareUpdateConfigurationRunListResult: """Return list of software update configuration runs. + .. seealso:: + - http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -254,12 +253,11 @@ def list( :param top: Maximum number of entries returned in the results collection. Default value is None. :type top: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationRunListResult or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRunListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -270,10 +268,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.SoftwareUpdateConfigurationRunListResult] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, @@ -282,15 +280,14 @@ def list( skip=skip, top=top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -300,13 +297,9 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SoftwareUpdateConfigurationRunListResult", pipeline_response) + deserialized = self._deserialize("SoftwareUpdateConfigurationRunListResult", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configurations_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configurations_operations.py index 2fc4294217af..94998903a997 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configurations_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configurations_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,20 +19,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -51,7 +51,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -71,7 +71,7 @@ def build_create_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -98,7 +98,7 @@ def build_get_by_name_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +117,7 @@ def build_get_by_name_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -142,7 +142,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -161,7 +161,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -186,7 +186,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -202,7 +202,7 @@ def build_list_request( "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -250,6 +250,9 @@ def create( ) -> _models.SoftwareUpdateConfiguration: """Create a new software update configuration with the name given in the URI. + .. seealso:: + - http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -264,7 +267,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: SoftwareUpdateConfiguration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfiguration :raises ~azure.core.exceptions.HttpResponseError: @@ -276,7 +278,7 @@ def create( resource_group_name: str, automation_account_name: str, software_update_configuration_name: str, - parameters: IO, + parameters: IO[bytes], client_request_id: Optional[str] = None, *, content_type: str = "application/json", @@ -284,6 +286,9 @@ def create( ) -> _models.SoftwareUpdateConfiguration: """Create a new software update configuration with the name given in the URI. + .. seealso:: + - http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -292,13 +297,12 @@ def create( created. Required. :type software_update_configuration_name: str :param parameters: Request body. Required. - :type parameters: IO + :type parameters: IO[bytes] :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: 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: SoftwareUpdateConfiguration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfiguration :raises ~azure.core.exceptions.HttpResponseError: @@ -310,12 +314,15 @@ def create( resource_group_name: str, automation_account_name: str, software_update_configuration_name: str, - parameters: Union[_models.SoftwareUpdateConfiguration, IO], + parameters: Union[_models.SoftwareUpdateConfiguration, IO[bytes]], client_request_id: Optional[str] = None, **kwargs: Any ) -> _models.SoftwareUpdateConfiguration: """Create a new software update configuration with the name given in the URI. + .. seealso:: + - http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -323,19 +330,16 @@ def create( :param software_update_configuration_name: The name of the software update configuration to be created. Required. :type software_update_configuration_name: str - :param parameters: Request body. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.SoftwareUpdateConfiguration or IO + :param parameters: Request body. Is either a SoftwareUpdateConfiguration type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.automation.models.SoftwareUpdateConfiguration or IO[bytes] :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: 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: SoftwareUpdateConfiguration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -346,19 +350,19 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SoftwareUpdateConfiguration] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SoftwareUpdateConfiguration") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, software_update_configuration_name=software_update_configuration_name, @@ -368,15 +372,14 @@ def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -387,20 +390,16 @@ def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("SoftwareUpdateConfiguration", pipeline_response) + deserialized = self._deserialize("SoftwareUpdateConfiguration", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("SoftwareUpdateConfiguration", pipeline_response) + deserialized = self._deserialize("SoftwareUpdateConfiguration", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}" - } - @distributed_trace def get_by_name( self, @@ -412,6 +411,9 @@ def get_by_name( ) -> _models.SoftwareUpdateConfiguration: """Get a single software update configuration by name. + .. seealso:: + - http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -421,12 +423,11 @@ def get_by_name( :type software_update_configuration_name: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfiguration or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -437,25 +438,24 @@ def get_by_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) cls: ClsType[_models.SoftwareUpdateConfiguration] = kwargs.pop("cls", None) - request = build_get_by_name_request( + _request = build_get_by_name_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, software_update_configuration_name=software_update_configuration_name, subscription_id=self._config.subscription_id, client_request_id=client_request_id, api_version=api_version, - template_url=self.get_by_name.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -465,16 +465,12 @@ def get_by_name( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SoftwareUpdateConfiguration", pipeline_response) + deserialized = self._deserialize("SoftwareUpdateConfiguration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_name.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -487,6 +483,9 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """delete a specific software update configuration. + .. seealso:: + - http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -496,12 +495,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type software_update_configuration_name: str :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_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, @@ -512,25 +510,24 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, software_update_configuration_name=software_update_configuration_name, subscription_id=self._config.subscription_id, client_request_id=client_request_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -541,11 +538,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.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -558,6 +551,9 @@ def list( ) -> _models.SoftwareUpdateConfigurationListResult: """Get all software update configurations for the account. + .. seealso:: + - http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -566,12 +562,11 @@ def list( :type client_request_id: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationListResult or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -582,25 +577,24 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) cls: ClsType[_models.SoftwareUpdateConfigurationListResult] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, client_request_id=client_request_id, 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -610,13 +604,9 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SoftwareUpdateConfigurationListResult", pipeline_response) + deserialized = self._deserialize("SoftwareUpdateConfigurationListResult", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_operations.py index 8c58d2fc5e71..230fc943e65f 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +20,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -50,7 +50,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -68,7 +68,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -91,7 +91,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -109,7 +109,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -132,7 +132,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -149,7 +149,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -170,7 +170,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -187,7 +187,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -209,7 +209,7 @@ def build_list_by_automation_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -225,7 +225,7 @@ def build_list_by_automation_account_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -270,6 +270,9 @@ def create_or_update( ) -> _models.SourceControl: """Create a source control. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontroloperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -282,7 +285,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: SourceControl or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl :raises ~azure.core.exceptions.HttpResponseError: @@ -294,13 +296,16 @@ def create_or_update( resource_group_name: str, automation_account_name: str, source_control_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.SourceControl: """Create a source control. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontroloperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -309,11 +314,10 @@ def create_or_update( :type source_control_name: str :param parameters: The parameters supplied to the create or update source control operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControl or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl :raises ~azure.core.exceptions.HttpResponseError: @@ -325,11 +329,14 @@ def create_or_update( resource_group_name: str, automation_account_name: str, source_control_name: str, - parameters: Union[_models.SourceControlCreateOrUpdateParameters, IO], + parameters: Union[_models.SourceControlCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.SourceControl: """Create a source control. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontroloperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -337,17 +344,14 @@ def create_or_update( :param source_control_name: The source control name. Required. :type source_control_name: str :param parameters: The parameters supplied to the create or update source control operation. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.SourceControlCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 SourceControlCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.SourceControlCreateOrUpdateParameters or + IO[bytes] :return: SourceControl or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,19 +362,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SourceControl] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SourceControlCreateOrUpdateParameters") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, source_control_name=source_control_name, @@ -379,15 +383,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -398,20 +401,16 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("SourceControl", pipeline_response) + deserialized = self._deserialize("SourceControl", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("SourceControl", pipeline_response) + deserialized = self._deserialize("SourceControl", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}" - } - @overload def update( self, @@ -425,6 +424,9 @@ def update( ) -> _models.SourceControl: """Update a source control. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontroloperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -436,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: SourceControl or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl :raises ~azure.core.exceptions.HttpResponseError: @@ -448,13 +449,16 @@ def update( resource_group_name: str, automation_account_name: str, source_control_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.SourceControl: """Update a source control. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontroloperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -462,11 +466,10 @@ def update( :param source_control_name: The source control name. Required. :type source_control_name: str :param parameters: The parameters supplied to the update source control operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControl or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl :raises ~azure.core.exceptions.HttpResponseError: @@ -478,11 +481,14 @@ def update( resource_group_name: str, automation_account_name: str, source_control_name: str, - parameters: Union[_models.SourceControlUpdateParameters, IO], + parameters: Union[_models.SourceControlUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.SourceControl: """Update a source control. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontroloperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -490,17 +496,13 @@ def update( :param source_control_name: The source control name. Required. :type source_control_name: str :param parameters: The parameters supplied to the update source control operation. Is either a - model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.SourceControlUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + SourceControlUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.SourceControlUpdateParameters or IO[bytes] :return: SourceControl or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -511,19 +513,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SourceControl] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SourceControlUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, source_control_name=source_control_name, @@ -532,15 +534,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -550,16 +551,12 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SourceControl", pipeline_response) + deserialized = self._deserialize("SourceControl", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -567,18 +564,20 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the source control. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontroloperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param source_control_name: The name of source control. Required. :type source_control_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, @@ -589,24 +588,23 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, source_control_name=source_control_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -617,11 +615,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.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -629,18 +623,20 @@ def get( ) -> _models.SourceControl: """Retrieve the source control identified by source control name. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontroloperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param source_control_name: The name of source control. Required. :type source_control_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControl or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -651,24 +647,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.SourceControl] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, source_control_name=source_control_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -678,16 +673,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SourceControl", pipeline_response) + deserialized = self._deserialize("SourceControl", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -695,13 +686,15 @@ def list_by_automation_account( ) -> Iterable["_models.SourceControl"]: """Retrieve a list of source controls. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontroloperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param filter: The filter to apply on the operation. 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 SourceControl or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.SourceControl] :raises ~azure.core.exceptions.HttpResponseError: @@ -709,10 +702,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.SourceControlListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -723,25 +716,22 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SourceControlListResult", pipeline_response) @@ -751,10 +741,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -766,7 +757,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_sync_job_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_sync_job_operations.py index 0c41e15aa9d1..b587676bf60d 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_sync_job_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_sync_job_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +20,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -51,7 +51,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -70,7 +70,7 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -94,7 +94,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -112,7 +112,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -135,7 +135,7 @@ def build_list_by_automation_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -152,7 +152,7 @@ def build_list_by_automation_account_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -198,6 +198,9 @@ def create( ) -> _models.SourceControlSyncJob: """Creates the sync job for a source control. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontrolsyncjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -212,7 +215,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: SourceControlSyncJob or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControlSyncJob :raises ~azure.core.exceptions.HttpResponseError: @@ -225,13 +227,16 @@ def create( automation_account_name: str, source_control_name: str, source_control_sync_job_id: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.SourceControlSyncJob: """Creates the sync job for a source control. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontrolsyncjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -242,11 +247,10 @@ def create( :type source_control_sync_job_id: str :param parameters: The parameters supplied to the create source control sync job operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControlSyncJob or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControlSyncJob :raises ~azure.core.exceptions.HttpResponseError: @@ -259,11 +263,14 @@ def create( automation_account_name: str, source_control_name: str, source_control_sync_job_id: str, - parameters: Union[_models.SourceControlSyncJobCreateParameters, IO], + parameters: Union[_models.SourceControlSyncJobCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.SourceControlSyncJob: """Creates the sync job for a source control. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontrolsyncjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -273,17 +280,14 @@ def create( :param source_control_sync_job_id: The source control sync job id. Required. :type source_control_sync_job_id: str :param parameters: The parameters supplied to the create source control sync job operation. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.SourceControlSyncJobCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 SourceControlSyncJobCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.SourceControlSyncJobCreateParameters or + IO[bytes] :return: SourceControlSyncJob or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControlSyncJob :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -294,19 +298,19 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SourceControlSyncJob] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SourceControlSyncJobCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, source_control_name=source_control_name, @@ -316,15 +320,14 @@ def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -334,16 +337,12 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SourceControlSyncJob", pipeline_response) + deserialized = self._deserialize("SourceControlSyncJob", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -356,6 +355,9 @@ def get( ) -> _models.SourceControlSyncJobById: """Retrieve the source control sync job identified by job id. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontrolsyncjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -364,12 +366,11 @@ def get( :type source_control_name: str :param source_control_sync_job_id: The source control sync job id. Required. :type source_control_sync_job_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControlSyncJobById or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControlSyncJobById :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -380,25 +381,24 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.SourceControlSyncJobById] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, source_control_name=source_control_name, source_control_sync_job_id=source_control_sync_job_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -408,16 +408,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SourceControlSyncJobById", pipeline_response) + deserialized = self._deserialize("SourceControlSyncJobById", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -430,6 +426,9 @@ def list_by_automation_account( ) -> Iterable["_models.SourceControlSyncJob"]: """Retrieve a list of source control sync jobs. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontrolsyncjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -438,7 +437,6 @@ def list_by_automation_account( :type source_control_name: str :param filter: The filter to apply on the operation. 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 SourceControlSyncJob or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.SourceControlSyncJob] @@ -447,10 +445,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.SourceControlSyncJobListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -461,26 +459,23 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, source_control_name=source_control_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SourceControlSyncJobListResult", pipeline_response) @@ -490,10 +485,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -505,7 +501,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_sync_job_streams_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_sync_job_streams_operations.py index 314e759b1941..eed09e271e15 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_sync_job_streams_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_sync_job_streams_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +19,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -53,7 +52,7 @@ def build_list_by_sync_job_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +70,7 @@ def build_list_by_sync_job_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -96,7 +95,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -115,7 +114,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -157,6 +156,9 @@ def list_by_sync_job( ) -> Iterable["_models.SourceControlSyncJobStream"]: """Retrieve a list of sync job streams identified by sync job id. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontrolsyncjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -167,7 +169,6 @@ def list_by_sync_job( :type source_control_sync_job_id: str :param filter: The filter to apply on the operation. 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 SourceControlSyncJobStream or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.SourceControlSyncJobStream] @@ -176,10 +177,10 @@ def list_by_sync_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.SourceControlSyncJobStreamsListBySyncJob] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,7 +191,7 @@ def list_by_sync_job( def prepare_request(next_link=None): if not next_link: - request = build_list_by_sync_job_request( + _request = build_list_by_sync_job_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, source_control_name=source_control_name, @@ -198,19 +199,16 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_sync_job.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SourceControlSyncJobStreamsListBySyncJob", pipeline_response) @@ -220,10 +218,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -236,10 +235,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_sync_job.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams" - } - @distributed_trace def get( self, @@ -252,6 +247,9 @@ def get( ) -> _models.SourceControlSyncJobStreamById: """Retrieve a sync job stream identified by stream id. + .. seealso:: + - http://aka.ms/azureautomationsdk/sourcecontrolsyncjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -262,12 +260,11 @@ def get( :type source_control_sync_job_id: str :param stream_id: The id of the sync job stream. Required. :type stream_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControlSyncJobStreamById or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControlSyncJobStreamById :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -278,10 +275,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.SourceControlSyncJobStreamById] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, source_control_name=source_control_name, @@ -289,15 +286,14 @@ def get( stream_id=stream_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -307,13 +303,9 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SourceControlSyncJobStreamById", pipeline_response) + deserialized = self._deserialize("SourceControlSyncJobStreamById", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams/{streamId}" - } + return deserialized # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_statistics_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_statistics_operations.py index c55349c27844..5ce830f890ec 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_statistics_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_statistics_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +19,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -51,7 +50,7 @@ def build_list_by_automation_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -67,7 +66,7 @@ def build_list_by_automation_account_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -105,13 +104,15 @@ def list_by_automation_account( ) -> Iterable["_models.Statistics"]: """Retrieve the statistics for the account. + .. seealso:: + - http://aka.ms/azureautomationsdk/statisticsoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param filter: The filter to apply on the operation. 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 Statistics or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.Statistics] :raises ~azure.core.exceptions.HttpResponseError: @@ -119,10 +120,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.StatisticsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -133,25 +134,22 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StatisticsListResult", pipeline_response) @@ -161,10 +159,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -176,7 +175,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/statistics" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_test_job_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_test_job_operations.py index f9f05316a2c7..0e1e7ce715cb 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_test_job_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_test_job_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,20 +19,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -45,7 +45,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -60,10 +60,10 @@ def build_create_request( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._]+$" ), "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, "str"), - "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z]*-*[a-zA-Z0-9]*$"), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-_0-9]*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -82,7 +82,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -96,10 +96,10 @@ def build_get_request( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._]+$" ), "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, "str"), - "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z]*-*[a-zA-Z0-9]*$"), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-_0-9]*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,7 +116,7 @@ def build_resume_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -130,10 +130,10 @@ def build_resume_request( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._]+$" ), "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, "str"), - "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z]*-*[a-zA-Z0-9]*$"), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-_0-9]*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -150,7 +150,7 @@ def build_stop_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -164,10 +164,10 @@ def build_stop_request( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._]+$" ), "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, "str"), - "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z]*-*[a-zA-Z0-9]*$"), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-_0-9]*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -184,7 +184,7 @@ def build_suspend_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -198,10 +198,10 @@ def build_suspend_request( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._]+$" ), "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, "str"), - "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z]*-*[a-zA-Z0-9]*$"), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-_0-9]*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -244,6 +244,9 @@ def create( ) -> _models.TestJob: """Create a test job of the runbook. + .. seealso:: + - http://aka.ms/azureautomationsdk/testjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -255,7 +258,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: TestJob or the result of cls(response) :rtype: ~azure.mgmt.automation.models.TestJob :raises ~azure.core.exceptions.HttpResponseError: @@ -267,13 +269,16 @@ def create( resource_group_name: str, automation_account_name: str, runbook_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.TestJob: """Create a test job of the runbook. + .. seealso:: + - http://aka.ms/azureautomationsdk/testjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -281,11 +286,10 @@ def create( :param runbook_name: The parameters supplied to the create test job operation. Required. :type runbook_name: str :param parameters: The parameters supplied to the create test job operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TestJob or the result of cls(response) :rtype: ~azure.mgmt.automation.models.TestJob :raises ~azure.core.exceptions.HttpResponseError: @@ -297,29 +301,28 @@ def create( resource_group_name: str, automation_account_name: str, runbook_name: str, - parameters: Union[_models.TestJobCreateParameters, IO], + parameters: Union[_models.TestJobCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.TestJob: """Create a test job of the runbook. + .. seealso:: + - http://aka.ms/azureautomationsdk/testjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The parameters supplied to the create test job operation. Required. :type runbook_name: str - :param parameters: The parameters supplied to the create test job operation. Is either a model - type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.TestJobCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 supplied to the create test job operation. Is either a + TestJobCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.TestJobCreateParameters or IO[bytes] :return: TestJob or the result of cls(response) :rtype: ~azure.mgmt.automation.models.TestJob :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -330,19 +333,19 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestJob] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "TestJobCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, @@ -351,15 +354,14 @@ def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,16 +371,12 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("TestJob", pipeline_response) + deserialized = self._deserialize("TestJob", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob" - } + return deserialized # type: ignore @distributed_trace def get( @@ -386,18 +384,20 @@ def get( ) -> _models.TestJob: """Retrieve the test job for the specified runbook. + .. seealso:: + - http://aka.ms/azureautomationsdk/testjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The runbook name. Required. :type runbook_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TestJob or the result of cls(response) :rtype: ~azure.mgmt.automation.models.TestJob :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -408,24 +408,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.TestJob] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -435,16 +434,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("TestJob", pipeline_response) + deserialized = self._deserialize("TestJob", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob" - } + return deserialized # type: ignore @distributed_trace def resume( # pylint: disable=inconsistent-return-statements @@ -452,18 +447,20 @@ def resume( # pylint: disable=inconsistent-return-statements ) -> None: """Resume the test job. + .. seealso:: + - http://aka.ms/azureautomationsdk/testjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The runbook name. Required. :type runbook_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,24 +471,23 @@ def resume( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_resume_request( + _request = build_resume_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.resume.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -502,11 +498,7 @@ def resume( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - resume.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/resume" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def stop( # pylint: disable=inconsistent-return-statements @@ -514,18 +506,20 @@ def stop( # pylint: disable=inconsistent-return-statements ) -> None: """Stop the test job. + .. seealso:: + - http://aka.ms/azureautomationsdk/testjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The runbook name. Required. :type runbook_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, @@ -536,24 +530,23 @@ def stop( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -564,11 +557,7 @@ def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/stop" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def suspend( # pylint: disable=inconsistent-return-statements @@ -576,18 +565,20 @@ def suspend( # pylint: disable=inconsistent-return-statements ) -> None: """Suspend the test job. + .. seealso:: + - http://aka.ms/azureautomationsdk/testjoboperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param runbook_name: The runbook name. Required. :type runbook_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, @@ -598,24 +589,23 @@ def suspend( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_suspend_request( + _request = build_suspend_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.suspend.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -626,8 +616,4 @@ def suspend( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - suspend.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/suspend" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_test_job_streams_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_test_job_streams_operations.py index e20b0d12c927..6ddebe5f6c4a 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_test_job_streams_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_test_job_streams_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +19,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -51,7 +50,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -65,11 +64,11 @@ def build_get_request( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._]+$" ), "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, "str"), - "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z]*-*[a-zA-Z0-9]*$"), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-_0-9]*$"), "jobStreamId": _SERIALIZER.url("job_stream_id", job_stream_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -92,7 +91,7 @@ def build_list_by_test_job_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -106,10 +105,10 @@ def build_list_by_test_job_request( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._]+$" ), "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, "str"), - "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z]*-*[a-zA-Z0-9]*$"), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, "str", pattern=r"^[a-zA-Z][a-zA-Z-_0-9]*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -152,6 +151,9 @@ def get( ) -> _models.JobStream: """Retrieve a test job stream of the test job identified by runbook name and stream id. + .. seealso:: + - http://aka.ms/azureautomationsdk/jobstreamoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -160,12 +162,11 @@ def get( :type runbook_name: str :param job_stream_id: The job stream id. Required. :type job_stream_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: JobStream or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobStream :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -176,25 +177,24 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.JobStream] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, job_stream_id=job_stream_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -204,16 +204,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("JobStream", pipeline_response) + deserialized = self._deserialize("JobStream", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams/{jobStreamId}" - } + return deserialized # type: ignore @distributed_trace def list_by_test_job( @@ -226,6 +222,9 @@ def list_by_test_job( ) -> Iterable["_models.JobStream"]: """Retrieve a list of test job streams identified by runbook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/jobstreamoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -234,7 +233,6 @@ def list_by_test_job( :type runbook_name: str :param filter: The filter to apply on the operation. 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 JobStream or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.JobStream] :raises ~azure.core.exceptions.HttpResponseError: @@ -242,10 +240,10 @@ def list_by_test_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.JobStreamListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -256,26 +254,23 @@ def list_by_test_job( def prepare_request(next_link=None): if not next_link: - request = build_list_by_test_job_request( + _request = build_list_by_test_job_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_test_job.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("JobStreamListResult", pipeline_response) @@ -285,10 +280,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -300,7 +296,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_test_job.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_usages_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_usages_operations.py index 46d2b4c00a69..9fdcf9684047 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_usages_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/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. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +19,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -46,7 +45,7 @@ def build_list_by_automation_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,7 +61,7 @@ def build_list_by_automation_account_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -98,11 +97,13 @@ def list_by_automation_account( ) -> Iterable["_models.Usage"]: """Retrieve the usage for the account id. + .. seealso:: + - http://aka.ms/azureautomationsdk/usageoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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 Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -110,10 +111,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -124,24 +125,21 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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,10 +149,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -166,7 +165,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/usages" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_variable_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_variable_operations.py index 33b9118074cf..f4b38cdef302 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_variable_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_variable_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +20,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -46,7 +46,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -64,7 +64,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +83,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -101,7 +101,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -120,7 +120,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -137,7 +137,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,7 +154,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -171,7 +171,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -188,7 +188,7 @@ def build_list_by_automation_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -204,7 +204,7 @@ def build_list_by_automation_account_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -247,6 +247,9 @@ def create_or_update( ) -> _models.Variable: """Create a variable. + .. seealso:: + - http://aka.ms/azureautomationsdk/variableoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -259,7 +262,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: Variable or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable :raises ~azure.core.exceptions.HttpResponseError: @@ -271,13 +273,16 @@ def create_or_update( resource_group_name: str, automation_account_name: str, variable_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Variable: """Create a variable. + .. seealso:: + - http://aka.ms/azureautomationsdk/variableoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -286,11 +291,10 @@ def create_or_update( :type variable_name: str :param parameters: The parameters supplied to the create or update variable operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Variable or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable :raises ~azure.core.exceptions.HttpResponseError: @@ -302,11 +306,14 @@ def create_or_update( resource_group_name: str, automation_account_name: str, variable_name: str, - parameters: Union[_models.VariableCreateOrUpdateParameters, IO], + parameters: Union[_models.VariableCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Variable: """Create a variable. + .. seealso:: + - http://aka.ms/azureautomationsdk/variableoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -314,17 +321,13 @@ def create_or_update( :param variable_name: The variable name. Required. :type variable_name: str :param parameters: The parameters supplied to the create or update variable operation. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.VariableCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 VariableCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.VariableCreateOrUpdateParameters or IO[bytes] :return: Variable or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -335,19 +338,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Variable] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "VariableCreateOrUpdateParameters") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, variable_name=variable_name, @@ -356,15 +359,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -375,20 +377,16 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("Variable", pipeline_response) + deserialized = self._deserialize("Variable", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("Variable", pipeline_response) + deserialized = self._deserialize("Variable", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}" - } - @overload def update( self, @@ -402,6 +400,9 @@ def update( ) -> _models.Variable: """Update a variable. + .. seealso:: + - http://aka.ms/azureautomationsdk/variableoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -413,7 +414,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: Variable or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable :raises ~azure.core.exceptions.HttpResponseError: @@ -425,13 +425,16 @@ def update( resource_group_name: str, automation_account_name: str, variable_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Variable: """Update a variable. + .. seealso:: + - http://aka.ms/azureautomationsdk/variableoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -439,11 +442,10 @@ def update( :param variable_name: The variable name. Required. :type variable_name: str :param parameters: The parameters supplied to the update variable operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Variable or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable :raises ~azure.core.exceptions.HttpResponseError: @@ -455,29 +457,28 @@ def update( resource_group_name: str, automation_account_name: str, variable_name: str, - parameters: Union[_models.VariableUpdateParameters, IO], + parameters: Union[_models.VariableUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Variable: """Update a variable. + .. seealso:: + - http://aka.ms/azureautomationsdk/variableoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param variable_name: The variable name. Required. :type variable_name: str - :param parameters: The parameters supplied to the update variable operation. Is either a model - type or a IO type. Required. - :type parameters: ~azure.mgmt.automation.models.VariableUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 supplied to the update variable operation. Is either a + VariableUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.VariableUpdateParameters or IO[bytes] :return: Variable or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -488,19 +489,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Variable] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "VariableUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, variable_name=variable_name, @@ -509,15 +510,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -527,16 +527,12 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Variable", pipeline_response) + deserialized = self._deserialize("Variable", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/variables/{variableName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -544,18 +540,20 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the variable. + .. seealso:: + - http://aka.ms/azureautomationsdk/variableoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param variable_name: The name of variable. Required. :type variable_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, @@ -566,24 +564,23 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, variable_name=variable_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -594,11 +591,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.Automation/automationAccounts/{automationAccountName}/variables/{variableName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -606,18 +599,20 @@ def get( ) -> _models.Variable: """Retrieve the variable identified by variable name. + .. seealso:: + - http://aka.ms/azureautomationsdk/variableoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param variable_name: The name of variable. Required. :type variable_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Variable or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -628,24 +623,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.Variable] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, variable_name=variable_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -655,16 +649,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Variable", pipeline_response) + deserialized = self._deserialize("Variable", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -672,11 +662,13 @@ def list_by_automation_account( ) -> Iterable["_models.Variable"]: """Retrieve a list of variables. + .. seealso:: + - http://aka.ms/azureautomationsdk/variableoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_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 Variable or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.Variable] :raises ~azure.core.exceptions.HttpResponseError: @@ -684,10 +676,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2022-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) cls: ClsType[_models.VariableListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -698,24 +690,21 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("VariableListResult", pipeline_response) @@ -725,10 +714,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -740,7 +730,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_watcher_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_watcher_operations.py index 66097fe791af..5d032c77eab3 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_watcher_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_watcher_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +20,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -46,9 +46,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -66,7 +64,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -85,9 +83,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -104,7 +100,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -121,9 +117,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -141,7 +135,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -160,9 +154,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -179,7 +171,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -196,9 +188,7 @@ def build_start_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -215,7 +205,7 @@ def build_start_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -232,9 +222,7 @@ def build_stop_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -251,7 +239,7 @@ def build_stop_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -273,9 +261,7 @@ def build_list_by_automation_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -291,7 +277,7 @@ def build_list_by_automation_account_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -336,6 +322,9 @@ def create_or_update( ) -> _models.Watcher: """Create the watcher identified by watcher name. + .. seealso:: + - http://aka.ms/azureautomationsdk/watcheroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -347,7 +336,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: Watcher or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher :raises ~azure.core.exceptions.HttpResponseError: @@ -359,13 +347,16 @@ def create_or_update( resource_group_name: str, automation_account_name: str, watcher_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Watcher: """Create the watcher identified by watcher name. + .. seealso:: + - http://aka.ms/azureautomationsdk/watcheroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -373,11 +364,10 @@ def create_or_update( :param watcher_name: The watcher name. Required. :type watcher_name: str :param parameters: The create or update parameters for watcher. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Watcher or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher :raises ~azure.core.exceptions.HttpResponseError: @@ -389,29 +379,28 @@ def create_or_update( resource_group_name: str, automation_account_name: str, watcher_name: str, - parameters: Union[_models.Watcher, IO], + parameters: Union[_models.Watcher, IO[bytes]], **kwargs: Any ) -> _models.Watcher: """Create the watcher identified by watcher name. + .. seealso:: + - http://aka.ms/azureautomationsdk/watcheroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param watcher_name: The watcher name. Required. :type watcher_name: str - :param parameters: The create or update parameters for watcher. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.automation.models.Watcher or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 create or update parameters for watcher. Is either a Watcher type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.Watcher or IO[bytes] :return: Watcher or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -422,21 +411,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Watcher] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Watcher") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, watcher_name=watcher_name, @@ -445,15 +432,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -464,38 +450,36 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("Watcher", pipeline_response) + deserialized = self._deserialize("Watcher", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("Watcher", pipeline_response) + deserialized = self._deserialize("Watcher", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}" - } - @distributed_trace def get( self, resource_group_name: str, automation_account_name: str, watcher_name: str, **kwargs: Any ) -> _models.Watcher: """Retrieve the watcher identified by watcher name. + .. seealso:: + - http://aka.ms/azureautomationsdk/watcheroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param watcher_name: The watcher name. Required. :type watcher_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Watcher or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -506,26 +490,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.Watcher] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, watcher_name=watcher_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -535,16 +516,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Watcher", pipeline_response) + deserialized = self._deserialize("Watcher", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}" - } + return deserialized # type: ignore @overload def update( @@ -559,6 +536,9 @@ def update( ) -> _models.Watcher: """Update the watcher identified by watcher name. + .. seealso:: + - http://aka.ms/azureautomationsdk/watcheroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -570,7 +550,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: Watcher or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher :raises ~azure.core.exceptions.HttpResponseError: @@ -582,13 +561,16 @@ def update( resource_group_name: str, automation_account_name: str, watcher_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Watcher: """Update the watcher identified by watcher name. + .. seealso:: + - http://aka.ms/azureautomationsdk/watcheroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -596,11 +578,10 @@ def update( :param watcher_name: The watcher name. Required. :type watcher_name: str :param parameters: The update parameters for watcher. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Watcher or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher :raises ~azure.core.exceptions.HttpResponseError: @@ -612,29 +593,28 @@ def update( resource_group_name: str, automation_account_name: str, watcher_name: str, - parameters: Union[_models.WatcherUpdateParameters, IO], + parameters: Union[_models.WatcherUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Watcher: """Update the watcher identified by watcher name. + .. seealso:: + - http://aka.ms/azureautomationsdk/watcheroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param watcher_name: The watcher name. Required. :type watcher_name: str - :param parameters: The update parameters for watcher. Is either a model type or a IO type. - Required. - :type parameters: ~azure.mgmt.automation.models.WatcherUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 update parameters for watcher. Is either a WatcherUpdateParameters type + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.WatcherUpdateParameters or IO[bytes] :return: Watcher or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -645,21 +625,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Watcher] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "WatcherUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, watcher_name=watcher_name, @@ -668,15 +646,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -686,16 +663,12 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Watcher", pipeline_response) + deserialized = self._deserialize("Watcher", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -703,18 +676,20 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the watcher by name. + .. seealso:: + - http://aka.ms/azureautomationsdk/watcheroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param watcher_name: The watcher name. Required. :type watcher_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, @@ -725,26 +700,23 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, watcher_name=watcher_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -755,11 +727,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.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def start( # pylint: disable=inconsistent-return-statements @@ -767,18 +735,20 @@ def start( # pylint: disable=inconsistent-return-statements ) -> None: """Resume the watcher identified by watcher name. + .. seealso:: + - http://aka.ms/azureautomationsdk/watcheroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param watcher_name: The watcher name. Required. :type watcher_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, @@ -789,26 +759,23 @@ def start( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_start_request( + _request = build_start_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, watcher_name=watcher_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.start.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -819,11 +786,7 @@ def start( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - start.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/start" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def stop( # pylint: disable=inconsistent-return-statements @@ -831,18 +794,20 @@ def stop( # pylint: disable=inconsistent-return-statements ) -> None: """Resume the watcher identified by watcher name. + .. seealso:: + - http://aka.ms/azureautomationsdk/watcheroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param watcher_name: The watcher name. Required. :type watcher_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, @@ -853,26 +818,23 @@ def stop( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, watcher_name=watcher_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -883,11 +845,7 @@ def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_by_automation_account( @@ -895,13 +853,15 @@ def list_by_automation_account( ) -> Iterable["_models.Watcher"]: """Retrieve a list of watchers. + .. seealso:: + - http://aka.ms/azureautomationsdk/watcheroperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param filter: The filter to apply on the operation. 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 Watcher or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.Watcher] :raises ~azure.core.exceptions.HttpResponseError: @@ -909,12 +869,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-01-13-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-01-13-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-13-preview")) cls: ClsType[_models.WatcherListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -925,25 +883,22 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WatcherListResult", pipeline_response) @@ -953,10 +908,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -968,7 +924,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers" - } diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_webhook_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_webhook_operations.py index d738fc7d1b05..a3d92c6871fd 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_webhook_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_webhook_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # 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, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +20,19 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import AutomationClientMixinABC, _convert_request, _format_url_section +from .._vendor import AutomationClientMixinABC -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]] @@ -46,7 +46,7 @@ def build_generate_uri_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2015-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,7 +62,7 @@ def build_generate_uri_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -79,7 +79,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2015-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -96,7 +96,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -113,7 +113,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2015-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -130,7 +130,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -147,7 +147,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2015-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -165,7 +165,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -184,7 +184,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2015-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -202,7 +202,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -226,7 +226,7 @@ def build_list_by_automation_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2015-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -242,7 +242,7 @@ def build_list_by_automation_account_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -278,16 +278,18 @@ def __init__(self, *args, **kwargs): def generate_uri(self, resource_group_name: str, automation_account_name: str, **kwargs: Any) -> str: """Generates a Uri for use in creating a webhook. + .. seealso:: + - http://aka.ms/azureautomationsdk/webhookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: str or the result of cls(response) :rtype: str :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -298,23 +300,22 @@ def generate_uri(self, resource_group_name: str, automation_account_name: str, * _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2015-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) cls: ClsType[str] = kwargs.pop("cls", None) - request = build_generate_uri_request( + _request = build_generate_uri_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.generate_uri.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -324,16 +325,12 @@ def generate_uri(self, resource_group_name: str, automation_account_name: str, * error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("str", pipeline_response) + deserialized = self._deserialize("str", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - generate_uri.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/generateUri" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -341,18 +338,20 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Delete the webhook by name. + .. seealso:: + - http://aka.ms/azureautomationsdk/webhookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param webhook_name: The webhook name. Required. :type webhook_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, @@ -363,24 +362,23 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2015-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, webhook_name=webhook_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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -391,11 +389,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.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -403,18 +397,20 @@ def get( ) -> _models.Webhook: """Retrieve the webhook identified by webhook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/webhookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param webhook_name: The webhook name. Required. :type webhook_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -425,24 +421,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2015-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, webhook_name=webhook_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -452,16 +447,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Webhook", pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -476,6 +467,9 @@ def create_or_update( ) -> _models.Webhook: """Create the webhook identified by webhook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/webhookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -487,7 +481,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: Webhook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook :raises ~azure.core.exceptions.HttpResponseError: @@ -499,13 +492,16 @@ def create_or_update( resource_group_name: str, automation_account_name: str, webhook_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Webhook: """Create the webhook identified by webhook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/webhookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -513,11 +509,10 @@ def create_or_update( :param webhook_name: The webhook name. Required. :type webhook_name: str :param parameters: The create or update parameters for webhook. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook :raises ~azure.core.exceptions.HttpResponseError: @@ -529,29 +524,28 @@ def create_or_update( resource_group_name: str, automation_account_name: str, webhook_name: str, - parameters: Union[_models.WebhookCreateOrUpdateParameters, IO], + parameters: Union[_models.WebhookCreateOrUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Webhook: """Create the webhook identified by webhook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/webhookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param webhook_name: The webhook name. Required. :type webhook_name: str - :param parameters: The create or update parameters for webhook. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.automation.models.WebhookCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 create or update parameters for webhook. Is either a + WebhookCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.WebhookCreateOrUpdateParameters or IO[bytes] :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -562,19 +556,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2015-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "WebhookCreateOrUpdateParameters") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, webhook_name=webhook_name, @@ -583,15 +577,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -602,20 +595,16 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("Webhook", pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("Webhook", pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}" - } - @overload def update( self, @@ -629,6 +618,9 @@ def update( ) -> _models.Webhook: """Update the webhook identified by webhook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/webhookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -640,7 +632,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: Webhook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook :raises ~azure.core.exceptions.HttpResponseError: @@ -652,13 +643,16 @@ def update( resource_group_name: str, automation_account_name: str, webhook_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Webhook: """Update the webhook identified by webhook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/webhookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. @@ -666,11 +660,10 @@ def update( :param webhook_name: The webhook name. Required. :type webhook_name: str :param parameters: The update parameters for webhook. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook :raises ~azure.core.exceptions.HttpResponseError: @@ -682,29 +675,28 @@ def update( resource_group_name: str, automation_account_name: str, webhook_name: str, - parameters: Union[_models.WebhookUpdateParameters, IO], + parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Webhook: """Update the webhook identified by webhook name. + .. seealso:: + - http://aka.ms/azureautomationsdk/webhookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param webhook_name: The webhook name. Required. :type webhook_name: str - :param parameters: The update parameters for webhook. Is either a model type or a IO type. - Required. - :type parameters: ~azure.mgmt.automation.models.WebhookUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 update parameters for webhook. Is either a WebhookUpdateParameters type + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.automation.models.WebhookUpdateParameters or IO[bytes] :return: Webhook or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -715,19 +707,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2015-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Webhook] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "WebhookUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, webhook_name=webhook_name, @@ -736,15 +728,14 @@ 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.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -754,16 +745,12 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Webhook", pipeline_response) + deserialized = self._deserialize("Webhook", pipeline_response.http_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.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}" - } + return deserialized # type: ignore @distributed_trace def list_by_automation_account( @@ -771,13 +758,15 @@ def list_by_automation_account( ) -> Iterable["_models.Webhook"]: """Retrieve a list of webhooks. + .. seealso:: + - http://aka.ms/azureautomationsdk/webhookoperations + :param resource_group_name: Name of an Azure Resource group. Required. :type resource_group_name: str :param automation_account_name: The name of the automation account. Required. :type automation_account_name: str :param filter: The filter to apply on the operation. 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 Webhook or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.Webhook] :raises ~azure.core.exceptions.HttpResponseError: @@ -785,10 +774,10 @@ def list_by_automation_account( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2015-10-31"] = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-10-31")) cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -799,25 +788,22 @@ def list_by_automation_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_automation_account_request( + _request = build_list_by_automation_account_request( resource_group_name=resource_group_name, automation_account_name=automation_account_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_automation_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WebhookListResult", pipeline_response) @@ -827,10 +813,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -842,7 +829,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_automation_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks" - } diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/compilation_job_stream_by_job_stream_id.py b/sdk/automation/azure-mgmt-automation/generated_samples/compilation_job_stream_by_job_stream_id.py index 266d0219775e..0370d2121cfc 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/compilation_job_stream_by_job_stream_id.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/compilation_job_stream_by_job_stream_id.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/compilation_job_stream_list.py b/sdk/automation/azure-mgmt-automation/generated_samples/compilation_job_stream_list.py index 40ed8e037890..69fac35af76b 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/compilation_job_stream_list.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/compilation_job_stream_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/create_compilation_job.py b/sdk/automation/azure-mgmt-automation/generated_samples/create_compilation_job.py index b5c4c5affb90..6c12c3313852 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/create_compilation_job.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/create_compilation_job.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.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/create_job_schedule.py b/sdk/automation/azure-mgmt-automation/generated_samples/create_job_schedule.py index a4d2d569874f..6b31e5628386 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/create_job_schedule.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/create_job_schedule.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.automation import AutomationClient """ @@ -44,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/createJobSchedule.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/createJobSchedule.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_automation_account.py b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_automation_account.py index d097bf32b265..c81a4d658d88 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_automation_account.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_automation_account.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.automation import AutomationClient """ @@ -37,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/createOrUpdateAutomationAccount.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/createOrUpdateAutomationAccount.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_certificate.py b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_certificate.py index cca079c0d201..b66d439d7055 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_certificate.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_certificate.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.automation import AutomationClient """ @@ -46,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/createOrUpdateCertificate.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/createOrUpdateCertificate.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_connection.py b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_connection.py index 03a424b2e7db..83bfbbaeb1d6 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_connection.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_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.automation import AutomationClient """ @@ -45,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/createOrUpdateConnection.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/createOrUpdateConnection.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_connection_type.py b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_connection_type.py index 184d6e8603ad..f9925df8678c 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_connection_type.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_connection_type.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.automation import AutomationClient """ @@ -48,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/createOrUpdateConnectionType.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/createOrUpdateConnectionType.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_credential.py b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_credential.py index 2fa852a415c4..fa1186dd8688 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_credential.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_credential.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.automation import AutomationClient """ @@ -45,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/createOrUpdateCredential.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/createOrUpdateCredential.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_dsc_configuration.py b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_dsc_configuration.py index 73adef8439d4..3b443847c5a5 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_dsc_configuration.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_dsc_configuration.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -52,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/createOrUpdateDscConfiguration.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/createOrUpdateDscConfiguration.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_dsc_node_configuration.py b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_dsc_node_configuration.py index 5b8c55268bcb..80553097c462 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_dsc_node_configuration.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_dsc_node_configuration.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.automation import AutomationClient """ @@ -53,6 +56,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/createOrUpdateDscNodeConfiguration.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/createOrUpdateDscNodeConfiguration.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_module.py b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_module.py index 591f109ce076..9b5a24073c7f 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_module.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_module.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.automation import AutomationClient """ @@ -29,7 +32,7 @@ def main(): subscription_id="subid", ) - response = client.module.create_or_update( + response = client.module.begin_create_or_update( resource_group_name="rg", automation_account_name="myAutomationAccount33", module_name="OmsCompositeResources", @@ -45,10 +48,10 @@ def main(): } } }, - ) + ).result() print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/createOrUpdateModule.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/createOrUpdateModule.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_power_shell72_module.py b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_power_shell72_module.py new file mode 100644 index 000000000000..3ebf1143b15a --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_power_shell72_module.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.automation import AutomationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-automation +# USAGE + python create_or_update_power_shell72_module.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 = AutomationClient( + credential=DefaultAzureCredential(), + subscription_id="a6ddc3c0-ed18-45d9-9cae-d91644c46eb1", + ) + + response = client.power_shell72_module.begin_create_or_update( + resource_group_name="rg", + automation_account_name="myAutomationAccount33", + module_name="OmsCompositeResources", + parameters={ + "properties": { + "contentLink": { + "contentHash": { + "algorithm": "sha265", + "value": "07E108A962B81DD9C9BAA89BB47C0F6EE52B29E83758B07795E408D258B2B87B", + }, + "uri": "https://teststorage.blob.core.windows.net/dsccomposite/OmsCompositeResources.zip", + "version": "1.0.0.0", + } + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/createOrUpdatePowerShell72Module.json +if __name__ == "__main__": + main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_python2_package.py b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_python2_package.py index 7a9980c27184..76ee03f13b30 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_python2_package.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_python2_package.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.automation import AutomationClient """ @@ -50,6 +53,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/createOrUpdatePython2Package.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/createOrUpdatePython2Package.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_python3_package.py b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_python3_package.py index 05ebdbeca55d..42f6a22a5350 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_python3_package.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_python3_package.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.automation import AutomationClient """ @@ -29,7 +32,7 @@ def main(): subscription_id="subid", ) - response = client.python3_package.create_or_update( + response = client.python3_package.begin_create_or_update( resource_group_name="rg", automation_account_name="myAutomationAccount33", package_name="OmsCompositeResources", @@ -46,10 +49,10 @@ def main(): }, "tags": {}, }, - ) + ).result() print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/createOrUpdatePython3Package.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/createOrUpdatePython3Package.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_runbook.py b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_runbook.py index 3b8805b3d1b3..4893d1026195 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_runbook.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_runbook.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.automation import AutomationClient """ @@ -56,6 +59,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/createOrUpdateRunbook.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/createOrUpdateRunbook.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_schedule.py b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_schedule.py index 19499d40910d..8d0f171e638e 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_schedule.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_schedule.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.automation import AutomationClient """ @@ -48,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/createOrUpdateSchedule.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/createOrUpdateSchedule.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_variable.py b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_variable.py index 78e18fc4d9d0..d5d5f20eefc1 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_variable.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_variable.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.automation import AutomationClient """ @@ -41,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/createOrUpdateVariable.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/createOrUpdateVariable.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_watcher.py b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_watcher.py index 666c1997f5ad..2846dde834ad 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_watcher.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_watcher.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.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_webhook.py b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_webhook.py index 13956bc41682..c53b0e75573d 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_webhook.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_webhook.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.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/create_runbook_as_draft.py b/sdk/automation/azure-mgmt-automation/generated_samples/create_runbook_as_draft.py index fc334f9f9b23..4b66d98f5d71 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/create_runbook_as_draft.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/create_runbook_as_draft.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.automation import AutomationClient """ @@ -49,6 +52,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/createRunbookAsDraft.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/createRunbookAsDraft.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/create_test_job.py b/sdk/automation/azure-mgmt-automation/generated_samples/create_test_job.py index e1c7d4e9df5b..2c4571d8dd02 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/create_test_job.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/create_test_job.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.automation import AutomationClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/createTestJob.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/createTestJob.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/delete_automation_account.py b/sdk/automation/azure-mgmt-automation/generated_samples/delete_automation_account.py index e20284362dff..38e763a8140a 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/delete_automation_account.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/delete_automation_account.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,13 +30,12 @@ def main(): subscription_id="subid", ) - response = client.automation_account.delete( + client.automation_account.delete( resource_group_name="rg", automation_account_name="myAutomationAccount9", ) - print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/deleteAutomationAccount.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/deleteAutomationAccount.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/delete_certificate.py b/sdk/automation/azure-mgmt-automation/generated_samples/delete_certificate.py index 61fd5294d6ec..295938689ffc 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/delete_certificate.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/delete_certificate.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="subid", ) - response = client.certificate.delete( + client.certificate.delete( resource_group_name="rg", automation_account_name="myAutomationAccount33", certificate_name="testCert", ) - print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/deleteCertificate.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/deleteCertificate.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/delete_connection.py b/sdk/automation/azure-mgmt-automation/generated_samples/delete_connection.py index a3a0ad565068..8e24e4d6d373 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/delete_connection.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/delete_connection.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="subid", ) - response = client.connection.delete( + client.connection.delete( resource_group_name="rg", automation_account_name="myAutomationAccount28", connection_name="myConnection", ) - print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/deleteConnection.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/deleteConnection.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/delete_connection_type.py b/sdk/automation/azure-mgmt-automation/generated_samples/delete_connection_type.py index f929c0d808aa..f7cbd9a55bcf 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/delete_connection_type.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/delete_connection_type.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="subid", ) - response = client.connection_type.delete( + client.connection_type.delete( resource_group_name="rg", automation_account_name="myAutomationAccount22", connection_type_name="myCT", ) - print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/deleteConnectionType.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/deleteConnectionType.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/delete_credential_existing.py b/sdk/automation/azure-mgmt-automation/generated_samples/delete_credential_existing.py index 798b2233ab98..0e0325359316 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/delete_credential_existing.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/delete_credential_existing.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="subid", ) - response = client.credential.delete( + client.credential.delete( resource_group_name="rg", automation_account_name="myAutomationAccount20", credential_name="myCredential", ) - print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/deleteCredentialExisting.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/deleteCredentialExisting.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/delete_dsc_configuration.py b/sdk/automation/azure-mgmt-automation/generated_samples/delete_dsc_configuration.py index 4f6167ad95e6..569caca6960c 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/delete_dsc_configuration.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/delete_dsc_configuration.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="subid", ) - response = client.dsc_configuration.delete( + client.dsc_configuration.delete( resource_group_name="rg", automation_account_name="myAutomationAccount33", configuration_name="TemplateBasic", ) - print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/deleteDscConfiguration.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/deleteDscConfiguration.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/delete_dsc_node.py b/sdk/automation/azure-mgmt-automation/generated_samples/delete_dsc_node.py index 6ba11c5dd893..54ea48a9ef7d 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/delete_dsc_node.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/delete_dsc_node.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,12 +30,11 @@ def main(): subscription_id="subid", ) - response = client.dsc_node.delete( + client.dsc_node.delete( resource_group_name="rg", automation_account_name="myAutomationAccount9", node_id="e1243a76-a9bd-432f-bde3-ad8f317ee786", ) - print(response) # x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/deleteDscNode.json diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/delete_dsc_node_configuration.py b/sdk/automation/azure-mgmt-automation/generated_samples/delete_dsc_node_configuration.py index 986c71cb656b..d86ff8a2d71f 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/delete_dsc_node_configuration.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/delete_dsc_node_configuration.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="subid", ) - response = client.dsc_node_configuration.delete( + client.dsc_node_configuration.delete( resource_group_name="rg", automation_account_name="myAutomationAccount20", node_configuration_name="configName.nodeConfigName", ) - print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/deleteDscNodeConfiguration.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/deleteDscNodeConfiguration.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/delete_hybrid_runbook_worker.py b/sdk/automation/azure-mgmt-automation/generated_samples/delete_hybrid_runbook_worker.py index d57ea4f58b6c..a785bd5128a4 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/delete_hybrid_runbook_worker.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/delete_hybrid_runbook_worker.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,15 +30,14 @@ def main(): subscription_id="subid", ) - response = client.hybrid_runbook_workers.delete( + client.hybrid_runbook_workers.delete( resource_group_name="rg", automation_account_name="myAutomationAccount20", hybrid_runbook_worker_group_name="myGroup", hybrid_runbook_worker_id="c010ad12-ef14-4a2a-aa9e-ef22c4745ddd", ) - print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/deleteHybridRunbookWorker.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/deleteHybridRunbookWorker.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/delete_hybrid_runbook_worker_group.py b/sdk/automation/azure-mgmt-automation/generated_samples/delete_hybrid_runbook_worker_group.py index d2756c5337d4..772edfce4acd 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/delete_hybrid_runbook_worker_group.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/delete_hybrid_runbook_worker_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="subid", ) - response = client.hybrid_runbook_worker_group.delete( + client.hybrid_runbook_worker_group.delete( resource_group_name="rg", automation_account_name="myAutomationAccount20", hybrid_runbook_worker_group_name="myGroup", ) - print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/deleteHybridRunbookWorkerGroup.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/deleteHybridRunbookWorkerGroup.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/delete_job_schedule.py b/sdk/automation/azure-mgmt-automation/generated_samples/delete_job_schedule.py index 8a4366dc6e0d..cd10a10372fa 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/delete_job_schedule.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/delete_job_schedule.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="subid", ) - response = client.job_schedule.delete( + client.job_schedule.delete( resource_group_name="rg", automation_account_name="ContoseAutomationAccount", job_schedule_id="0fa462ba-3aa2-4138-83ca-9ebc3bc55cdc", ) - print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/deleteJobSchedule.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/deleteJobSchedule.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/delete_module.py b/sdk/automation/azure-mgmt-automation/generated_samples/delete_module.py index 3758f7cbd3b2..53a48550bc6d 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/delete_module.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/delete_module.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="subid", ) - response = client.module.delete( + client.module.delete( resource_group_name="rg", automation_account_name="myAutomationAccount33", module_name="OmsCompositeResources", ) - print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/deleteModule.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/deleteModule.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/delete_power_shell72_module.py b/sdk/automation/azure-mgmt-automation/generated_samples/delete_power_shell72_module.py new file mode 100644 index 000000000000..9b5549284c88 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_samples/delete_power_shell72_module.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.automation import AutomationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-automation +# USAGE + python delete_power_shell72_module.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 = AutomationClient( + credential=DefaultAzureCredential(), + subscription_id="a6ddc3c0-ed18-45d9-9cae-d91644c46eb1", + ) + + client.power_shell72_module.delete( + resource_group_name="rg", + automation_account_name="myAutomationAccount33", + module_name="OmsCompositeResources", + ) + + +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/deletePowerShell72Module.json +if __name__ == "__main__": + main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/delete_python2_package.py b/sdk/automation/azure-mgmt-automation/generated_samples/delete_python2_package.py index ba772b1f15c1..455e368516f1 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/delete_python2_package.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/delete_python2_package.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="subid", ) - response = client.python2_package.delete( + client.python2_package.delete( resource_group_name="rg", automation_account_name="myAutomationAccount33", package_name="OmsCompositeResources", ) - print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/deletePython2Package.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/deletePython2Package.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/delete_python3_package.py b/sdk/automation/azure-mgmt-automation/generated_samples/delete_python3_package.py index 49b6c157e7ce..4b6f68b2ad62 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/delete_python3_package.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/delete_python3_package.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="subid", ) - response = client.python3_package.delete( + client.python3_package.delete( resource_group_name="rg", automation_account_name="myAutomationAccount33", package_name="OmsCompositeResources", ) - print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/deletePython3Package.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/deletePython3Package.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/delete_runbook.py b/sdk/automation/azure-mgmt-automation/generated_samples/delete_runbook.py index bd4aeccefb63..d68cb69ff00b 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/delete_runbook.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/delete_runbook.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="subid", ) - response = client.runbook.delete( + client.runbook.delete( resource_group_name="rg", automation_account_name="ContoseAutomationAccount", runbook_name="Get-AzureVMTutorial", ) - print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/deleteRunbook.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/deleteRunbook.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/delete_schedule.py b/sdk/automation/azure-mgmt-automation/generated_samples/delete_schedule.py index e4bbe77ff19a..2fac4162c5aa 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/delete_schedule.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/delete_schedule.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="subid", ) - response = client.schedule.delete( + client.schedule.delete( resource_group_name="rg", automation_account_name="myAutomationAccount33", schedule_name="mySchedule", ) - print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/deleteSchedule.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/deleteSchedule.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/delete_variable.py b/sdk/automation/azure-mgmt-automation/generated_samples/delete_variable.py index 373381e793b3..5e1bf8000bad 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/delete_variable.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/delete_variable.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="subid", ) - response = client.variable.delete( + client.variable.delete( resource_group_name="rg", automation_account_name="sampleAccount9", variable_name="sampleVariable", ) - print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/deleteVariable.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/deleteVariable.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/delete_watcher.py b/sdk/automation/azure-mgmt-automation/generated_samples/delete_watcher.py index 0c14c65c24c2..0f5e527b3e10 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/delete_watcher.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/delete_watcher.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,12 +30,11 @@ def main(): subscription_id="subid", ) - response = client.watcher.delete( + client.watcher.delete( resource_group_name="rg", automation_account_name="MyTestAutomationAccount", watcher_name="MyTestWatcher", ) - print(response) # x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/deleteWatcher.json diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/delete_webhook.py b/sdk/automation/azure-mgmt-automation/generated_samples/delete_webhook.py index 5998a5bd524d..5cb27ce8e4d3 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/delete_webhook.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/delete_webhook.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,12 +30,11 @@ def main(): subscription_id="subid", ) - response = client.webhook.delete( + client.webhook.delete( resource_group_name="rg", automation_account_name="myAutomationAccount33", webhook_name="TestWebhook", ) - print(response) # x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2015-10-31/examples/deleteWebhook.json diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/deserialize_graph_runbook_content.py b/sdk/automation/azure-mgmt-automation/generated_samples/deserialize_graph_runbook_content.py index d83ec664e049..b9f9cb365f16 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/deserialize_graph_runbook_content.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/deserialize_graph_runbook_content.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.automation import AutomationClient """ @@ -43,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/deserializeGraphRunbookContent.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/deserializeGraphRunbookContent.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_activity_in_amodule.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_activity_in_amodule.py index 9389529266ad..cb87e20bcec9 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_activity_in_amodule.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_activity_in_amodule.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getActivityInAModule.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getActivityInAModule.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_agent_registration.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_agent_registration.py index 7ef428702a29..2bc7dcaddabf 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_agent_registration.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_agent_registration.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_all_connection_types_first100.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_all_connection_types_first100.py index b14fe70e2f5f..75ac1d1bbd51 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_all_connection_types_first100.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_all_connection_types_first100.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getAllConnectionTypes_First100.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getAllConnectionTypes_First100.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_all_connection_types_next100.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_all_connection_types_next100.py index 9967b3c5b03a..33f5bb4c19d0 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_all_connection_types_next100.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_all_connection_types_next100.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getAllConnectionTypes_Next100.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getAllConnectionTypes_Next100.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_all_dsc_configurations.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_all_dsc_configurations.py index c45e1be72dac..37961d95d57e 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_all_dsc_configurations.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_all_dsc_configurations.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getAllDscConfigurations.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getAllDscConfigurations.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_automation_account.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_automation_account.py index 6b9e268ad6a3..2362649bf42d 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_automation_account.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_automation_account.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getAutomationAccount.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getAutomationAccount.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_certificate.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_certificate.py index 59c87b0d969e..ac09022fd2b6 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_certificate.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_certificate.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getCertificate.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getCertificate.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_compilation_job.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_compilation_job.py index ef88aa7d757e..825278c23f5a 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_compilation_job.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_compilation_job.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_connection.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_connection.py index 9b0cecd3799f..bce983235e81 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_connection.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_connection.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getConnection.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getConnection.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_connection_type.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_connection_type.py index ef0bc7206051..b138e15167fa 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_connection_type.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_connection_type.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getConnectionType.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getConnectionType.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_credential.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_credential.py index a3ea4858bc15..2b6c1bf2c4f6 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_credential.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_credential.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getCredential.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getCredential.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_deleted_automation_account.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_deleted_automation_account.py index 5cf4398a5e57..5e58ce87cbd9 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_deleted_automation_account.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_deleted_automation_account.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_dsc_configuration.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_dsc_configuration.py index dd59173f3450..d26c2ca44871 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_dsc_configuration.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_dsc_configuration.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getDscConfiguration.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getDscConfiguration.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_dsc_configuration_content.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_dsc_configuration_content.py index 3ebfcdc0e0b5..4dfac898b7ef 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_dsc_configuration_content.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_dsc_configuration_content.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getDscConfigurationContent.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getDscConfigurationContent.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_dsc_node.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_dsc_node.py index f0112c52c5b7..7db59ba56d3f 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_dsc_node.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_dsc_node.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_dsc_node_configuration.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_dsc_node_configuration.py index 16614b7e7da9..c2f3433dee7d 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_dsc_node_configuration.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_dsc_node_configuration.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getDscNodeConfiguration.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getDscNodeConfiguration.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_dsc_node_report.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_dsc_node_report.py index 6e23677c4bc8..84f583c63fd7 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_dsc_node_report.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_dsc_node_report.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_dsc_node_report_content.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_dsc_node_report_content.py index f2f0eac20d9d..1df8a0e9f91f 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_dsc_node_report_content.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_dsc_node_report_content.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_hybrid_runbook_worker.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_hybrid_runbook_worker.py index ec122cfc5619..f98a865a23c3 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_hybrid_runbook_worker.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_hybrid_runbook_worker.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getHybridRunbookWorker.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getHybridRunbookWorker.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_hybrid_runbook_worker_group.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_hybrid_runbook_worker_group.py index 49284fc381f8..61333644e95d 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_hybrid_runbook_worker_group.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_hybrid_runbook_worker_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getHybridRunbookWorkerGroup.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getHybridRunbookWorkerGroup.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_job_schedule.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_job_schedule.py index 6658c782f8d4..5c0e141079e9 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_job_schedule.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_job_schedule.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getJobSchedule.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getJobSchedule.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_linked_workspace.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_linked_workspace.py index bfa741d8eae9..0480602c22e9 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_linked_workspace.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_linked_workspace.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getLinkedWorkspace.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getLinkedWorkspace.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_module.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_module.py index d6ea2e7fa7c7..bee5fc04d98e 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_module.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_module.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getModule.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getModule.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_paged_dsc_configurations_with_no_filter.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_paged_dsc_configurations_with_no_filter.py index 47346472da18..7fe2ef2f3bc7 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_paged_dsc_configurations_with_no_filter.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_paged_dsc_configurations_with_no_filter.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getPagedDscConfigurationsWithNoFilter.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getPagedDscConfigurationsWithNoFilter.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_pagedl_dsc_configurations_with_name_filter.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_pagedl_dsc_configurations_with_name_filter.py index 5ab5913776cd..2eba5679da15 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_pagedl_dsc_configurations_with_name_filter.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_pagedl_dsc_configurations_with_name_filter.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getPagedlDscConfigurationsWithNameFilter.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getPagedlDscConfigurationsWithNameFilter.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_power_shell72_module.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_power_shell72_module.py new file mode 100644 index 000000000000..066fc530de4d --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_power_shell72_module.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.automation import AutomationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-automation +# USAGE + python get_power_shell72_module.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 = AutomationClient( + credential=DefaultAzureCredential(), + subscription_id="a6ddc3c0-ed18-45d9-9cae-d91644c46eb1", + ) + + response = client.power_shell72_module.get( + resource_group_name="rg", + automation_account_name="myAutomationAccount33", + module_name="OmsCompositeResources", + ) + print(response) + + +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getPowerShell72Module.json +if __name__ == "__main__": + main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_python2_package.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_python2_package.py index 684fdc7d4b62..f612360fddf3 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_python2_package.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_python2_package.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getPython2Package.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getPython2Package.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_python3_package.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_python3_package.py index ba09a760e5f5..d7eaadacf61e 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_python3_package.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_python3_package.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getPython3Package.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getPython3Package.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_runbook.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_runbook.py index 6e699bb34e43..26418e840ffc 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_runbook.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_runbook.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getRunbook.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getRunbook.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_runbook_content.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_runbook_content.py index a90309a5ab22..215901a71dae 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_runbook_content.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_runbook_content.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getRunbookContent.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getRunbookContent.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_runbook_draft.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_runbook_draft.py index aab64bc644a7..fca8c4734309 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_runbook_draft.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_runbook_draft.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getRunbookDraft.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getRunbookDraft.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_runbook_draft_content.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_runbook_draft_content.py index 0b9a52aad808..8b7fcb70b5ca 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_runbook_draft_content.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_runbook_draft_content.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getRunbookDraftContent.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getRunbookDraftContent.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_schedule.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_schedule.py index 9b5f8c045edb..cadff0ef95fa 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_schedule.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_schedule.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getSchedule.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getSchedule.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_statistics_of_automation_account.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_statistics_of_automation_account.py index 41a7706999b7..a1672cdb6f32 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_statistics_of_automation_account.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_statistics_of_automation_account.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getStatisticsOfAutomationAccount.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getStatisticsOfAutomationAccount.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_test_job.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_test_job.py index d604bce10343..86dfa7b4baa7 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_test_job.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_test_job.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getTestJob.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getTestJob.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_test_job_stream.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_test_job_stream.py index 2ac192c8a19b..589bc26f23b4 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_test_job_stream.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_test_job_stream.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getTestJobStream.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getTestJobStream.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_usages_of_automation_account.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_usages_of_automation_account.py index a083999ca85d..e9e6cbe44c59 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_usages_of_automation_account.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_usages_of_automation_account.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getUsagesOfAutomationAccount.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getUsagesOfAutomationAccount.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_variable.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_variable.py index ad8209775320..cf277730127a 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_variable.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_variable.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/getVariable.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/getVariable.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_watcher.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_watcher.py index eb369835683f..075a8a4c3e6e 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_watcher.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_watcher.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_webhook.py b/sdk/automation/azure-mgmt-automation/generated_samples/get_webhook.py index 10fc19f864e3..9143bac1cedc 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_webhook.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/get_webhook.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/create_job.py b/sdk/automation/azure-mgmt-automation/generated_samples/job/create_job.py similarity index 94% rename from sdk/automation/azure-mgmt-automation/generated_samples/create_job.py rename to sdk/automation/azure-mgmt-automation/generated_samples/job/create_job.py index 2d38fea8ffe7..78e066a81027 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/create_job.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/job/create_job.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.automation import AutomationClient """ @@ -44,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/job/createJob.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/job/createJob.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_job.py b/sdk/automation/azure-mgmt-automation/generated_samples/job/get_job.py similarity index 95% rename from sdk/automation/azure-mgmt-automation/generated_samples/get_job.py rename to sdk/automation/azure-mgmt-automation/generated_samples/job/get_job.py index d2b92f137f87..6b32c88f5f38 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_job.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/job/get_job.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/job/getJob.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/job/getJob.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_job_output.py b/sdk/automation/azure-mgmt-automation/generated_samples/job/get_job_output.py similarity index 95% rename from sdk/automation/azure-mgmt-automation/generated_samples/get_job_output.py rename to sdk/automation/azure-mgmt-automation/generated_samples/job/get_job_output.py index 42e27376f357..b1b10a77b2df 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_job_output.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/job/get_job_output.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/job/getJobOutput.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/job/getJobOutput.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_job_runbook_content.py b/sdk/automation/azure-mgmt-automation/generated_samples/job/get_job_runbook_content.py similarity index 95% rename from sdk/automation/azure-mgmt-automation/generated_samples/get_job_runbook_content.py rename to sdk/automation/azure-mgmt-automation/generated_samples/job/get_job_runbook_content.py index e9c2654c74f6..1f46f62efb5c 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_job_runbook_content.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/job/get_job_runbook_content.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/job/getJobRunbookContent.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/job/getJobRunbookContent.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_job_stream.py b/sdk/automation/azure-mgmt-automation/generated_samples/job/get_job_stream.py similarity index 96% rename from sdk/automation/azure-mgmt-automation/generated_samples/get_job_stream.py rename to sdk/automation/azure-mgmt-automation/generated_samples/job/get_job_stream.py index f45ea43108fe..a9e3797cdb85 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_job_stream.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/job/get_job_stream.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/job/getJobStream.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/job/getJobStream.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_job_streams_by_job.py b/sdk/automation/azure-mgmt-automation/generated_samples/job/list_job_streams_by_job.py similarity index 96% rename from sdk/automation/azure-mgmt-automation/generated_samples/list_job_streams_by_job.py rename to sdk/automation/azure-mgmt-automation/generated_samples/job/list_job_streams_by_job.py index 459c3da81dae..d7765f61287c 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_job_streams_by_job.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/job/list_job_streams_by_job.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/job/listJobStreamsByJob.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/job/listJobStreamsByJob.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_jobs_by_automation_account.py b/sdk/automation/azure-mgmt-automation/generated_samples/job/list_jobs_by_automation_account.py similarity index 96% rename from sdk/automation/azure-mgmt-automation/generated_samples/list_jobs_by_automation_account.py rename to sdk/automation/azure-mgmt-automation/generated_samples/job/list_jobs_by_automation_account.py index d789ee010ee9..77e3b0f6bd22 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_jobs_by_automation_account.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/job/list_jobs_by_automation_account.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/job/listJobsByAutomationAccount.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/job/listJobsByAutomationAccount.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/resume_job.py b/sdk/automation/azure-mgmt-automation/generated_samples/job/resume_job.py similarity index 92% rename from sdk/automation/azure-mgmt-automation/generated_samples/resume_job.py rename to sdk/automation/azure-mgmt-automation/generated_samples/job/resume_job.py index 9f6449d75dcf..06bdfe4d5ae0 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/resume_job.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/job/resume_job.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="51766542-3ed7-4a72-a187-0c8ab644ddab", ) - response = client.job.resume( + client.job.resume( resource_group_name="mygroup", automation_account_name="ContoseAutomationAccount", job_name="foo", ) - print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/job/resumeJob.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/job/resumeJob.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/stop_job.py b/sdk/automation/azure-mgmt-automation/generated_samples/job/stop_job.py similarity index 92% rename from sdk/automation/azure-mgmt-automation/generated_samples/stop_job.py rename to sdk/automation/azure-mgmt-automation/generated_samples/job/stop_job.py index b918877a09be..9e8f2577c1d4 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/stop_job.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/job/stop_job.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="51766542-3ed7-4a72-a187-0c8ab644ddab", ) - response = client.job.stop( + client.job.stop( resource_group_name="mygroup", automation_account_name="ContoseAutomationAccount", job_name="foo", ) - print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/job/stopJob.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/job/stopJob.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/suspend_job.py b/sdk/automation/azure-mgmt-automation/generated_samples/job/suspend_job.py similarity index 92% rename from sdk/automation/azure-mgmt-automation/generated_samples/suspend_job.py rename to sdk/automation/azure-mgmt-automation/generated_samples/job/suspend_job.py index 8d989be033b9..3ee832296fa3 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/suspend_job.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/job/suspend_job.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="51766542-3ed7-4a72-a187-0c8ab644ddab", ) - response = client.job.suspend( + client.job.suspend( resource_group_name="mygroup", automation_account_name="ContoseAutomationAccount", job_name="foo", ) - print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/job/suspendJob.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/job/suspendJob.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_activities_by_module.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_activities_by_module.py index 8872546354af..0a967846f304 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_activities_by_module.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_activities_by_module.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listActivitiesByModule.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listActivitiesByModule.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_all_dsc_nodes_by_automation_account.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_all_dsc_nodes_by_automation_account.py index 7e9f6396e600..cbcbaa13f653 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_all_dsc_nodes_by_automation_account.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_all_dsc_nodes_by_automation_account.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_all_job_schedules_by_automation_account.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_all_job_schedules_by_automation_account.py index e81e9a773167..642b2d75d7e8 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_all_job_schedules_by_automation_account.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_all_job_schedules_by_automation_account.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listAllJobSchedulesByAutomationAccount.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listAllJobSchedulesByAutomationAccount.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_automation_account_keys.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_automation_account_keys.py index d022dd606657..283140f2a334 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_automation_account_keys.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_automation_account_keys.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listAutomationAccountKeys.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listAutomationAccountKeys.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_automation_accounts_by_resource_group.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_automation_accounts_by_resource_group.py index a2cf160943a9..bfd703c014f9 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_automation_accounts_by_resource_group.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_automation_accounts_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listAutomationAccountsByResourceGroup.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listAutomationAccountsByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_automation_accounts_by_subscription.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_automation_accounts_by_subscription.py index 329c56d5574a..b2f779704486 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_automation_accounts_by_subscription.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_automation_accounts_by_subscription.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listAutomationAccountsBySubscription.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listAutomationAccountsBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_certificates_by_automation_account.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_certificates_by_automation_account.py index 28b8a613718b..7b6bf2aa8f58 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_certificates_by_automation_account.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_certificates_by_automation_account.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listCertificatesByAutomationAccount.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listCertificatesByAutomationAccount.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_compilation_jobs_by_automation_account.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_compilation_jobs_by_automation_account.py index 13a9c44e34b2..2f888903c6fd 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_compilation_jobs_by_automation_account.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_compilation_jobs_by_automation_account.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_connections_by_automation_account_first100.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_connections_by_automation_account_first100.py index 34c9575d04a3..3a9be8307160 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_connections_by_automation_account_first100.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_connections_by_automation_account_first100.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listConnectionsByAutomationAccount_First100.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listConnectionsByAutomationAccount_First100.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_connections_by_automation_account_next100.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_connections_by_automation_account_next100.py index 9d8e1e180083..e2ba17889da4 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_connections_by_automation_account_next100.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_connections_by_automation_account_next100.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listConnectionsByAutomationAccount_Next100.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listConnectionsByAutomationAccount_Next100.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_credentials_by_automation_account.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_credentials_by_automation_account.py index f150c3673d51..beb8c7470c0d 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_credentials_by_automation_account.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_credentials_by_automation_account.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listCredentialsByAutomationAccount.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listCredentialsByAutomationAccount.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_credentials_by_automation_account_next100_using_next_link.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_credentials_by_automation_account_next100_using_next_link.py index 566095cbdb7e..50dc441092c2 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_credentials_by_automation_account_next100_using_next_link.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_credentials_by_automation_account_next100_using_next_link.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listCredentialsByAutomationAccount_next100_using_nextLink.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listCredentialsByAutomationAccount_next100_using_nextLink.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_dsc_node_configurations.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_dsc_node_configurations.py index a6f3b787db2f..67622d0f6426 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_dsc_node_configurations.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_dsc_node_configurations.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listDscNodeConfigurations.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listDscNodeConfigurations.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_dsc_node_reports_by_node.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_dsc_node_reports_by_node.py index 96fb43eeaf63..d840bc47801d 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_dsc_node_reports_by_node.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_dsc_node_reports_by_node.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_fields_by_module_and_type.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_fields_by_module_and_type.py index 4bf336a82996..94604ce14720 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_fields_by_module_and_type.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_fields_by_module_and_type.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -39,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listFieldsByModuleAndType.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listFieldsByModuleAndType.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_fields_by_type.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_fields_by_type.py index 75f28c225d50..421c8f38e23a 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_fields_by_type.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_fields_by_type.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listFieldsByType.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listFieldsByType.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_hybrid_runbook_worker.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_hybrid_runbook_worker.py index 771cdcde2d4a..a3d6d3a47ba3 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_hybrid_runbook_worker.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_hybrid_runbook_worker.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listHybridRunbookWorker.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listHybridRunbookWorker.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_hybrid_runbook_worker_group.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_hybrid_runbook_worker_group.py index 44a1342f3965..813c8ef896c9 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_hybrid_runbook_worker_group.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_hybrid_runbook_worker_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listHybridRunbookWorkerGroup.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listHybridRunbookWorkerGroup.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_modules_by_automation_account.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_modules_by_automation_account.py index 5f8e7099d1cc..1fcbf6ddb070 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_modules_by_automation_account.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_modules_by_automation_account.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listModulesByAutomationAccount.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listModulesByAutomationAccount.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_node_configuration_counts.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_node_configuration_counts.py index 00dc38d933a5..405214528781 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_node_configuration_counts.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_node_configuration_counts.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.automation import AutomationClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_node_configurations_with_name_filter.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_node_configurations_with_name_filter.py index 3a69b16cabe5..58d55f92ae8c 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_node_configurations_with_name_filter.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_node_configurations_with_name_filter.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listPagedDscNodeConfigurationsWithNameFilter.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listPagedDscNodeConfigurationsWithNameFilter.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_node_configurations_with_no_filter.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_node_configurations_with_no_filter.py index f82ff1046dbb..9000c1c5ef88 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_node_configurations_with_no_filter.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_node_configurations_with_no_filter.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listPagedDscNodeConfigurationsWithNoFilter.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listPagedDscNodeConfigurationsWithNoFilter.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_node_reports_by_node.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_node_reports_by_node.py index e6b853a64dca..661384c40b96 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_node_reports_by_node.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_node_reports_by_node.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_node_status_counts.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_node_status_counts.py index efd35d5de8f3..c1004ddaa22d 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_node_status_counts.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_node_status_counts.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.automation import AutomationClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_composite_filter.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_composite_filter.py index cf51a4248030..4ec9eedbd300 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_composite_filter.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_composite_filter.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_name_filter.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_name_filter.py index af954a3f052e..e962db24a88e 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_name_filter.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_name_filter.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_no_filter.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_no_filter.py index 2f83d3a9caf1..c2e508e489d2 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_no_filter.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_no_filter.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_node_configuration_custom_filter.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_node_configuration_custom_filter.py index 2c8109fa4783..53da5b881cf8 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_node_configuration_custom_filter.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_node_configuration_custom_filter.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_node_configuration_not_assigned_filter.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_node_configuration_not_assigned_filter.py index f9d5fc342da0..9456fcda2be3 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_node_configuration_not_assigned_filter.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_node_configuration_not_assigned_filter.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_status_filter.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_status_filter.py index 9291dc66dcba..e048cf4cfac0 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_status_filter.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_status_filter.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_version_filter.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_version_filter.py index 19b97ee3fc9e..fe2822958fed 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_version_filter.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_paged_dsc_nodes_by_automation_account_with_version_filter.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_power_shell72_modules_by_automation_account.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_power_shell72_modules_by_automation_account.py new file mode 100644 index 000000000000..0887eb003089 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_power_shell72_modules_by_automation_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.automation import AutomationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-automation +# USAGE + python list_power_shell72_modules_by_automation_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 = AutomationClient( + credential=DefaultAzureCredential(), + subscription_id="a6ddc3c0-ed18-45d9-9cae-d91644c46eb1", + ) + + response = client.power_shell72_module.list_by_automation_account( + resource_group_name="rg", + automation_account_name="myAutomationAccount33", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listPowerShell72ModulesByAutomationAccount.json +if __name__ == "__main__": + main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_python2_packages_by_automation_account.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_python2_packages_by_automation_account.py index 45ce29531a20..4ee010430e43 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_python2_packages_by_automation_account.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_python2_packages_by_automation_account.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listPython2PackagesByAutomationAccount.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listPython2PackagesByAutomationAccount.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_python3_packages_by_automation_account.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_python3_packages_by_automation_account.py index 544c0f4b875f..6d6f1b542ee3 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_python3_packages_by_automation_account.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_python3_packages_by_automation_account.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listPython3PackagesByAutomationAccount.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listPython3PackagesByAutomationAccount.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_rest_api_operations.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_rest_api_operations.py index d3caf91dba22..8d65018ec15e 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_rest_api_operations.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_rest_api_operations.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listRestAPIOperations.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listRestAPIOperations.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_runbooks_by_automation_account.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_runbooks_by_automation_account.py index a2cd89a2b95c..243b7ca28485 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_runbooks_by_automation_account.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_runbooks_by_automation_account.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listRunbooksByAutomationAccount.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listRunbooksByAutomationAccount.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_schedules_by_automation_account_first100.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_schedules_by_automation_account_first100.py index 1730bf20bf6e..a45b91e13d01 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_schedules_by_automation_account_first100.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_schedules_by_automation_account_first100.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listSchedulesByAutomationAccount_First100.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listSchedulesByAutomationAccount_First100.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_schedules_by_automation_account_next100.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_schedules_by_automation_account_next100.py index 2fb56d713471..3c0923a56eef 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_schedules_by_automation_account_next100.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_schedules_by_automation_account_next100.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listSchedulesByAutomationAccount_Next100.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listSchedulesByAutomationAccount_Next100.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_test_job_streams_by_job.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_test_job_streams_by_job.py index 0be9152ac743..4f6617c5adb8 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_test_job_streams_by_job.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_test_job_streams_by_job.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listTestJobStreamsByJob.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listTestJobStreamsByJob.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_variables_first100.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_variables_first100.py index 27441076e4cc..ba6d426d6978 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_variables_first100.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_variables_first100.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listVariables_First100.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listVariables_First100.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_variables_next100.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_variables_next100.py index 8e2c68a5a40e..728b33d33459 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_variables_next100.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_variables_next100.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/listVariables_Next100.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/listVariables_Next100.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_watchers_by_automation_account.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_watchers_by_automation_account.py index 2528b0b12062..875b9f5aad88 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_watchers_by_automation_account.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_watchers_by_automation_account.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_webhooks_by_automation_account.py b/sdk/automation/azure-mgmt-automation/generated_samples/list_webhooks_by_automation_account.py index 6310c3de2131..aeba21f7af44 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_webhooks_by_automation_account.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/list_webhooks_by_automation_account.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/move_hybrid_runbook_worker.py b/sdk/automation/azure-mgmt-automation/generated_samples/move_hybrid_runbook_worker.py new file mode 100644 index 000000000000..1bcdc0386950 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_samples/move_hybrid_runbook_worker.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.automation import AutomationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-automation +# USAGE + python move_hybrid_runbook_worker.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 = AutomationClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + client.hybrid_runbook_workers.move( + resource_group_name="rg", + automation_account_name="testaccount", + hybrid_runbook_worker_group_name="TestHybridGroup", + hybrid_runbook_worker_id="c010ad12-ef14-4a2a-aa9e-ef22c4745ddd", + hybrid_runbook_worker_move_parameters={"hybridRunbookWorkerGroupName": "TestHybridGroup2"}, + ) + + +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/moveHybridRunbookWorker.json +if __name__ == "__main__": + main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/private_endpoint_connection_delete.py b/sdk/automation/azure-mgmt-automation/generated_samples/private_endpoint_connection_delete.py index 90667792d25a..c5d94257f205 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/private_endpoint_connection_delete.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/private_endpoint_connection_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,12 +30,11 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.private_endpoint_connections.begin_delete( + client.private_endpoint_connections.begin_delete( resource_group_name="rg1", automation_account_name="ddb1", private_endpoint_connection_name="privateEndpointConnectionName", ).result() - print(response) # x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/PrivateEndpointConnectionDelete.json diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/private_endpoint_connection_get.py b/sdk/automation/azure-mgmt-automation/generated_samples/private_endpoint_connection_get.py index 12f93405791d..3a187bf89a0b 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/private_endpoint_connection_get.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/private_endpoint_connection_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/private_endpoint_connection_list_get.py b/sdk/automation/azure-mgmt-automation/generated_samples/private_endpoint_connection_list_get.py index d0b2839a11d7..85ea3a55fd8d 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/private_endpoint_connection_list_get.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/private_endpoint_connection_list_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/private_endpoint_connection_update.py b/sdk/automation/azure-mgmt-automation/generated_samples/private_endpoint_connection_update.py index 62eada24990f..d58628a70e87 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/private_endpoint_connection_update.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/private_endpoint_connection_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.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/private_link_resource_list_get.py b/sdk/automation/azure-mgmt-automation/generated_samples/private_link_resource_list_get.py index 751f640d36c5..13292b098f19 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/private_link_resource_list_get.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/private_link_resource_list_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/publish_runbook.py b/sdk/automation/azure-mgmt-automation/generated_samples/publish_runbook.py index 8b27533bda34..70976c7564ea 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/publish_runbook.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/publish_runbook.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="subid", ) - response = client.runbook.begin_publish( + client.runbook.begin_publish( resource_group_name="rg", automation_account_name="ContoseAutomationAccount", runbook_name="Get-AzureVMTutorial", ).result() - print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/publishRunbook.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/publishRunbook.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/put_hybrid_runbook_worker.py b/sdk/automation/azure-mgmt-automation/generated_samples/put_hybrid_runbook_worker.py new file mode 100644 index 000000000000..f791d4730b76 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_samples/put_hybrid_runbook_worker.py @@ -0,0 +1,51 @@ +# 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.automation import AutomationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-automation +# USAGE + python put_hybrid_runbook_worker.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 = AutomationClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.hybrid_runbook_workers.create( + resource_group_name="rg", + automation_account_name="testaccount", + hybrid_runbook_worker_group_name="TestHybridGroup", + hybrid_runbook_worker_id="c010ad12-ef14-4a2a-aa9e-ef22c4745ddd", + hybrid_runbook_worker_creation_parameters={ + "properties": { + "vmResourceId": "/subscriptions/vmsubid/resourceGroups/vmrg/providers/Microsoft.Compute/virtualMachines/vmname" + } + }, + ) + print(response) + + +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/putHybridRunbookWorker.json +if __name__ == "__main__": + main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/put_hybrid_runbook_worker_group.py b/sdk/automation/azure-mgmt-automation/generated_samples/put_hybrid_runbook_worker_group.py new file mode 100644 index 000000000000..e29c75e1fa7b --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_samples/put_hybrid_runbook_worker_group.py @@ -0,0 +1,48 @@ +# 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.automation import AutomationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-automation +# USAGE + python put_hybrid_runbook_worker_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AutomationClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.hybrid_runbook_worker_group.create( + resource_group_name="rg", + automation_account_name="testaccount", + hybrid_runbook_worker_group_name="TestHybridGroup", + hybrid_runbook_worker_group_creation_parameters={ + "properties": {"credential": {"name": "myRunAsCredentialName"}} + }, + ) + print(response) + + +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/putHybridRunbookWorkerGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/regenerate_agent_registration_key.py b/sdk/automation/azure-mgmt-automation/generated_samples/regenerate_agent_registration_key.py index 134d188f4fb3..06f324898e45 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/regenerate_agent_registration_key.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/regenerate_agent_registration_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.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/replace_runbook_draft_content.py b/sdk/automation/azure-mgmt-automation/generated_samples/replace_runbook_draft_content.py index 7d5faf92e036..07b68e6a0e94 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/replace_runbook_draft_content.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/replace_runbook_draft_content.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import IO + from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -77,6 +80,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/replaceRunbookDraftContent.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/replaceRunbookDraftContent.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/resume_test_job.py b/sdk/automation/azure-mgmt-automation/generated_samples/resume_test_job.py index 793545c2a9b7..1c064b7c078f 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/resume_test_job.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/resume_test_job.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="51766542-3ed7-4a72-a187-0c8ab644ddab", ) - response = client.test_job.resume( + client.test_job.resume( resource_group_name="mygroup", automation_account_name="ContoseAutomationAccount", runbook_name="Get-AzureVMTutorial", ) - print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/resumeTestJob.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/resumeTestJob.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/serialize_graph_runbook_content.py b/sdk/automation/azure-mgmt-automation/generated_samples/serialize_graph_runbook_content.py index 3155d622419f..d585a94f8e0a 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/serialize_graph_runbook_content.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/serialize_graph_runbook_content.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.automation import AutomationClient """ @@ -37,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/serializeGraphRunbookContent.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/serializeGraphRunbookContent.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/create_software_update_configuration.py b/sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration/create_software_update_configuration.py similarity index 99% rename from sdk/automation/azure-mgmt-automation/generated_samples/create_software_update_configuration.py rename to sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration/create_software_update_configuration.py index b4771505a99e..cf74aa1af4f2 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/create_software_update_configuration.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration/create_software_update_configuration.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.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/delete_software_update_configuration.py b/sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration/delete_software_update_configuration.py similarity index 95% rename from sdk/automation/azure-mgmt-automation/generated_samples/delete_software_update_configuration.py rename to sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration/delete_software_update_configuration.py index 6e2eb24b74ed..4860444270ac 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/delete_software_update_configuration.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration/delete_software_update_configuration.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,12 +30,11 @@ def main(): subscription_id="51766542-3ed7-4a72-a187-0c8ab644ddab", ) - response = client.software_update_configurations.delete( + client.software_update_configurations.delete( resource_group_name="mygroup", automation_account_name="myaccount", software_update_configuration_name="mypatch", ) - print(response) # x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/softwareUpdateConfiguration/deleteSoftwareUpdateConfiguration.json diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_software_update_configuration_by_name.py b/sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration/get_software_update_configuration_by_name.py similarity index 99% rename from sdk/automation/azure-mgmt-automation/generated_samples/get_software_update_configuration_by_name.py rename to sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration/get_software_update_configuration_by_name.py index 5902d947a095..70bbcd54b012 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_software_update_configuration_by_name.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration/get_software_update_configuration_by_name.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_software_update_configurations.py b/sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration/list_software_update_configurations.py similarity index 99% rename from sdk/automation/azure-mgmt-automation/generated_samples/list_software_update_configurations.py rename to sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration/list_software_update_configurations.py index b69d1cb13920..fe1173dad307 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_software_update_configurations.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration/list_software_update_configurations.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_software_update_configurations_by_vm.py b/sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration/list_software_update_configurations_by_vm.py similarity index 99% rename from sdk/automation/azure-mgmt-automation/generated_samples/list_software_update_configurations_by_vm.py rename to sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration/list_software_update_configurations_by_vm.py index 3681e8c0ae48..0b62afe1a129 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_software_update_configurations_by_vm.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration/list_software_update_configurations_by_vm.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_software_update_configuration_machine_run_by_id.py b/sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration_machine_run/get_software_update_configuration_machine_run_by_id.py similarity index 96% rename from sdk/automation/azure-mgmt-automation/generated_samples/get_software_update_configuration_machine_run_by_id.py rename to sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration_machine_run/get_software_update_configuration_machine_run_by_id.py index 58bd29fd58e4..595e7cb6b418 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_software_update_configuration_machine_run_by_id.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration_machine_run/get_software_update_configuration_machine_run_by_id.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/softwareUpdateConfigurationMachineRun/getSoftwareUpdateConfigurationMachineRunById.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/softwareUpdateConfigurationMachineRun/getSoftwareUpdateConfigurationMachineRunById.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_software_update_configuration_machine_runs.py b/sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration_machine_run/list_software_update_configuration_machine_runs.py similarity index 96% rename from sdk/automation/azure-mgmt-automation/generated_samples/list_software_update_configuration_machine_runs.py rename to sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration_machine_run/list_software_update_configuration_machine_runs.py index 00be7b54d8fc..88a666078312 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_software_update_configuration_machine_runs.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration_machine_run/list_software_update_configuration_machine_runs.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/softwareUpdateConfigurationMachineRun/listSoftwareUpdateConfigurationMachineRuns.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/softwareUpdateConfigurationMachineRun/listSoftwareUpdateConfigurationMachineRuns.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_software_update_configuration_machine_runs_by_run.py b/sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration_machine_run/list_software_update_configuration_machine_runs_by_run.py similarity index 96% rename from sdk/automation/azure-mgmt-automation/generated_samples/list_software_update_configuration_machine_runs_by_run.py rename to sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration_machine_run/list_software_update_configuration_machine_runs_by_run.py index df87e8fd3d19..9ecf9c169d6c 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_software_update_configuration_machine_runs_by_run.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration_machine_run/list_software_update_configuration_machine_runs_by_run.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/softwareUpdateConfigurationMachineRun/listSoftwareUpdateConfigurationMachineRunsByRun.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/softwareUpdateConfigurationMachineRun/listSoftwareUpdateConfigurationMachineRunsByRun.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_software_update_configuration_run_by_id.py b/sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration_run/get_software_update_configuration_run_by_id.py similarity index 96% rename from sdk/automation/azure-mgmt-automation/generated_samples/get_software_update_configuration_run_by_id.py rename to sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration_run/get_software_update_configuration_run_by_id.py index f22cd0c67707..33f0bb0f84b6 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_software_update_configuration_run_by_id.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration_run/get_software_update_configuration_run_by_id.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/softwareUpdateConfigurationRun/getSoftwareUpdateConfigurationRunById.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/softwareUpdateConfigurationRun/getSoftwareUpdateConfigurationRunById.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_failed_software_update_configuration_runs.py b/sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration_run/list_failed_software_update_configuration_runs.py similarity index 96% rename from sdk/automation/azure-mgmt-automation/generated_samples/list_failed_software_update_configuration_runs.py rename to sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration_run/list_failed_software_update_configuration_runs.py index d9a6b2e14679..9ebc71b3e362 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_failed_software_update_configuration_runs.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration_run/list_failed_software_update_configuration_runs.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/softwareUpdateConfigurationRun/listFailedSoftwareUpdateConfigurationRuns.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/softwareUpdateConfigurationRun/listFailedSoftwareUpdateConfigurationRuns.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/list_software_update_configuration_runs.py b/sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration_run/list_software_update_configuration_runs.py similarity index 96% rename from sdk/automation/azure-mgmt-automation/generated_samples/list_software_update_configuration_runs.py rename to sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration_run/list_software_update_configuration_runs.py index 69244ac61daf..4d22c531c812 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/list_software_update_configuration_runs.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/software_update_configuration_run/list_software_update_configuration_runs.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/softwareUpdateConfigurationRun/listSoftwareUpdateConfigurationRuns.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/softwareUpdateConfigurationRun/listSoftwareUpdateConfigurationRuns.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_source_control.py b/sdk/automation/azure-mgmt-automation/generated_samples/source_control/create_or_update_source_control.py similarity index 88% rename from sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_source_control.py rename to sdk/automation/azure-mgmt-automation/generated_samples/source_control/create_or_update_source_control.py index 714e153313c0..cc2279038a16 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/create_or_update_source_control.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/source_control/create_or_update_source_control.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.automation import AutomationClient """ @@ -41,10 +44,7 @@ def main(): "folderPath": "/folderOne/folderTwo", "publishRunbook": True, "repoUrl": "https://sampleUser.visualstudio.com/myProject/_git/myRepository", - "securityToken": { - "accessToken": "3a326f7a0dcd343ea58fee21f2fd5fb4c1234567", - "tokenType": "PersonalAccessToken", - }, + "securityToken": {"accessToken": "******", "tokenType": "PersonalAccessToken"}, "sourceType": "VsoGit", } }, @@ -52,6 +52,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/sourceControl/createOrUpdateSourceControl.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/sourceControl/createOrUpdateSourceControl.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/delete_source_control.py b/sdk/automation/azure-mgmt-automation/generated_samples/source_control/delete_source_control.py similarity index 91% rename from sdk/automation/azure-mgmt-automation/generated_samples/delete_source_control.py rename to sdk/automation/azure-mgmt-automation/generated_samples/source_control/delete_source_control.py index 7d549e83d0ee..1f7643b53b59 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/delete_source_control.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/source_control/delete_source_control.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="subid", ) - response = client.source_control.delete( + client.source_control.delete( resource_group_name="rg", automation_account_name="sampleAccount9", source_control_name="sampleSourceControl", ) - print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/sourceControl/deleteSourceControl.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/sourceControl/deleteSourceControl.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_all_source_controls.py b/sdk/automation/azure-mgmt-automation/generated_samples/source_control/get_all_source_controls.py similarity index 95% rename from sdk/automation/azure-mgmt-automation/generated_samples/get_all_source_controls.py rename to sdk/automation/azure-mgmt-automation/generated_samples/source_control/get_all_source_controls.py index bebb7fc90935..4000e4316378 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_all_source_controls.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/source_control/get_all_source_controls.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/sourceControl/getAllSourceControls.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/sourceControl/getAllSourceControls.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_source_control.py b/sdk/automation/azure-mgmt-automation/generated_samples/source_control/get_source_control.py similarity index 95% rename from sdk/automation/azure-mgmt-automation/generated_samples/get_source_control.py rename to sdk/automation/azure-mgmt-automation/generated_samples/source_control/get_source_control.py index fc9f1d72f52e..cc6cd989cd91 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_source_control.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/source_control/get_source_control.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/sourceControl/getSourceControl.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/sourceControl/getSourceControl.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/update_source_control_patch.py b/sdk/automation/azure-mgmt-automation/generated_samples/source_control/update_source_control_patch.py similarity index 87% rename from sdk/automation/azure-mgmt-automation/generated_samples/update_source_control_patch.py rename to sdk/automation/azure-mgmt-automation/generated_samples/source_control/update_source_control_patch.py index 52f7e6b0d4e0..0d21e554fae6 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/update_source_control_patch.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/source_control/update_source_control_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.automation import AutomationClient """ @@ -40,16 +43,13 @@ def main(): "description": "my description", "folderPath": "/folderOne/folderTwo", "publishRunbook": True, - "securityToken": { - "accessToken": "3a326f7a0dcd343ea58fee21f2fd5fb4c1234567", - "tokenType": "PersonalAccessToken", - }, + "securityToken": {"accessToken": "******", "tokenType": "PersonalAccessToken"}, } }, ) print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/sourceControl/updateSourceControl_patch.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/sourceControl/updateSourceControl_patch.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/create_source_control_sync_job.py b/sdk/automation/azure-mgmt-automation/generated_samples/source_control_sync_job/create_source_control_sync_job.py similarity index 94% rename from sdk/automation/azure-mgmt-automation/generated_samples/create_source_control_sync_job.py rename to sdk/automation/azure-mgmt-automation/generated_samples/source_control_sync_job/create_source_control_sync_job.py index 7e7e27f90f2c..61fe28edc56c 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/create_source_control_sync_job.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/source_control_sync_job/create_source_control_sync_job.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.automation import AutomationClient """ @@ -39,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/sourceControlSyncJob/createSourceControlSyncJob.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/sourceControlSyncJob/createSourceControlSyncJob.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_all_source_control_sync_jobs.py b/sdk/automation/azure-mgmt-automation/generated_samples/source_control_sync_job/get_all_source_control_sync_jobs.py similarity index 96% rename from sdk/automation/azure-mgmt-automation/generated_samples/get_all_source_control_sync_jobs.py rename to sdk/automation/azure-mgmt-automation/generated_samples/source_control_sync_job/get_all_source_control_sync_jobs.py index 05eb87813631..4b019768ef62 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_all_source_control_sync_jobs.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/source_control_sync_job/get_all_source_control_sync_jobs.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/sourceControlSyncJob/getAllSourceControlSyncJobs.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/sourceControlSyncJob/getAllSourceControlSyncJobs.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_source_control_sync_job.py b/sdk/automation/azure-mgmt-automation/generated_samples/source_control_sync_job/get_source_control_sync_job.py similarity index 96% rename from sdk/automation/azure-mgmt-automation/generated_samples/get_source_control_sync_job.py rename to sdk/automation/azure-mgmt-automation/generated_samples/source_control_sync_job/get_source_control_sync_job.py index ede5f897ec7d..5ec3f62d0cb8 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_source_control_sync_job.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/source_control_sync_job/get_source_control_sync_job.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/sourceControlSyncJob/getSourceControlSyncJob.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/sourceControlSyncJob/getSourceControlSyncJob.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_source_control_sync_job_streams.py b/sdk/automation/azure-mgmt-automation/generated_samples/source_control_sync_job_streams/get_source_control_sync_job_streams.py similarity index 96% rename from sdk/automation/azure-mgmt-automation/generated_samples/get_source_control_sync_job_streams.py rename to sdk/automation/azure-mgmt-automation/generated_samples/source_control_sync_job_streams/get_source_control_sync_job_streams.py index 6f515733f06d..826ddfa1b71f 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_source_control_sync_job_streams.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/source_control_sync_job_streams/get_source_control_sync_job_streams.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -39,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/sourceControlSyncJobStreams/getSourceControlSyncJobStreams.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/sourceControlSyncJobStreams/getSourceControlSyncJobStreams.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/get_source_control_sync_job_streams_by_stream_id.py b/sdk/automation/azure-mgmt-automation/generated_samples/source_control_sync_job_streams/get_source_control_sync_job_streams_by_stream_id.py similarity index 96% rename from sdk/automation/azure-mgmt-automation/generated_samples/get_source_control_sync_job_streams_by_stream_id.py rename to sdk/automation/azure-mgmt-automation/generated_samples/source_control_sync_job_streams/get_source_control_sync_job_streams_by_stream_id.py index 2a00b6994279..3077488161f5 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/get_source_control_sync_job_streams_by_stream_id.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/source_control_sync_job_streams/get_source_control_sync_job_streams_by_stream_id.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/sourceControlSyncJobStreams/getSourceControlSyncJobStreamsByStreamId.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/sourceControlSyncJobStreams/getSourceControlSyncJobStreamsByStreamId.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/start_watcher.py b/sdk/automation/azure-mgmt-automation/generated_samples/start_watcher.py index 7662d25930d7..1a3e21177d58 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/start_watcher.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/start_watcher.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,12 +30,11 @@ def main(): subscription_id="subid", ) - response = client.watcher.start( + client.watcher.start( resource_group_name="rg", automation_account_name="MyTestAutomationAccount", watcher_name="MyTestWatcher", ) - print(response) # x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/startWatcher.json diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/stop_test_job.py b/sdk/automation/azure-mgmt-automation/generated_samples/stop_test_job.py index e70cbf68bc08..b8ea84ac5685 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/stop_test_job.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/stop_test_job.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="51766542-3ed7-4a72-a187-0c8ab644ddab", ) - response = client.test_job.stop( + client.test_job.stop( resource_group_name="mygroup", automation_account_name="ContoseAutomationAccount", runbook_name="Get-AzureVMTutorial", ) - print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/stopTestJob.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/stopTestJob.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/stop_watcher.py b/sdk/automation/azure-mgmt-automation/generated_samples/stop_watcher.py index f71ada541e02..ae4333efca6f 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/stop_watcher.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/stop_watcher.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,12 +30,11 @@ def main(): subscription_id="subid", ) - response = client.watcher.stop( + client.watcher.stop( resource_group_name="rg", automation_account_name="MyTestAutomationAccount", watcher_name="MyTestWatcher", ) - print(response) # x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/stopWatcher.json diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/suspend_test_job.py b/sdk/automation/azure-mgmt-automation/generated_samples/suspend_test_job.py index e01ba8626e41..416fda0d0e17 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/suspend_test_job.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/suspend_test_job.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="51766542-3ed7-4a72-a187-0c8ab644ddab", ) - response = client.test_job.suspend( + client.test_job.suspend( resource_group_name="mygroup", automation_account_name="ContoseAutomationAccount", runbook_name="Get-AzureVMTutorial", ) - print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/suspendTestJob.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/suspendTestJob.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/undo_draft_edit_to_last_known_published_state.py b/sdk/automation/azure-mgmt-automation/generated_samples/undo_draft_edit_to_last_known_published_state.py index 47373562cc35..85a8b536ff3f 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/undo_draft_edit_to_last_known_published_state.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/undo_draft_edit_to_last_known_published_state.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/undoDraftEditToLastKnownPublishedState.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/undoDraftEditToLastKnownPublishedState.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/update_automation_account.py b/sdk/automation/azure-mgmt-automation/generated_samples/update_automation_account.py index d7b16ce92a58..be7e842361fd 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/update_automation_account.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/update_automation_account.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.automation import AutomationClient """ @@ -37,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/updateAutomationAccount.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/updateAutomationAccount.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/update_certificate.py b/sdk/automation/azure-mgmt-automation/generated_samples/update_certificate.py index 99ab885a839a..a646e67da0b3 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/update_certificate.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/update_certificate.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.automation import AutomationClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/updateCertificate.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/updateCertificate.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/update_connection.py b/sdk/automation/azure-mgmt-automation/generated_samples/update_connection.py index 8d80714883df..665dbad89f91 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/update_connection.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/update_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.automation import AutomationClient """ @@ -47,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/updateConnection.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/updateConnection.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/update_credential_patch.py b/sdk/automation/azure-mgmt-automation/generated_samples/update_credential_patch.py index b625492a573a..a2aecb43364a 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/update_credential_patch.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/update_credential_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.automation import AutomationClient """ @@ -45,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/updateCredential_patch.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/updateCredential_patch.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/update_dsc_configuration.py b/sdk/automation/azure-mgmt-automation/generated_samples/update_dsc_configuration.py index e094bac82453..19e2e7040fc5 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/update_dsc_configuration.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/update_dsc_configuration.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/updateDscConfiguration.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/updateDscConfiguration.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/update_dsc_node.py b/sdk/automation/azure-mgmt-automation/generated_samples/update_dsc_node.py index f16476b7c162..d05b6af207f8 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/update_dsc_node.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/update_dsc_node.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.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/update_hybrid_runbook_worker_group.py b/sdk/automation/azure-mgmt-automation/generated_samples/update_hybrid_runbook_worker_group.py new file mode 100644 index 000000000000..a52c80be5729 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_samples/update_hybrid_runbook_worker_group.py @@ -0,0 +1,48 @@ +# 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.automation import AutomationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-automation +# USAGE + python update_hybrid_runbook_worker_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AutomationClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.hybrid_runbook_worker_group.update( + resource_group_name="rg", + automation_account_name="testaccount", + hybrid_runbook_worker_group_name="TestHybridGroup", + hybrid_runbook_worker_group_updation_parameters={ + "properties": {"credential": {"name": "myRunAsCredentialUpdatedName"}} + }, + ) + print(response) + + +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/updateHybridRunbookWorkerGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/update_module.py b/sdk/automation/azure-mgmt-automation/generated_samples/update_module.py index ccb620b512db..3da0a26bc41c 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/update_module.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/update_module.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.automation import AutomationClient """ @@ -49,6 +52,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/updateModule.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/updateModule.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/update_power_shell72_module.py b/sdk/automation/azure-mgmt-automation/generated_samples/update_power_shell72_module.py new file mode 100644 index 000000000000..a0f4652b1036 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_samples/update_power_shell72_module.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.automation import AutomationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-automation +# USAGE + python update_power_shell72_module.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 = AutomationClient( + credential=DefaultAzureCredential(), + subscription_id="a6ddc3c0-ed18-45d9-9cae-d91644c46eb1", + ) + + response = client.power_shell72_module.update( + resource_group_name="rg", + automation_account_name="MyAutomationAccount", + module_name="MyModule", + parameters={ + "properties": { + "contentLink": { + "contentHash": { + "algorithm": "sha265", + "value": "07E108A962B81DD9C9BAA89BB47C0F6EE52B29E83758B07795E408D258B2B87A", + }, + "uri": "https://teststorage.blob.core.windows.net/mycontainer/MyModule.zip", + "version": "1.0.0.0", + } + } + }, + ) + print(response) + + +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/updatePowerShell72Module.json +if __name__ == "__main__": + main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/update_python2_package.py b/sdk/automation/azure-mgmt-automation/generated_samples/update_python2_package.py index 64b2e32508bb..63a5b11866fd 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/update_python2_package.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/update_python2_package.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.automation import AutomationClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/updatePython2Package.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/updatePython2Package.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/update_python3_package.py b/sdk/automation/azure-mgmt-automation/generated_samples/update_python3_package.py index 862d22b3f059..d7f382611242 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/update_python3_package.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/update_python3_package.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.automation import AutomationClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/updatePython3Package.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/updatePython3Package.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/update_runbook.py b/sdk/automation/azure-mgmt-automation/generated_samples/update_runbook.py index 418a89a0de11..e170de342f82 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/update_runbook.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/update_runbook.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.automation import AutomationClient """ @@ -45,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/updateRunbook.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/updateRunbook.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/update_schedule.py b/sdk/automation/azure-mgmt-automation/generated_samples/update_schedule.py index 1f105f8835d7..71c2b53186b5 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/update_schedule.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/update_schedule.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.automation import AutomationClient """ @@ -41,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/updateSchedule.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/updateSchedule.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/update_variable_patch.py b/sdk/automation/azure-mgmt-automation/generated_samples/update_variable_patch.py index 36c587ab42b9..5fcfccb4b287 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/update_variable_patch.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/update_variable_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.automation import AutomationClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2022-08-08/examples/updateVariable_patch.json +# x-ms-original-file: specification/automation/resource-manager/Microsoft.Automation/stable/2023-11-01/examples/updateVariable_patch.json if __name__ == "__main__": main() diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/update_watcher.py b/sdk/automation/azure-mgmt-automation/generated_samples/update_watcher.py index 050ed96d68e6..54166d7fb981 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/update_watcher.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/update_watcher.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.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/update_webhook.py b/sdk/automation/azure-mgmt-automation/generated_samples/update_webhook.py index 40a8e43c20ef..33068cd8a6d7 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/update_webhook.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/update_webhook.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.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_samples/webhook_generate_uri.py b/sdk/automation/azure-mgmt-automation/generated_samples/webhook_generate_uri.py index 82cda65e5013..625199184011 100644 --- a/sdk/automation/azure-mgmt-automation/generated_samples/webhook_generate_uri.py +++ b/sdk/automation/azure-mgmt-automation/generated_samples/webhook_generate_uri.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.automation import AutomationClient """ diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/conftest.py b/sdk/automation/azure-mgmt-automation/generated_tests/conftest.py new file mode 100644 index 000000000000..1b401bd0756c --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + automation_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + automation_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + automation_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + automation_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=automation_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=automation_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=automation_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=automation_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation.py new file mode 100644 index 000000000000..c91c21abfee6 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomation(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_convert_graph_runbook_content(self, resource_group): + response = self.client.convert_graph_runbook_content( + resource_group_name=resource_group.name, + automation_account_name="str", + parameters={ + "graphRunbookJson": "str", + "rawContent": {"runbookDefinition": "str", "runbookType": "str", "schemaVersion": "str"}, + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_activity_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_activity_operations.py new file mode 100644 index 000000000000..6b605916ad44 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_activity_operations.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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationActivityOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.activity.get( + resource_group_name=resource_group.name, + automation_account_name="str", + module_name="str", + activity_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_module(self, resource_group): + response = self.client.activity.list_by_module( + resource_group_name=resource_group.name, + automation_account_name="str", + module_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_activity_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_activity_operations_async.py new file mode 100644 index 000000000000..f39baf6e1d96 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_activity_operations_async.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationActivityOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.activity.get( + resource_group_name=resource_group.name, + automation_account_name="str", + module_name="str", + activity_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_module(self, resource_group): + response = self.client.activity.list_by_module( + resource_group_name=resource_group.name, + automation_account_name="str", + module_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_agent_registration_information_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_agent_registration_information_operations.py new file mode 100644 index 000000000000..dcfc1c6c2ba9 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_agent_registration_information_operations.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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationAgentRegistrationInformationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.agent_registration_information.get( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_regenerate_key(self, resource_group): + response = self.client.agent_registration_information.regenerate_key( + resource_group_name=resource_group.name, + automation_account_name="str", + parameters={"keyName": "str"}, + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_agent_registration_information_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_agent_registration_information_operations_async.py new file mode 100644 index 000000000000..069b167f661c --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_agent_registration_information_operations_async.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationAgentRegistrationInformationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.agent_registration_information.get( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_regenerate_key(self, resource_group): + response = await self.client.agent_registration_information.regenerate_key( + resource_group_name=resource_group.name, + automation_account_name="str", + parameters={"keyName": "str"}, + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_async.py new file mode 100644 index 000000000000..e0e45bb6458b --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_async.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_convert_graph_runbook_content(self, resource_group): + response = await self.client.convert_graph_runbook_content( + resource_group_name=resource_group.name, + automation_account_name="str", + parameters={ + "graphRunbookJson": "str", + "rawContent": {"runbookDefinition": "str", "runbookType": "str", "schemaVersion": "str"}, + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_automation_account_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_automation_account_operations.py new file mode 100644 index 000000000000..62f741e4c881 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_automation_account_operations.py @@ -0,0 +1,126 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationAutomationAccountOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.automation_account.update( + resource_group_name=resource_group.name, + automation_account_name="str", + parameters={ + "disableLocalAuth": bool, + "encryption": { + "identity": {"userAssignedIdentity": {}}, + "keySource": "str", + "keyVaultProperties": {"keyName": "str", "keyVersion": "str", "keyvaultUri": "str"}, + }, + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "location": "str", + "name": "str", + "publicNetworkAccess": bool, + "sku": {"name": "str", "capacity": 0, "family": "str"}, + "tags": {"str": "str"}, + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.automation_account.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + parameters={ + "disableLocalAuth": bool, + "encryption": { + "identity": {"userAssignedIdentity": {}}, + "keySource": "str", + "keyVaultProperties": {"keyName": "str", "keyVersion": "str", "keyvaultUri": "str"}, + }, + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "location": "str", + "name": "str", + "publicNetworkAccess": bool, + "sku": {"name": "str", "capacity": 0, "family": "str"}, + "tags": {"str": "str"}, + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.automation_account.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.automation_account.get( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.automation_account.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.automation_account.list( + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_automation_account_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_automation_account_operations_async.py new file mode 100644 index 000000000000..8bfc6ccb57b0 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_automation_account_operations_async.py @@ -0,0 +1,127 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationAutomationAccountOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.automation_account.update( + resource_group_name=resource_group.name, + automation_account_name="str", + parameters={ + "disableLocalAuth": bool, + "encryption": { + "identity": {"userAssignedIdentity": {}}, + "keySource": "str", + "keyVaultProperties": {"keyName": "str", "keyVersion": "str", "keyvaultUri": "str"}, + }, + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "location": "str", + "name": "str", + "publicNetworkAccess": bool, + "sku": {"name": "str", "capacity": 0, "family": "str"}, + "tags": {"str": "str"}, + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.automation_account.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + parameters={ + "disableLocalAuth": bool, + "encryption": { + "identity": {"userAssignedIdentity": {}}, + "keySource": "str", + "keyVaultProperties": {"keyName": "str", "keyVersion": "str", "keyvaultUri": "str"}, + }, + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "location": "str", + "name": "str", + "publicNetworkAccess": bool, + "sku": {"name": "str", "capacity": 0, "family": "str"}, + "tags": {"str": "str"}, + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.automation_account.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.automation_account.get( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.automation_account.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.automation_account.list( + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_certificate_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_certificate_operations.py new file mode 100644 index 000000000000..4d94f708320c --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_certificate_operations.py @@ -0,0 +1,91 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationCertificateOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.certificate.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + certificate_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.certificate.get( + resource_group_name=resource_group.name, + automation_account_name="str", + certificate_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.certificate.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + certificate_name="str", + parameters={ + "base64Value": "str", + "name": "str", + "description": "str", + "isExportable": bool, + "thumbprint": "str", + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.certificate.update( + resource_group_name=resource_group.name, + automation_account_name="str", + certificate_name="str", + parameters={"description": "str", "name": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.certificate.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_certificate_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_certificate_operations_async.py new file mode 100644 index 000000000000..d3caf1b40665 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_certificate_operations_async.py @@ -0,0 +1,92 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationCertificateOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.certificate.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + certificate_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.certificate.get( + resource_group_name=resource_group.name, + automation_account_name="str", + certificate_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.certificate.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + certificate_name="str", + parameters={ + "base64Value": "str", + "name": "str", + "description": "str", + "isExportable": bool, + "thumbprint": "str", + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.certificate.update( + resource_group_name=resource_group.name, + automation_account_name="str", + certificate_name="str", + parameters={"description": "str", "name": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = self.client.certificate.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_connection_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_connection_operations.py new file mode 100644 index 000000000000..3cd349b9d515 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_connection_operations.py @@ -0,0 +1,90 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationConnectionOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.connection.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + connection_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.connection.get( + resource_group_name=resource_group.name, + automation_account_name="str", + connection_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.connection.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + connection_name="str", + parameters={ + "connectionType": {"name": "str"}, + "name": "str", + "description": "str", + "fieldDefinitionValues": {"str": "str"}, + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.connection.update( + resource_group_name=resource_group.name, + automation_account_name="str", + connection_name="str", + parameters={"description": "str", "fieldDefinitionValues": {"str": "str"}, "name": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.connection.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_connection_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_connection_operations_async.py new file mode 100644 index 000000000000..17306486816b --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_connection_operations_async.py @@ -0,0 +1,91 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationConnectionOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.connection.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + connection_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.connection.get( + resource_group_name=resource_group.name, + automation_account_name="str", + connection_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.connection.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + connection_name="str", + parameters={ + "connectionType": {"name": "str"}, + "name": "str", + "description": "str", + "fieldDefinitionValues": {"str": "str"}, + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.connection.update( + resource_group_name=resource_group.name, + automation_account_name="str", + connection_name="str", + parameters={"description": "str", "fieldDefinitionValues": {"str": "str"}, "name": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = self.client.connection.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_connection_type_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_connection_type_operations.py new file mode 100644 index 000000000000..c14d93ac98dd --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_connection_type_operations.py @@ -0,0 +1,75 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationConnectionTypeOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.connection_type.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + connection_type_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.connection_type.get( + resource_group_name=resource_group.name, + automation_account_name="str", + connection_type_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.connection_type.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + connection_type_name="str", + parameters={ + "fieldDefinitions": {"str": {"type": "str", "isEncrypted": bool, "isOptional": bool}}, + "name": "str", + "isGlobal": bool, + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.connection_type.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_connection_type_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_connection_type_operations_async.py new file mode 100644 index 000000000000..0dba3e973b59 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_connection_type_operations_async.py @@ -0,0 +1,76 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationConnectionTypeOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.connection_type.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + connection_type_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.connection_type.get( + resource_group_name=resource_group.name, + automation_account_name="str", + connection_type_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.connection_type.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + connection_type_name="str", + parameters={ + "fieldDefinitions": {"str": {"type": "str", "isEncrypted": bool, "isOptional": bool}}, + "name": "str", + "isGlobal": bool, + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = self.client.connection_type.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_credential_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_credential_operations.py new file mode 100644 index 000000000000..35881ffbcd03 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_credential_operations.py @@ -0,0 +1,85 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationCredentialOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.credential.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + credential_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.credential.get( + resource_group_name=resource_group.name, + automation_account_name="str", + credential_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.credential.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + credential_name="str", + parameters={"name": "str", "password": "str", "userName": "str", "description": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.credential.update( + resource_group_name=resource_group.name, + automation_account_name="str", + credential_name="str", + parameters={"description": "str", "name": "str", "password": "str", "userName": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.credential.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_credential_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_credential_operations_async.py new file mode 100644 index 000000000000..d030182ebe04 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_credential_operations_async.py @@ -0,0 +1,86 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationCredentialOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.credential.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + credential_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.credential.get( + resource_group_name=resource_group.name, + automation_account_name="str", + credential_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.credential.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + credential_name="str", + parameters={"name": "str", "password": "str", "userName": "str", "description": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.credential.update( + resource_group_name=resource_group.name, + automation_account_name="str", + credential_name="str", + parameters={"description": "str", "name": "str", "password": "str", "userName": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = self.client.credential.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_deleted_automation_accounts_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_deleted_automation_accounts_operations.py new file mode 100644 index 000000000000..42183b89a940 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_deleted_automation_accounts_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationDeletedAutomationAccountsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_subscription(self, resource_group): + response = self.client.deleted_automation_accounts.list_by_subscription( + api_version="2022-01-31", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_deleted_automation_accounts_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_deleted_automation_accounts_operations_async.py new file mode 100644 index 000000000000..1e4611aaf6f4 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_deleted_automation_accounts_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationDeletedAutomationAccountsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_subscription(self, resource_group): + response = await self.client.deleted_automation_accounts.list_by_subscription( + api_version="2022-01-31", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_compilation_job_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_compilation_job_operations.py new file mode 100644 index 000000000000..983d8ee3e766 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_compilation_job_operations.py @@ -0,0 +1,79 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationDscCompilationJobOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.dsc_compilation_job.begin_create( + resource_group_name=resource_group.name, + automation_account_name="str", + compilation_job_name="str", + parameters={ + "configuration": {"name": "str"}, + "incrementNodeConfigurationBuild": bool, + "location": "str", + "name": "str", + "parameters": {"str": "str"}, + "tags": {"str": "str"}, + }, + api_version="2020-01-13-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.dsc_compilation_job.get( + resource_group_name=resource_group.name, + automation_account_name="str", + compilation_job_name="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.dsc_compilation_job.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2020-01-13-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_stream(self, resource_group): + response = self.client.dsc_compilation_job.get_stream( + resource_group_name=resource_group.name, + automation_account_name="str", + job_id="str", + job_stream_id="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_compilation_job_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_compilation_job_operations_async.py new file mode 100644 index 000000000000..9cd2ff9e93ed --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_compilation_job_operations_async.py @@ -0,0 +1,82 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationDscCompilationJobOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.dsc_compilation_job.begin_create( + resource_group_name=resource_group.name, + automation_account_name="str", + compilation_job_name="str", + parameters={ + "configuration": {"name": "str"}, + "incrementNodeConfigurationBuild": bool, + "location": "str", + "name": "str", + "parameters": {"str": "str"}, + "tags": {"str": "str"}, + }, + api_version="2020-01-13-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.dsc_compilation_job.get( + resource_group_name=resource_group.name, + automation_account_name="str", + compilation_job_name="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = self.client.dsc_compilation_job.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2020-01-13-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_stream(self, resource_group): + response = await self.client.dsc_compilation_job.get_stream( + resource_group_name=resource_group.name, + automation_account_name="str", + job_id="str", + job_stream_id="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_compilation_job_stream_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_compilation_job_stream_operations.py new file mode 100644 index 000000000000..0a2c9c3d274a --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_compilation_job_stream_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationDscCompilationJobStreamOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_job(self, resource_group): + response = self.client.dsc_compilation_job_stream.list_by_job( + resource_group_name=resource_group.name, + automation_account_name="str", + job_id="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_compilation_job_stream_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_compilation_job_stream_operations_async.py new file mode 100644 index 000000000000..097698daaa7e --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_compilation_job_stream_operations_async.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationDscCompilationJobStreamOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_job(self, resource_group): + response = await self.client.dsc_compilation_job_stream.list_by_job( + resource_group_name=resource_group.name, + automation_account_name="str", + job_id="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_configuration_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_configuration_operations.py new file mode 100644 index 000000000000..cac61410f6fd --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_configuration_operations.py @@ -0,0 +1,111 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationDscConfigurationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.dsc_configuration.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + configuration_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.dsc_configuration.get( + resource_group_name=resource_group.name, + automation_account_name="str", + configuration_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.dsc_configuration.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + configuration_name="str", + parameters={ + "source": { + "hash": {"algorithm": "str", "value": "str"}, + "type": "str", + "value": "str", + "version": "str", + }, + "description": "str", + "location": "str", + "logProgress": bool, + "logVerbose": bool, + "name": "str", + "parameters": {"str": {"defaultValue": "str", "isMandatory": bool, "position": 0, "type": "str"}}, + "tags": {"str": "str"}, + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.dsc_configuration.update( + resource_group_name=resource_group.name, + automation_account_name="str", + configuration_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_content(self, resource_group): + response = self.client.dsc_configuration.get_content( + resource_group_name=resource_group.name, + automation_account_name="str", + configuration_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.dsc_configuration.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_configuration_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_configuration_operations_async.py new file mode 100644 index 000000000000..7ee05751ddc4 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_configuration_operations_async.py @@ -0,0 +1,112 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationDscConfigurationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.dsc_configuration.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + configuration_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.dsc_configuration.get( + resource_group_name=resource_group.name, + automation_account_name="str", + configuration_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.dsc_configuration.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + configuration_name="str", + parameters={ + "source": { + "hash": {"algorithm": "str", "value": "str"}, + "type": "str", + "value": "str", + "version": "str", + }, + "description": "str", + "location": "str", + "logProgress": bool, + "logVerbose": bool, + "name": "str", + "parameters": {"str": {"defaultValue": "str", "isMandatory": bool, "position": 0, "type": "str"}}, + "tags": {"str": "str"}, + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.dsc_configuration.update( + resource_group_name=resource_group.name, + automation_account_name="str", + configuration_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_content(self, resource_group): + response = await self.client.dsc_configuration.get_content( + resource_group_name=resource_group.name, + automation_account_name="str", + configuration_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = self.client.dsc_configuration.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_node_configuration_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_node_configuration_operations.py new file mode 100644 index 000000000000..c03bfd5834c7 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_node_configuration_operations.py @@ -0,0 +1,82 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationDscNodeConfigurationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.dsc_node_configuration.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + node_configuration_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.dsc_node_configuration.get( + resource_group_name=resource_group.name, + automation_account_name="str", + node_configuration_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.dsc_node_configuration.begin_create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + node_configuration_name="str", + parameters={ + "configuration": {"name": "str"}, + "incrementNodeConfigurationBuild": bool, + "name": "str", + "source": { + "hash": {"algorithm": "str", "value": "str"}, + "type": "str", + "value": "str", + "version": "str", + }, + "tags": {"str": "str"}, + }, + api_version="2023-11-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.dsc_node_configuration.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_node_configuration_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_node_configuration_operations_async.py new file mode 100644 index 000000000000..ddf72b86bd9f --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_node_configuration_operations_async.py @@ -0,0 +1,85 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationDscNodeConfigurationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.dsc_node_configuration.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + node_configuration_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.dsc_node_configuration.get( + resource_group_name=resource_group.name, + automation_account_name="str", + node_configuration_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.dsc_node_configuration.begin_create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + node_configuration_name="str", + parameters={ + "configuration": {"name": "str"}, + "incrementNodeConfigurationBuild": bool, + "name": "str", + "source": { + "hash": {"algorithm": "str", "value": "str"}, + "type": "str", + "value": "str", + "version": "str", + }, + "tags": {"str": "str"}, + }, + api_version="2023-11-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = self.client.dsc_node_configuration.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_node_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_node_operations.py new file mode 100644 index 000000000000..8cb548436357 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_node_operations.py @@ -0,0 +1,71 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationDscNodeOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.dsc_node.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + node_id="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.dsc_node.get( + resource_group_name=resource_group.name, + automation_account_name="str", + node_id="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.dsc_node.update( + resource_group_name=resource_group.name, + automation_account_name="str", + node_id="str", + dsc_node_update_parameters={"nodeId": "str", "properties": {"name": "str"}}, + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.dsc_node.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2020-01-13-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_node_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_node_operations_async.py new file mode 100644 index 000000000000..d793a8233cbe --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_dsc_node_operations_async.py @@ -0,0 +1,72 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationDscNodeOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.dsc_node.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + node_id="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.dsc_node.get( + resource_group_name=resource_group.name, + automation_account_name="str", + node_id="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.dsc_node.update( + resource_group_name=resource_group.name, + automation_account_name="str", + node_id="str", + dsc_node_update_parameters={"nodeId": "str", "properties": {"name": "str"}}, + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = self.client.dsc_node.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2020-01-13-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_fields_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_fields_operations.py new file mode 100644 index 000000000000..c14369fbd7e3 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_fields_operations.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationFieldsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_type(self, resource_group): + response = self.client.fields.list_by_type( + resource_group_name=resource_group.name, + automation_account_name="str", + module_name="str", + type_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_fields_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_fields_operations_async.py new file mode 100644 index 000000000000..1057e3beefcb --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_fields_operations_async.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationFieldsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_type(self, resource_group): + response = self.client.fields.list_by_type( + resource_group_name=resource_group.name, + automation_account_name="str", + module_name="str", + type_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_hybrid_runbook_worker_group_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_hybrid_runbook_worker_group_operations.py new file mode 100644 index 000000000000..9a1aa603be94 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_hybrid_runbook_worker_group_operations.py @@ -0,0 +1,85 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationHybridRunbookWorkerGroupOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.hybrid_runbook_worker_group.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + hybrid_runbook_worker_group_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.hybrid_runbook_worker_group.get( + resource_group_name=resource_group.name, + automation_account_name="str", + hybrid_runbook_worker_group_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create(self, resource_group): + response = self.client.hybrid_runbook_worker_group.create( + resource_group_name=resource_group.name, + automation_account_name="str", + hybrid_runbook_worker_group_name="str", + hybrid_runbook_worker_group_creation_parameters={"credential": {"name": "str"}, "name": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.hybrid_runbook_worker_group.update( + resource_group_name=resource_group.name, + automation_account_name="str", + hybrid_runbook_worker_group_name="str", + hybrid_runbook_worker_group_updation_parameters={"credential": {"name": "str"}, "name": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.hybrid_runbook_worker_group.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_hybrid_runbook_worker_group_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_hybrid_runbook_worker_group_operations_async.py new file mode 100644 index 000000000000..cecaf50fb475 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_hybrid_runbook_worker_group_operations_async.py @@ -0,0 +1,86 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationHybridRunbookWorkerGroupOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.hybrid_runbook_worker_group.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + hybrid_runbook_worker_group_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.hybrid_runbook_worker_group.get( + resource_group_name=resource_group.name, + automation_account_name="str", + hybrid_runbook_worker_group_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create(self, resource_group): + response = await self.client.hybrid_runbook_worker_group.create( + resource_group_name=resource_group.name, + automation_account_name="str", + hybrid_runbook_worker_group_name="str", + hybrid_runbook_worker_group_creation_parameters={"credential": {"name": "str"}, "name": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.hybrid_runbook_worker_group.update( + resource_group_name=resource_group.name, + automation_account_name="str", + hybrid_runbook_worker_group_name="str", + hybrid_runbook_worker_group_updation_parameters={"credential": {"name": "str"}, "name": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = self.client.hybrid_runbook_worker_group.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_hybrid_runbook_workers_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_hybrid_runbook_workers_operations.py new file mode 100644 index 000000000000..f934f228fb2c --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_hybrid_runbook_workers_operations.py @@ -0,0 +1,90 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationHybridRunbookWorkersOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.hybrid_runbook_workers.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + hybrid_runbook_worker_group_name="str", + hybrid_runbook_worker_id="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.hybrid_runbook_workers.get( + resource_group_name=resource_group.name, + automation_account_name="str", + hybrid_runbook_worker_group_name="str", + hybrid_runbook_worker_id="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create(self, resource_group): + response = self.client.hybrid_runbook_workers.create( + resource_group_name=resource_group.name, + automation_account_name="str", + hybrid_runbook_worker_group_name="str", + hybrid_runbook_worker_id="str", + hybrid_runbook_worker_creation_parameters={"name": "str", "vmResourceId": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_move(self, resource_group): + response = self.client.hybrid_runbook_workers.move( + resource_group_name=resource_group.name, + automation_account_name="str", + hybrid_runbook_worker_group_name="str", + hybrid_runbook_worker_id="str", + hybrid_runbook_worker_move_parameters={"hybridRunbookWorkerGroupName": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_hybrid_runbook_worker_group(self, resource_group): + response = self.client.hybrid_runbook_workers.list_by_hybrid_runbook_worker_group( + resource_group_name=resource_group.name, + automation_account_name="str", + hybrid_runbook_worker_group_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_hybrid_runbook_workers_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_hybrid_runbook_workers_operations_async.py new file mode 100644 index 000000000000..dad1cd325c6c --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_hybrid_runbook_workers_operations_async.py @@ -0,0 +1,91 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationHybridRunbookWorkersOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.hybrid_runbook_workers.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + hybrid_runbook_worker_group_name="str", + hybrid_runbook_worker_id="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.hybrid_runbook_workers.get( + resource_group_name=resource_group.name, + automation_account_name="str", + hybrid_runbook_worker_group_name="str", + hybrid_runbook_worker_id="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create(self, resource_group): + response = await self.client.hybrid_runbook_workers.create( + resource_group_name=resource_group.name, + automation_account_name="str", + hybrid_runbook_worker_group_name="str", + hybrid_runbook_worker_id="str", + hybrid_runbook_worker_creation_parameters={"name": "str", "vmResourceId": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_move(self, resource_group): + response = await self.client.hybrid_runbook_workers.move( + resource_group_name=resource_group.name, + automation_account_name="str", + hybrid_runbook_worker_group_name="str", + hybrid_runbook_worker_id="str", + hybrid_runbook_worker_move_parameters={"hybridRunbookWorkerGroupName": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_hybrid_runbook_worker_group(self, resource_group): + response = self.client.hybrid_runbook_workers.list_by_hybrid_runbook_worker_group( + resource_group_name=resource_group.name, + automation_account_name="str", + hybrid_runbook_worker_group_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_job_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_job_operations.py new file mode 100644 index 000000000000..3c4fa3c6d684 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_job_operations.py @@ -0,0 +1,123 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationJobOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_output(self, resource_group): + response = self.client.job.get_output( + resource_group_name=resource_group.name, + automation_account_name="str", + job_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_runbook_content(self, resource_group): + response = self.client.job.get_runbook_content( + resource_group_name=resource_group.name, + automation_account_name="str", + job_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_suspend(self, resource_group): + response = self.client.job.suspend( + resource_group_name=resource_group.name, + automation_account_name="str", + job_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_stop(self, resource_group): + response = self.client.job.stop( + resource_group_name=resource_group.name, + automation_account_name="str", + job_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.job.get( + resource_group_name=resource_group.name, + automation_account_name="str", + job_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create(self, resource_group): + response = self.client.job.create( + resource_group_name=resource_group.name, + automation_account_name="str", + job_name="str", + parameters={"parameters": {"str": "str"}, "runOn": "str", "runbook": {"name": "str"}}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.job.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_resume(self, resource_group): + response = self.client.job.resume( + resource_group_name=resource_group.name, + automation_account_name="str", + job_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_job_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_job_operations_async.py new file mode 100644 index 000000000000..bdfd470a794d --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_job_operations_async.py @@ -0,0 +1,124 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationJobOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_output(self, resource_group): + response = await self.client.job.get_output( + resource_group_name=resource_group.name, + automation_account_name="str", + job_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_runbook_content(self, resource_group): + response = await self.client.job.get_runbook_content( + resource_group_name=resource_group.name, + automation_account_name="str", + job_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_suspend(self, resource_group): + response = await self.client.job.suspend( + resource_group_name=resource_group.name, + automation_account_name="str", + job_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_stop(self, resource_group): + response = await self.client.job.stop( + resource_group_name=resource_group.name, + automation_account_name="str", + job_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.job.get( + resource_group_name=resource_group.name, + automation_account_name="str", + job_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create(self, resource_group): + response = await self.client.job.create( + resource_group_name=resource_group.name, + automation_account_name="str", + job_name="str", + parameters={"parameters": {"str": "str"}, "runOn": "str", "runbook": {"name": "str"}}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = self.client.job.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_resume(self, resource_group): + response = await self.client.job.resume( + resource_group_name=resource_group.name, + automation_account_name="str", + job_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_job_schedule_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_job_schedule_operations.py new file mode 100644 index 000000000000..315e55bda507 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_job_schedule_operations.py @@ -0,0 +1,76 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationJobScheduleOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.job_schedule.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + job_schedule_id="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.job_schedule.get( + resource_group_name=resource_group.name, + automation_account_name="str", + job_schedule_id="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create(self, resource_group): + response = self.client.job_schedule.create( + resource_group_name=resource_group.name, + automation_account_name="str", + job_schedule_id="str", + parameters={ + "runbook": {"name": "str"}, + "schedule": {"name": "str"}, + "parameters": {"str": "str"}, + "runOn": "str", + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.job_schedule.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_job_schedule_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_job_schedule_operations_async.py new file mode 100644 index 000000000000..676938521c4d --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_job_schedule_operations_async.py @@ -0,0 +1,77 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationJobScheduleOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.job_schedule.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + job_schedule_id="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.job_schedule.get( + resource_group_name=resource_group.name, + automation_account_name="str", + job_schedule_id="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create(self, resource_group): + response = await self.client.job_schedule.create( + resource_group_name=resource_group.name, + automation_account_name="str", + job_schedule_id="str", + parameters={ + "runbook": {"name": "str"}, + "schedule": {"name": "str"}, + "parameters": {"str": "str"}, + "runOn": "str", + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = self.client.job_schedule.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_job_stream_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_job_stream_operations.py new file mode 100644 index 000000000000..56a30e6ae0e4 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_job_stream_operations.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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationJobStreamOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.job_stream.get( + resource_group_name=resource_group.name, + automation_account_name="str", + job_name="str", + job_stream_id="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_job(self, resource_group): + response = self.client.job_stream.list_by_job( + resource_group_name=resource_group.name, + automation_account_name="str", + job_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_job_stream_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_job_stream_operations_async.py new file mode 100644 index 000000000000..cc6813d4d567 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_job_stream_operations_async.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationJobStreamOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.job_stream.get( + resource_group_name=resource_group.name, + automation_account_name="str", + job_name="str", + job_stream_id="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_job(self, resource_group): + response = self.client.job_stream.list_by_job( + resource_group_name=resource_group.name, + automation_account_name="str", + job_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_keys_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_keys_operations.py new file mode 100644 index 000000000000..915b240ddae1 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_keys_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationKeysOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.keys.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_keys_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_keys_operations_async.py new file mode 100644 index 000000000000..bdf5586ae380 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_keys_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationKeysOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = await self.client.keys.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_linked_workspace_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_linked_workspace_operations.py new file mode 100644 index 000000000000..92b1bdd50114 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_linked_workspace_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationLinkedWorkspaceOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.linked_workspace.get( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_linked_workspace_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_linked_workspace_operations_async.py new file mode 100644 index 000000000000..1b732e2ddc12 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_linked_workspace_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationLinkedWorkspaceOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.linked_workspace.get( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_module_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_module_operations.py new file mode 100644 index 000000000000..51205816ef85 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_module_operations.py @@ -0,0 +1,95 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationModuleOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.module.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + module_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.module.get( + resource_group_name=resource_group.name, + automation_account_name="str", + module_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.module.begin_create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + module_name="str", + parameters={ + "contentLink": {"contentHash": {"algorithm": "str", "value": "str"}, "uri": "str", "version": "str"}, + "location": "str", + "name": "str", + "tags": {"str": "str"}, + }, + api_version="2023-11-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.module.update( + resource_group_name=resource_group.name, + automation_account_name="str", + module_name="str", + parameters={ + "contentLink": {"contentHash": {"algorithm": "str", "value": "str"}, "uri": "str", "version": "str"}, + "location": "str", + "name": "str", + "tags": {"str": "str"}, + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.module.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_module_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_module_operations_async.py new file mode 100644 index 000000000000..7a16395b30cc --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_module_operations_async.py @@ -0,0 +1,102 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationModuleOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.module.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + module_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.module.get( + resource_group_name=resource_group.name, + automation_account_name="str", + module_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.module.begin_create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + module_name="str", + parameters={ + "contentLink": { + "contentHash": {"algorithm": "str", "value": "str"}, + "uri": "str", + "version": "str", + }, + "location": "str", + "name": "str", + "tags": {"str": "str"}, + }, + api_version="2023-11-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.module.update( + resource_group_name=resource_group.name, + automation_account_name="str", + module_name="str", + parameters={ + "contentLink": {"contentHash": {"algorithm": "str", "value": "str"}, "uri": "str", "version": "str"}, + "location": "str", + "name": "str", + "tags": {"str": "str"}, + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = self.client.module.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_node_count_information_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_node_count_information_operations.py new file mode 100644 index 000000000000..6fb52c220ab0 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_node_count_information_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationNodeCountInformationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.node_count_information.get( + resource_group_name=resource_group.name, + automation_account_name="str", + count_type="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_node_count_information_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_node_count_information_operations_async.py new file mode 100644 index 000000000000..96782f7d1ade --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_node_count_information_operations_async.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationNodeCountInformationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.node_count_information.get( + resource_group_name=resource_group.name, + automation_account_name="str", + count_type="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_node_reports_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_node_reports_operations.py new file mode 100644 index 000000000000..f97f92374aa2 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_node_reports_operations.py @@ -0,0 +1,60 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationNodeReportsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_node(self, resource_group): + response = self.client.node_reports.list_by_node( + resource_group_name=resource_group.name, + automation_account_name="str", + node_id="str", + api_version="2020-01-13-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.node_reports.get( + resource_group_name=resource_group.name, + automation_account_name="str", + node_id="str", + report_id="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_content(self, resource_group): + response = self.client.node_reports.get_content( + resource_group_name=resource_group.name, + automation_account_name="str", + node_id="str", + report_id="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_node_reports_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_node_reports_operations_async.py new file mode 100644 index 000000000000..bbe8f5dcf3d1 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_node_reports_operations_async.py @@ -0,0 +1,61 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationNodeReportsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_node(self, resource_group): + response = self.client.node_reports.list_by_node( + resource_group_name=resource_group.name, + automation_account_name="str", + node_id="str", + api_version="2020-01-13-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.node_reports.get( + resource_group_name=resource_group.name, + automation_account_name="str", + node_id="str", + report_id="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_content(self, resource_group): + response = await self.client.node_reports.get_content( + resource_group_name=resource_group.name, + automation_account_name="str", + node_id="str", + report_id="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_object_data_types_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_object_data_types_operations.py new file mode 100644 index 000000000000..ace4ed71b2d2 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_object_data_types_operations.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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationObjectDataTypesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_fields_by_module_and_type(self, resource_group): + response = self.client.object_data_types.list_fields_by_module_and_type( + resource_group_name=resource_group.name, + automation_account_name="str", + module_name="str", + type_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_fields_by_type(self, resource_group): + response = self.client.object_data_types.list_fields_by_type( + resource_group_name=resource_group.name, + automation_account_name="str", + type_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_object_data_types_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_object_data_types_operations_async.py new file mode 100644 index 000000000000..d5104e5cf428 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_object_data_types_operations_async.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationObjectDataTypesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_fields_by_module_and_type(self, resource_group): + response = self.client.object_data_types.list_fields_by_module_and_type( + resource_group_name=resource_group.name, + automation_account_name="str", + module_name="str", + type_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_fields_by_type(self, resource_group): + response = self.client.object_data_types.list_fields_by_type( + resource_group_name=resource_group.name, + automation_account_name="str", + type_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_operations.py new file mode 100644 index 000000000000..a7c18078fd61 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_operations_async.py new file mode 100644 index 000000000000..2f64d644ee39 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_power_shell72_module_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_power_shell72_module_operations.py new file mode 100644 index 000000000000..39b4ee58db87 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_power_shell72_module_operations.py @@ -0,0 +1,95 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationPowerShell72ModuleOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.power_shell72_module.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + module_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.power_shell72_module.get( + resource_group_name=resource_group.name, + automation_account_name="str", + module_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.power_shell72_module.begin_create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + module_name="str", + parameters={ + "contentLink": {"contentHash": {"algorithm": "str", "value": "str"}, "uri": "str", "version": "str"}, + "location": "str", + "name": "str", + "tags": {"str": "str"}, + }, + api_version="2023-11-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.power_shell72_module.update( + resource_group_name=resource_group.name, + automation_account_name="str", + module_name="str", + parameters={ + "contentLink": {"contentHash": {"algorithm": "str", "value": "str"}, "uri": "str", "version": "str"}, + "location": "str", + "name": "str", + "tags": {"str": "str"}, + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.power_shell72_module.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_power_shell72_module_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_power_shell72_module_operations_async.py new file mode 100644 index 000000000000..19f1b4ff9467 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_power_shell72_module_operations_async.py @@ -0,0 +1,102 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationPowerShell72ModuleOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.power_shell72_module.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + module_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.power_shell72_module.get( + resource_group_name=resource_group.name, + automation_account_name="str", + module_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.power_shell72_module.begin_create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + module_name="str", + parameters={ + "contentLink": { + "contentHash": {"algorithm": "str", "value": "str"}, + "uri": "str", + "version": "str", + }, + "location": "str", + "name": "str", + "tags": {"str": "str"}, + }, + api_version="2023-11-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.power_shell72_module.update( + resource_group_name=resource_group.name, + automation_account_name="str", + module_name="str", + parameters={ + "contentLink": {"contentHash": {"algorithm": "str", "value": "str"}, "uri": "str", "version": "str"}, + "location": "str", + "name": "str", + "tags": {"str": "str"}, + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = self.client.power_shell72_module.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_private_endpoint_connections_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..644454f2f37b --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_private_endpoint_connections_operations.py @@ -0,0 +1,78 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationPrivateEndpointConnectionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.private_endpoint_connections.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2020-01-13-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + automation_account_name="str", + private_endpoint_connection_name="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.private_endpoint_connections.begin_create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + private_endpoint_connection_name="str", + parameters={ + "groupIds": ["str"], + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": {"actionsRequired": "str", "description": "str", "status": "str"}, + "type": "str", + }, + api_version="2020-01-13-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + automation_account_name="str", + private_endpoint_connection_name="str", + api_version="2020-01-13-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_private_endpoint_connections_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_private_endpoint_connections_operations_async.py new file mode 100644 index 000000000000..7204890b0c33 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_private_endpoint_connections_operations_async.py @@ -0,0 +1,87 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationPrivateEndpointConnectionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = self.client.private_endpoint_connections.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2020-01-13-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + automation_account_name="str", + private_endpoint_connection_name="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.private_endpoint_connections.begin_create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + private_endpoint_connection_name="str", + parameters={ + "groupIds": ["str"], + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "type": "str", + }, + api_version="2020-01-13-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + automation_account_name="str", + private_endpoint_connection_name="str", + api_version="2020-01-13-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_private_link_resources_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_private_link_resources_operations.py new file mode 100644 index 000000000000..dd9c6f4da5e8 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_private_link_resources_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationPrivateLinkResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_automation(self, resource_group): + response = self.client.private_link_resources.automation( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2020-01-13-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_private_link_resources_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_private_link_resources_operations_async.py new file mode 100644 index 000000000000..f07a4e78b988 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_private_link_resources_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationPrivateLinkResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_automation(self, resource_group): + response = self.client.private_link_resources.automation( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2020-01-13-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_python2_package_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_python2_package_operations.py new file mode 100644 index 000000000000..81be8f8a5c3f --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_python2_package_operations.py @@ -0,0 +1,88 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationPython2PackageOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.python2_package.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + package_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.python2_package.get( + resource_group_name=resource_group.name, + automation_account_name="str", + package_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.python2_package.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + package_name="str", + parameters={ + "contentLink": {"contentHash": {"algorithm": "str", "value": "str"}, "uri": "str", "version": "str"}, + "tags": {"str": "str"}, + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.python2_package.update( + resource_group_name=resource_group.name, + automation_account_name="str", + package_name="str", + parameters={"tags": {"str": "str"}}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.python2_package.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_python2_package_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_python2_package_operations_async.py new file mode 100644 index 000000000000..e571ec6af957 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_python2_package_operations_async.py @@ -0,0 +1,89 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationPython2PackageOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.python2_package.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + package_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.python2_package.get( + resource_group_name=resource_group.name, + automation_account_name="str", + package_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.python2_package.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + package_name="str", + parameters={ + "contentLink": {"contentHash": {"algorithm": "str", "value": "str"}, "uri": "str", "version": "str"}, + "tags": {"str": "str"}, + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.python2_package.update( + resource_group_name=resource_group.name, + automation_account_name="str", + package_name="str", + parameters={"tags": {"str": "str"}}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = self.client.python2_package.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_python3_package_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_python3_package_operations.py new file mode 100644 index 000000000000..ac8737607a5d --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_python3_package_operations.py @@ -0,0 +1,88 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationPython3PackageOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.python3_package.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + package_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.python3_package.get( + resource_group_name=resource_group.name, + automation_account_name="str", + package_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.python3_package.begin_create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + package_name="str", + parameters={ + "contentLink": {"contentHash": {"algorithm": "str", "value": "str"}, "uri": "str", "version": "str"}, + "tags": {"str": "str"}, + }, + api_version="2023-11-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.python3_package.update( + resource_group_name=resource_group.name, + automation_account_name="str", + package_name="str", + parameters={"tags": {"str": "str"}}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.python3_package.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_python3_package_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_python3_package_operations_async.py new file mode 100644 index 000000000000..71bba1d3300e --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_python3_package_operations_async.py @@ -0,0 +1,95 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationPython3PackageOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.python3_package.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + package_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.python3_package.get( + resource_group_name=resource_group.name, + automation_account_name="str", + package_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.python3_package.begin_create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + package_name="str", + parameters={ + "contentLink": { + "contentHash": {"algorithm": "str", "value": "str"}, + "uri": "str", + "version": "str", + }, + "tags": {"str": "str"}, + }, + api_version="2023-11-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.python3_package.update( + resource_group_name=resource_group.name, + automation_account_name="str", + package_name="str", + parameters={"tags": {"str": "str"}}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = self.client.python3_package.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_runbook_draft_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_runbook_draft_operations.py new file mode 100644 index 000000000000..6e744cfff314 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_runbook_draft_operations.py @@ -0,0 +1,72 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationRunbookDraftOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_content(self, resource_group): + response = self.client.runbook_draft.get_content( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_replace_content(self, resource_group): + response = self.client.runbook_draft.begin_replace_content( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + runbook_content=b"bytes", + api_version="2023-11-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.runbook_draft.get( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_undo_edit(self, resource_group): + response = self.client.runbook_draft.undo_edit( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_runbook_draft_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_runbook_draft_operations_async.py new file mode 100644 index 000000000000..5071d7219894 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_runbook_draft_operations_async.py @@ -0,0 +1,75 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationRunbookDraftOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_content(self, resource_group): + response = await self.client.runbook_draft.get_content( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_replace_content(self, resource_group): + response = await ( + await self.client.runbook_draft.begin_replace_content( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + runbook_content=b"bytes", + api_version="2023-11-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.runbook_draft.get( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_undo_edit(self, resource_group): + response = await self.client.runbook_draft.undo_edit( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_runbook_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_runbook_operations.py new file mode 100644 index 000000000000..8e5e74ed36e0 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_runbook_operations.py @@ -0,0 +1,145 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationRunbookOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_publish(self, resource_group): + response = self.client.runbook.begin_publish( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + api_version="2023-11-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_content(self, resource_group): + response = self.client.runbook.get_content( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.runbook.get( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.runbook.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + parameters={ + "runbookType": "str", + "description": "str", + "draft": { + "creationTime": "2020-02-20 00:00:00", + "draftContentLink": { + "contentHash": {"algorithm": "str", "value": "str"}, + "uri": "str", + "version": "str", + }, + "inEdit": bool, + "lastModifiedTime": "2020-02-20 00:00:00", + "outputTypes": ["str"], + "parameters": {"str": {"defaultValue": "str", "isMandatory": bool, "position": 0, "type": "str"}}, + }, + "location": "str", + "logActivityTrace": 0, + "logProgress": bool, + "logVerbose": bool, + "name": "str", + "publishContentLink": { + "contentHash": {"algorithm": "str", "value": "str"}, + "uri": "str", + "version": "str", + }, + "tags": {"str": "str"}, + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.runbook.update( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + parameters={ + "description": "str", + "location": "str", + "logActivityTrace": 0, + "logProgress": bool, + "logVerbose": bool, + "name": "str", + "tags": {"str": "str"}, + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.runbook.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.runbook.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_runbook_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_runbook_operations_async.py new file mode 100644 index 000000000000..74328c758ad1 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_runbook_operations_async.py @@ -0,0 +1,148 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationRunbookOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_publish(self, resource_group): + response = await ( + await self.client.runbook.begin_publish( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + api_version="2023-11-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_content(self, resource_group): + response = await self.client.runbook.get_content( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.runbook.get( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.runbook.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + parameters={ + "runbookType": "str", + "description": "str", + "draft": { + "creationTime": "2020-02-20 00:00:00", + "draftContentLink": { + "contentHash": {"algorithm": "str", "value": "str"}, + "uri": "str", + "version": "str", + }, + "inEdit": bool, + "lastModifiedTime": "2020-02-20 00:00:00", + "outputTypes": ["str"], + "parameters": {"str": {"defaultValue": "str", "isMandatory": bool, "position": 0, "type": "str"}}, + }, + "location": "str", + "logActivityTrace": 0, + "logProgress": bool, + "logVerbose": bool, + "name": "str", + "publishContentLink": { + "contentHash": {"algorithm": "str", "value": "str"}, + "uri": "str", + "version": "str", + }, + "tags": {"str": "str"}, + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.runbook.update( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + parameters={ + "description": "str", + "location": "str", + "logActivityTrace": 0, + "logProgress": bool, + "logVerbose": bool, + "name": "str", + "tags": {"str": "str"}, + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.runbook.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = self.client.runbook.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_schedule_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_schedule_operations.py new file mode 100644 index 000000000000..a9b35a7b574d --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_schedule_operations.py @@ -0,0 +1,98 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationScheduleOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.schedule.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + schedule_name="str", + parameters={ + "frequency": "str", + "name": "str", + "startTime": "2020-02-20 00:00:00", + "advancedSchedule": { + "monthDays": [0], + "monthlyOccurrences": [{"day": "str", "occurrence": 0}], + "weekDays": ["str"], + }, + "description": "str", + "expiryTime": "2020-02-20 00:00:00", + "interval": {}, + "timeZone": "str", + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.schedule.update( + resource_group_name=resource_group.name, + automation_account_name="str", + schedule_name="str", + parameters={"description": "str", "isEnabled": bool, "name": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.schedule.get( + resource_group_name=resource_group.name, + automation_account_name="str", + schedule_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.schedule.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + schedule_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.schedule.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_schedule_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_schedule_operations_async.py new file mode 100644 index 000000000000..93cb77049ace --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_schedule_operations_async.py @@ -0,0 +1,99 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationScheduleOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.schedule.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + schedule_name="str", + parameters={ + "frequency": "str", + "name": "str", + "startTime": "2020-02-20 00:00:00", + "advancedSchedule": { + "monthDays": [0], + "monthlyOccurrences": [{"day": "str", "occurrence": 0}], + "weekDays": ["str"], + }, + "description": "str", + "expiryTime": "2020-02-20 00:00:00", + "interval": {}, + "timeZone": "str", + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.schedule.update( + resource_group_name=resource_group.name, + automation_account_name="str", + schedule_name="str", + parameters={"description": "str", "isEnabled": bool, "name": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.schedule.get( + resource_group_name=resource_group.name, + automation_account_name="str", + schedule_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.schedule.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + schedule_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = self.client.schedule.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_software_update_configuration_machine_runs_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_software_update_configuration_machine_runs_operations.py new file mode 100644 index 000000000000..fa452103e2ae --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_software_update_configuration_machine_runs_operations.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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationSoftwareUpdateConfigurationMachineRunsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_by_id(self, resource_group): + response = self.client.software_update_configuration_machine_runs.get_by_id( + resource_group_name=resource_group.name, + automation_account_name="str", + software_update_configuration_machine_run_id="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.software_update_configuration_machine_runs.list( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_software_update_configuration_machine_runs_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_software_update_configuration_machine_runs_operations_async.py new file mode 100644 index 000000000000..463cdbe9ff33 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_software_update_configuration_machine_runs_operations_async.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationSoftwareUpdateConfigurationMachineRunsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_by_id(self, resource_group): + response = await self.client.software_update_configuration_machine_runs.get_by_id( + resource_group_name=resource_group.name, + automation_account_name="str", + software_update_configuration_machine_run_id="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = await self.client.software_update_configuration_machine_runs.list( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_software_update_configuration_runs_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_software_update_configuration_runs_operations.py new file mode 100644 index 000000000000..d0528478b7d6 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_software_update_configuration_runs_operations.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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationSoftwareUpdateConfigurationRunsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_by_id(self, resource_group): + response = self.client.software_update_configuration_runs.get_by_id( + resource_group_name=resource_group.name, + automation_account_name="str", + software_update_configuration_run_id="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.software_update_configuration_runs.list( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_software_update_configuration_runs_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_software_update_configuration_runs_operations_async.py new file mode 100644 index 000000000000..95887c522e1e --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_software_update_configuration_runs_operations_async.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationSoftwareUpdateConfigurationRunsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_by_id(self, resource_group): + response = await self.client.software_update_configuration_runs.get_by_id( + resource_group_name=resource_group.name, + automation_account_name="str", + software_update_configuration_run_id="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = await self.client.software_update_configuration_runs.list( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_software_update_configurations_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_software_update_configurations_operations.py new file mode 100644 index 000000000000..35f27fd47262 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_software_update_configurations_operations.py @@ -0,0 +1,133 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationSoftwareUpdateConfigurationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create(self, resource_group): + response = self.client.software_update_configurations.create( + resource_group_name=resource_group.name, + automation_account_name="str", + software_update_configuration_name="str", + parameters={ + "scheduleInfo": { + "advancedSchedule": { + "monthDays": [0], + "monthlyOccurrences": [{"day": "str", "occurrence": 0}], + "weekDays": ["str"], + }, + "creationTime": "2020-02-20 00:00:00", + "description": "str", + "expiryTime": "2020-02-20 00:00:00", + "expiryTimeOffsetMinutes": 0.0, + "frequency": "str", + "interval": 0, + "isEnabled": False, + "lastModifiedTime": "2020-02-20 00:00:00", + "nextRun": "2020-02-20 00:00:00", + "nextRunOffsetMinutes": 0.0, + "startTime": "2020-02-20 00:00:00", + "startTimeOffsetMinutes": 0.0, + "timeZone": "str", + }, + "updateConfiguration": { + "operatingSystem": "str", + "azureVirtualMachines": ["str"], + "duration": "1 day, 0:00:00", + "linux": { + "excludedPackageNameMasks": ["str"], + "includedPackageClassifications": "str", + "includedPackageNameMasks": ["str"], + "rebootSetting": "str", + }, + "nonAzureComputerNames": ["str"], + "targets": { + "azureQueries": [ + { + "locations": ["str"], + "scope": ["str"], + "tagSettings": {"filterOperator": "str", "tags": {"str": ["str"]}}, + } + ], + "nonAzureQueries": [{"functionAlias": "str", "workspaceId": "str"}], + }, + "windows": { + "excludedKbNumbers": ["str"], + "includedKbNumbers": ["str"], + "includedUpdateClassifications": "str", + "rebootSetting": "str", + }, + }, + "createdBy": "str", + "creationTime": "2020-02-20 00:00:00", + "error": {"code": "str", "message": "str"}, + "id": "str", + "lastModifiedBy": "str", + "lastModifiedTime": "2020-02-20 00:00:00", + "name": "str", + "provisioningState": "str", + "tasks": { + "postTask": {"parameters": {"str": "str"}, "source": "str"}, + "preTask": {"parameters": {"str": "str"}, "source": "str"}, + }, + "type": "str", + }, + api_version="2019-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_by_name(self, resource_group): + response = self.client.software_update_configurations.get_by_name( + resource_group_name=resource_group.name, + automation_account_name="str", + software_update_configuration_name="str", + api_version="2019-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.software_update_configurations.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + software_update_configuration_name="str", + api_version="2019-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.software_update_configurations.list( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2019-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_software_update_configurations_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_software_update_configurations_operations_async.py new file mode 100644 index 000000000000..b0026a00f9fd --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_software_update_configurations_operations_async.py @@ -0,0 +1,134 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationSoftwareUpdateConfigurationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create(self, resource_group): + response = await self.client.software_update_configurations.create( + resource_group_name=resource_group.name, + automation_account_name="str", + software_update_configuration_name="str", + parameters={ + "scheduleInfo": { + "advancedSchedule": { + "monthDays": [0], + "monthlyOccurrences": [{"day": "str", "occurrence": 0}], + "weekDays": ["str"], + }, + "creationTime": "2020-02-20 00:00:00", + "description": "str", + "expiryTime": "2020-02-20 00:00:00", + "expiryTimeOffsetMinutes": 0.0, + "frequency": "str", + "interval": 0, + "isEnabled": False, + "lastModifiedTime": "2020-02-20 00:00:00", + "nextRun": "2020-02-20 00:00:00", + "nextRunOffsetMinutes": 0.0, + "startTime": "2020-02-20 00:00:00", + "startTimeOffsetMinutes": 0.0, + "timeZone": "str", + }, + "updateConfiguration": { + "operatingSystem": "str", + "azureVirtualMachines": ["str"], + "duration": "1 day, 0:00:00", + "linux": { + "excludedPackageNameMasks": ["str"], + "includedPackageClassifications": "str", + "includedPackageNameMasks": ["str"], + "rebootSetting": "str", + }, + "nonAzureComputerNames": ["str"], + "targets": { + "azureQueries": [ + { + "locations": ["str"], + "scope": ["str"], + "tagSettings": {"filterOperator": "str", "tags": {"str": ["str"]}}, + } + ], + "nonAzureQueries": [{"functionAlias": "str", "workspaceId": "str"}], + }, + "windows": { + "excludedKbNumbers": ["str"], + "includedKbNumbers": ["str"], + "includedUpdateClassifications": "str", + "rebootSetting": "str", + }, + }, + "createdBy": "str", + "creationTime": "2020-02-20 00:00:00", + "error": {"code": "str", "message": "str"}, + "id": "str", + "lastModifiedBy": "str", + "lastModifiedTime": "2020-02-20 00:00:00", + "name": "str", + "provisioningState": "str", + "tasks": { + "postTask": {"parameters": {"str": "str"}, "source": "str"}, + "preTask": {"parameters": {"str": "str"}, "source": "str"}, + }, + "type": "str", + }, + api_version="2019-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_by_name(self, resource_group): + response = await self.client.software_update_configurations.get_by_name( + resource_group_name=resource_group.name, + automation_account_name="str", + software_update_configuration_name="str", + api_version="2019-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.software_update_configurations.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + software_update_configuration_name="str", + api_version="2019-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = await self.client.software_update_configurations.list( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2019-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_source_control_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_source_control_operations.py new file mode 100644 index 000000000000..ea5771ed64e6 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_source_control_operations.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationSourceControlOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.source_control.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + source_control_name="str", + parameters={ + "autoSync": bool, + "branch": "str", + "description": "str", + "folderPath": "str", + "publishRunbook": bool, + "repoUrl": "str", + "securityToken": {"accessToken": "str", "refreshToken": "str", "tokenType": "str"}, + "sourceType": "str", + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.source_control.update( + resource_group_name=resource_group.name, + automation_account_name="str", + source_control_name="str", + parameters={ + "autoSync": bool, + "branch": "str", + "description": "str", + "folderPath": "str", + "publishRunbook": bool, + "securityToken": {"accessToken": "str", "refreshToken": "str", "tokenType": "str"}, + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.source_control.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + source_control_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.source_control.get( + resource_group_name=resource_group.name, + automation_account_name="str", + source_control_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.source_control.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_source_control_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_source_control_operations_async.py new file mode 100644 index 000000000000..772b3fb14a9c --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_source_control_operations_async.py @@ -0,0 +1,102 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationSourceControlOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.source_control.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + source_control_name="str", + parameters={ + "autoSync": bool, + "branch": "str", + "description": "str", + "folderPath": "str", + "publishRunbook": bool, + "repoUrl": "str", + "securityToken": {"accessToken": "str", "refreshToken": "str", "tokenType": "str"}, + "sourceType": "str", + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.source_control.update( + resource_group_name=resource_group.name, + automation_account_name="str", + source_control_name="str", + parameters={ + "autoSync": bool, + "branch": "str", + "description": "str", + "folderPath": "str", + "publishRunbook": bool, + "securityToken": {"accessToken": "str", "refreshToken": "str", "tokenType": "str"}, + }, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.source_control.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + source_control_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.source_control.get( + resource_group_name=resource_group.name, + automation_account_name="str", + source_control_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = self.client.source_control.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_source_control_sync_job_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_source_control_sync_job_operations.py new file mode 100644 index 000000000000..43ffc36587ac --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_source_control_sync_job_operations.py @@ -0,0 +1,61 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationSourceControlSyncJobOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create(self, resource_group): + response = self.client.source_control_sync_job.create( + resource_group_name=resource_group.name, + automation_account_name="str", + source_control_name="str", + source_control_sync_job_id="str", + parameters={"commitId": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.source_control_sync_job.get( + resource_group_name=resource_group.name, + automation_account_name="str", + source_control_name="str", + source_control_sync_job_id="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.source_control_sync_job.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + source_control_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_source_control_sync_job_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_source_control_sync_job_operations_async.py new file mode 100644 index 000000000000..408552e6ee08 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_source_control_sync_job_operations_async.py @@ -0,0 +1,62 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationSourceControlSyncJobOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create(self, resource_group): + response = await self.client.source_control_sync_job.create( + resource_group_name=resource_group.name, + automation_account_name="str", + source_control_name="str", + source_control_sync_job_id="str", + parameters={"commitId": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.source_control_sync_job.get( + resource_group_name=resource_group.name, + automation_account_name="str", + source_control_name="str", + source_control_sync_job_id="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = self.client.source_control_sync_job.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + source_control_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_source_control_sync_job_streams_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_source_control_sync_job_streams_operations.py new file mode 100644 index 000000000000..55c4af6c7dfe --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_source_control_sync_job_streams_operations.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationSourceControlSyncJobStreamsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_sync_job(self, resource_group): + response = self.client.source_control_sync_job_streams.list_by_sync_job( + resource_group_name=resource_group.name, + automation_account_name="str", + source_control_name="str", + source_control_sync_job_id="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.source_control_sync_job_streams.get( + resource_group_name=resource_group.name, + automation_account_name="str", + source_control_name="str", + source_control_sync_job_id="str", + stream_id="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_source_control_sync_job_streams_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_source_control_sync_job_streams_operations_async.py new file mode 100644 index 000000000000..5d18dbf11225 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_source_control_sync_job_streams_operations_async.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationSourceControlSyncJobStreamsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_sync_job(self, resource_group): + response = self.client.source_control_sync_job_streams.list_by_sync_job( + resource_group_name=resource_group.name, + automation_account_name="str", + source_control_name="str", + source_control_sync_job_id="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.source_control_sync_job_streams.get( + resource_group_name=resource_group.name, + automation_account_name="str", + source_control_name="str", + source_control_sync_job_id="str", + stream_id="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_statistics_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_statistics_operations.py new file mode 100644 index 000000000000..ebc3fa9d7234 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_statistics_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationStatisticsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.statistics.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_statistics_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_statistics_operations_async.py new file mode 100644 index 000000000000..bd2e1dc098c0 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_statistics_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationStatisticsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = self.client.statistics.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_test_job_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_test_job_operations.py new file mode 100644 index 000000000000..f65c9ba708c3 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_test_job_operations.py @@ -0,0 +1,85 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationTestJobOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create(self, resource_group): + response = self.client.test_job.create( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + parameters={"parameters": {"str": "str"}, "runOn": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.test_job.get( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_resume(self, resource_group): + response = self.client.test_job.resume( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_stop(self, resource_group): + response = self.client.test_job.stop( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_suspend(self, resource_group): + response = self.client.test_job.suspend( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_test_job_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_test_job_operations_async.py new file mode 100644 index 000000000000..d7d6c616885f --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_test_job_operations_async.py @@ -0,0 +1,86 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationTestJobOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create(self, resource_group): + response = await self.client.test_job.create( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + parameters={"parameters": {"str": "str"}, "runOn": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.test_job.get( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_resume(self, resource_group): + response = await self.client.test_job.resume( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_stop(self, resource_group): + response = await self.client.test_job.stop( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_suspend(self, resource_group): + response = await self.client.test_job.suspend( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_test_job_streams_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_test_job_streams_operations.py new file mode 100644 index 000000000000..3f98d13a03bd --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_test_job_streams_operations.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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationTestJobStreamsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.test_job_streams.get( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + job_stream_id="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_test_job(self, resource_group): + response = self.client.test_job_streams.list_by_test_job( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_test_job_streams_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_test_job_streams_operations_async.py new file mode 100644 index 000000000000..5253398f1c5d --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_test_job_streams_operations_async.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationTestJobStreamsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.test_job_streams.get( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + job_stream_id="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_test_job(self, resource_group): + response = self.client.test_job_streams.list_by_test_job( + resource_group_name=resource_group.name, + automation_account_name="str", + runbook_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_usages_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_usages_operations.py new file mode 100644 index 000000000000..10fd2aeb83dd --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_usages_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationUsagesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.usages.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_usages_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_usages_operations_async.py new file mode 100644 index 000000000000..2e1d0eebde51 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_usages_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationUsagesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = self.client.usages.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_variable_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_variable_operations.py new file mode 100644 index 000000000000..028a3c34e3cb --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_variable_operations.py @@ -0,0 +1,85 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationVariableOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.variable.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + variable_name="str", + parameters={"name": "str", "description": "str", "isEncrypted": bool, "value": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.variable.update( + resource_group_name=resource_group.name, + automation_account_name="str", + variable_name="str", + parameters={"description": "str", "name": "str", "value": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.variable.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + variable_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.variable.get( + resource_group_name=resource_group.name, + automation_account_name="str", + variable_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.variable.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_variable_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_variable_operations_async.py new file mode 100644 index 000000000000..a27faa4dfe26 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_variable_operations_async.py @@ -0,0 +1,86 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationVariableOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.variable.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + variable_name="str", + parameters={"name": "str", "description": "str", "isEncrypted": bool, "value": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.variable.update( + resource_group_name=resource_group.name, + automation_account_name="str", + variable_name="str", + parameters={"description": "str", "name": "str", "value": "str"}, + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.variable.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + variable_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.variable.get( + resource_group_name=resource_group.name, + automation_account_name="str", + variable_name="str", + api_version="2023-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = self.client.variable.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2023-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_watcher_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_watcher_operations.py new file mode 100644 index 000000000000..d7c9ee6897f4 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_watcher_operations.py @@ -0,0 +1,127 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationWatcherOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.watcher.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + watcher_name="str", + parameters={ + "creationTime": "2020-02-20 00:00:00", + "description": "str", + "etag": "str", + "executionFrequencyInSeconds": 0, + "id": "str", + "lastModifiedBy": "str", + "lastModifiedTime": "2020-02-20 00:00:00", + "location": "str", + "name": "str", + "scriptName": "str", + "scriptParameters": {"str": "str"}, + "scriptRunOn": "str", + "status": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.watcher.get( + resource_group_name=resource_group.name, + automation_account_name="str", + watcher_name="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.watcher.update( + resource_group_name=resource_group.name, + automation_account_name="str", + watcher_name="str", + parameters={"executionFrequencyInSeconds": 0, "name": "str"}, + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.watcher.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + watcher_name="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_start(self, resource_group): + response = self.client.watcher.start( + resource_group_name=resource_group.name, + automation_account_name="str", + watcher_name="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_stop(self, resource_group): + response = self.client.watcher.stop( + resource_group_name=resource_group.name, + automation_account_name="str", + watcher_name="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.watcher.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2020-01-13-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_watcher_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_watcher_operations_async.py new file mode 100644 index 000000000000..2ad268a76f2e --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_watcher_operations_async.py @@ -0,0 +1,128 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationWatcherOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.watcher.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + watcher_name="str", + parameters={ + "creationTime": "2020-02-20 00:00:00", + "description": "str", + "etag": "str", + "executionFrequencyInSeconds": 0, + "id": "str", + "lastModifiedBy": "str", + "lastModifiedTime": "2020-02-20 00:00:00", + "location": "str", + "name": "str", + "scriptName": "str", + "scriptParameters": {"str": "str"}, + "scriptRunOn": "str", + "status": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.watcher.get( + resource_group_name=resource_group.name, + automation_account_name="str", + watcher_name="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.watcher.update( + resource_group_name=resource_group.name, + automation_account_name="str", + watcher_name="str", + parameters={"executionFrequencyInSeconds": 0, "name": "str"}, + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.watcher.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + watcher_name="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_start(self, resource_group): + response = await self.client.watcher.start( + resource_group_name=resource_group.name, + automation_account_name="str", + watcher_name="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_stop(self, resource_group): + response = await self.client.watcher.stop( + resource_group_name=resource_group.name, + automation_account_name="str", + watcher_name="str", + api_version="2020-01-13-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = self.client.watcher.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2020-01-13-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_webhook_operations.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_webhook_operations.py new file mode 100644 index 000000000000..8215ababf7db --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_webhook_operations.py @@ -0,0 +1,111 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationWebhookOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_generate_uri(self, resource_group): + response = self.client.webhook.generate_uri( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2015-10-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.webhook.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + webhook_name="str", + api_version="2015-10-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.webhook.get( + resource_group_name=resource_group.name, + automation_account_name="str", + webhook_name="str", + api_version="2015-10-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.webhook.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + webhook_name="str", + parameters={ + "name": "str", + "expiryTime": "2020-02-20 00:00:00", + "isEnabled": bool, + "parameters": {"str": "str"}, + "runOn": "str", + "runbook": {"name": "str"}, + "uri": "str", + }, + api_version="2015-10-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.webhook.update( + resource_group_name=resource_group.name, + automation_account_name="str", + webhook_name="str", + parameters={ + "description": "str", + "isEnabled": bool, + "name": "str", + "parameters": {"str": "str"}, + "runOn": "str", + }, + api_version="2015-10-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_automation_account(self, resource_group): + response = self.client.webhook.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2015-10-31", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_webhook_operations_async.py b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_webhook_operations_async.py new file mode 100644 index 000000000000..a9d4126a34c9 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/generated_tests/test_automation_webhook_operations_async.py @@ -0,0 +1,112 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.automation.aio import AutomationClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAutomationWebhookOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AutomationClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_generate_uri(self, resource_group): + response = await self.client.webhook.generate_uri( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2015-10-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.webhook.delete( + resource_group_name=resource_group.name, + automation_account_name="str", + webhook_name="str", + api_version="2015-10-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.webhook.get( + resource_group_name=resource_group.name, + automation_account_name="str", + webhook_name="str", + api_version="2015-10-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.webhook.create_or_update( + resource_group_name=resource_group.name, + automation_account_name="str", + webhook_name="str", + parameters={ + "name": "str", + "expiryTime": "2020-02-20 00:00:00", + "isEnabled": bool, + "parameters": {"str": "str"}, + "runOn": "str", + "runbook": {"name": "str"}, + "uri": "str", + }, + api_version="2015-10-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.webhook.update( + resource_group_name=resource_group.name, + automation_account_name="str", + webhook_name="str", + parameters={ + "description": "str", + "isEnabled": bool, + "name": "str", + "parameters": {"str": "str"}, + "runOn": "str", + }, + api_version="2015-10-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_automation_account(self, resource_group): + response = self.client.webhook.list_by_automation_account( + resource_group_name=resource_group.name, + automation_account_name="str", + api_version="2015-10-31", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/automation/azure-mgmt-automation/setup.py b/sdk/automation/azure-mgmt-automation/setup.py index 3fde3b666860..4e69a89494da 100644 --- a/sdk/automation/azure-mgmt-automation/setup.py +++ b/sdk/automation/azure-mgmt-automation/setup.py @@ -1,10 +1,10 @@ #!/usr/bin/env python -#------------------------------------------------------------------------- +# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. -#-------------------------------------------------------------------------- +# -------------------------------------------------------------------------- import re import os.path @@ -16,64 +16,68 @@ PACKAGE_PPRINT_NAME = "Automation" # a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace('-', '/') +package_folder_path = PACKAGE_NAME.replace("-", "/") # a-b-c => a.b.c -namespace_name = PACKAGE_NAME.replace('-', '.') +namespace_name = PACKAGE_NAME.replace("-", ".") # Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, 'version.py') - if os.path.exists(os.path.join(package_folder_path, 'version.py')) - else os.path.join(package_folder_path, '_version.py'), 'r') as fd: - version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', - fd.read(), re.MULTILINE).group(1) +with open( + os.path.join(package_folder_path, "version.py") + if os.path.exists(os.path.join(package_folder_path, "version.py")) + else os.path.join(package_folder_path, "_version.py"), + "r", +) as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) if not version: - raise RuntimeError('Cannot find version information') + raise RuntimeError("Cannot find version information") -with open('README.md', encoding='utf-8') as f: +with open("README.md", encoding="utf-8") as f: readme = f.read() -with open('CHANGELOG.md', encoding='utf-8') as f: +with open("CHANGELOG.md", encoding="utf-8") as f: changelog = f.read() setup( name=PACKAGE_NAME, version=version, - description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), - long_description=readme + '\n\n' + changelog, - long_description_content_type='text/markdown', - license='MIT License', - author='Microsoft Corporation', - author_email='azpysdkhelp@microsoft.com', - url='https://github.com/Azure/azure-sdk-for-python', + description="Microsoft Azure {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + long_description=readme + "\n\n" + changelog, + long_description_content_type="text/markdown", + license="MIT License", + author="Microsoft Corporation", + author_email="azpysdkhelp@microsoft.com", + url="https://github.com/Azure/azure-sdk-for-python", keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product classifiers=[ - 'Development Status :: 4 - Beta', - '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', - 'License :: OSI Approved :: MIT License', + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "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, - packages=find_packages(exclude=[ - 'tests', - # Exclude packages that will be covered by PEP420 or nspkg - 'azure', - 'azure.mgmt', - ]), + packages=find_packages( + exclude=[ + "tests", + # Exclude packages that will be covered by PEP420 or nspkg + "azure", + "azure.mgmt", + ] + ), include_package_data=True, package_data={ - 'pytyped': ['py.typed'], + "pytyped": ["py.typed"], }, install_requires=[ - "msrest>=0.7.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", + "typing-extensions>=4.6.0", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", ], - python_requires=">=3.7" + python_requires=">=3.8", )