From 4de5989808071aa80cd52a07338b6701d459e2f2 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 8 May 2023 07:32:23 +0000 Subject: [PATCH] CodeGen from PR 23832 in Azure/azure-rest-api-specs [Hub Generated] Publish private branch 'dev-maintenance-Microsoft.Maintenance-2023-04-01' (#23832) * Adds base for updating Microsoft.Maintenance from version preview/2022-07-01-preview to version 2023-04-01 * Updates readme * Updates API version in new specs and examples * Updated schema to support confiuration assignment to resource group and subscription. Removed pre/post task schema. * Added 201 response code for Maintenance Configuration, Configuration Assignment and apply update put call. * Added osTypes Filter in configuration assignment. * Updated description for osType property. * Added 202 status for delete operation. Corrected path for resource group get operation. * Fixed linter issue. * Added x-ms-long-running-operation and removed supression * Added x-ms-long-running-operation for delete api. * Added locations. * Suppressed LroErrorContent * Added suporession for 202 status --------- Co-authored-by: Kalpesh Chavan --- .../azure-mgmt-maintenance/_meta.json | 6 +- .../azure/mgmt/maintenance/__init__.py | 2 +- .../azure/mgmt/maintenance/_configuration.py | 17 +- .../_maintenance_management_client.py | 35 +- .../azure/mgmt/maintenance/_serialization.py | 180 ++--- .../azure/mgmt/maintenance/_vendor.py | 5 +- .../azure/mgmt/maintenance/_version.py | 2 +- .../azure/mgmt/maintenance/aio/__init__.py | 2 +- .../mgmt/maintenance/aio/_configuration.py | 12 +- .../aio/_maintenance_management_client.py | 28 +- .../maintenance/aio/operations/__init__.py | 6 +- ...ly_update_for_resource_group_operations.py | 26 +- .../operations/_apply_updates_operations.py | 124 ++-- ...signments_for_resource_group_operations.py | 486 ++++++++++++++ ...ssignments_for_subscriptions_operations.py | 458 +++++++++++++ .../_configuration_assignments_operations.py | 189 +++--- ...ignments_within_subscription_operations.py | 24 +- ...gurations_for_resource_group_operations.py | 26 +- .../_maintenance_configurations_operations.py | 114 ++-- .../maintenance/aio/operations/_operations.py | 24 +- ...c_maintenance_configurations_operations.py | 43 +- .../aio/operations/_updates_operations.py | 47 +- .../azure/mgmt/maintenance/models/__init__.py | 12 +- .../_maintenance_management_client_enums.py | 46 +- .../mgmt/maintenance/models/_models_py3.py | 183 +++--- .../mgmt/maintenance/operations/__init__.py | 6 +- ...ly_update_for_resource_group_operations.py | 32 +- .../operations/_apply_updates_operations.py | 158 +++-- ...signments_for_resource_group_operations.py | 622 ++++++++++++++++++ ...ssignments_for_subscriptions_operations.py | 582 ++++++++++++++++ .../_configuration_assignments_operations.py | 241 ++++--- ...ignments_within_subscription_operations.py | 30 +- ...gurations_for_resource_group_operations.py | 32 +- .../_maintenance_configurations_operations.py | 148 ++--- .../maintenance/operations/_operations.py | 28 +- ...c_maintenance_configurations_operations.py | 55 +- .../operations/_updates_operations.py | 59 +- .../apply_updates_create_or_update.py | 2 +- .../apply_updates_create_or_update_parent.py | 2 +- .../generated_samples/apply_updates_get.py | 2 +- .../apply_updates_get_parent.py | 4 +- .../generated_samples/apply_updates_list.py | 2 +- .../apply_updates_resource_group_list.py | 2 +- ...figuration_assignments_create_or_update.py | 2 +- ...ion_assignments_create_or_update_parent.py | 2 +- .../configuration_assignments_delete.py | 2 +- ...configuration_assignments_delete_parent.py | 2 +- ...nts_for_resource_group_create_or_update.py | 57 ++ ...n_assignments_for_resource_group_delete.py | 41 ++ ...tion_assignments_for_resource_group_get.py | 41 ++ ..._for_resource_group_update_for_resource.py | 57 ++ ...ents_for_subscriptions_create_or_update.py | 57 ++ ...on_assignments_for_subscriptions_delete.py | 40 ++ ...ation_assignments_for_subscriptions_get.py | 40 ++ ...s_for_subscriptions_update_for_resource.py | 57 ++ .../configuration_assignments_get.py | 2 +- .../configuration_assignments_get_parent.py | 2 +- .../configuration_assignments_list.py | 2 +- .../configuration_assignments_list_parent.py | 2 +- ...gnments_result_within_subscription_list.py | 2 +- ...gurations_create_or_update_for_resource.py | 2 +- ...ance_configurations_delete_for_resource.py | 2 +- ...tenance_configurations_get_for_resource.py | 2 +- ...s_get_for_resource_guest_os_patch_linux.py | 2 +- ...get_for_resource_guest_os_patch_windows.py | 2 +- .../maintenance_configurations_list.py | 2 +- ...ance_configurations_resource_group_list.py | 2 +- ...ance_configurations_update_for_resource.py | 2 +- .../generated_samples/operations_list.py | 2 +- ...tenance_configurations_get_for_resource.py | 2 +- .../public_maintenance_configurations_list.py | 2 +- .../generated_samples/updates_list.py | 2 +- .../generated_samples/updates_list_parent.py | 2 +- 73 files changed, 3551 insertions(+), 987 deletions(-) create mode 100644 sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_configuration_assignments_for_resource_group_operations.py create mode 100644 sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_configuration_assignments_for_subscriptions_operations.py create mode 100644 sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_configuration_assignments_for_resource_group_operations.py create mode 100644 sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_configuration_assignments_for_subscriptions_operations.py create mode 100644 sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_resource_group_create_or_update.py create mode 100644 sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_resource_group_delete.py create mode 100644 sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_resource_group_get.py create mode 100644 sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_resource_group_update_for_resource.py create mode 100644 sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_subscriptions_create_or_update.py create mode 100644 sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_subscriptions_delete.py create mode 100644 sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_subscriptions_get.py create mode 100644 sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_subscriptions_update_for_resource.py diff --git a/sdk/maintenance/azure-mgmt-maintenance/_meta.json b/sdk/maintenance/azure-mgmt-maintenance/_meta.json index aac5dfc9b4f28..28d1ca573c3be 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/_meta.json +++ b/sdk/maintenance/azure-mgmt-maintenance/_meta.json @@ -1,11 +1,11 @@ { - "commit": "a2da92ad78961529a087f9d0e65394174ac50794", + "commit": "3ce676c2fc2338288452c140f2f9d65e61018e8f", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest": "3.9.2", "use": [ - "@autorest/python@6.2.1", + "@autorest/python@6.4.8", "@autorest/modelerfour@4.24.3" ], - "autorest_command": "autorest specification/maintenance/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.1 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/maintenance/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.4.8 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/maintenance/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/__init__.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/__init__.py index 25fcc1aa8aa3c..29b55ae4c52be 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/__init__.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/__init__.py @@ -13,7 +13,7 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_configuration.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_configuration.py index a3e01181dc367..441ab14cdc90e 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_configuration.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -36,14 +30,14 @@ class MaintenanceManagementClientConfiguration(Configuration): # pylint: disabl :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-07-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-04-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MaintenanceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-07-01-preview") # type: Literal["2022-07-01-preview"] + api_version: str = kwargs.pop("api_version", "2023-04-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -57,10 +51,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-maintenance/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_maintenance_management_client.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_maintenance_management_client.py index 028563fefaacc..889db09ab794e 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_maintenance_management_client.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_maintenance_management_client.py @@ -12,12 +12,14 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from ._configuration import MaintenanceManagementClientConfiguration from ._serialization import Deserializer, Serializer from .operations import ( ApplyUpdateForResourceGroupOperations, ApplyUpdatesOperations, + ConfigurationAssignmentsForResourceGroupOperations, + ConfigurationAssignmentsForSubscriptionsOperations, ConfigurationAssignmentsOperations, ConfigurationAssignmentsWithinSubscriptionOperations, MaintenanceConfigurationsForResourceGroupOperations, @@ -57,6 +59,14 @@ class MaintenanceManagementClient: # pylint: disable=client-accepts-api-version ConfigurationAssignmentsWithinSubscriptionOperations operations :vartype configuration_assignments_within_subscription: azure.mgmt.maintenance.operations.ConfigurationAssignmentsWithinSubscriptionOperations + :ivar configuration_assignments_for_subscriptions: + ConfigurationAssignmentsForSubscriptionsOperations operations + :vartype configuration_assignments_for_subscriptions: + azure.mgmt.maintenance.operations.ConfigurationAssignmentsForSubscriptionsOperations + :ivar configuration_assignments_for_resource_group: + ConfigurationAssignmentsForResourceGroupOperations operations + :vartype configuration_assignments_for_resource_group: + azure.mgmt.maintenance.operations.ConfigurationAssignmentsForResourceGroupOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.maintenance.operations.Operations :ivar updates: UpdatesOperations operations @@ -68,8 +78,8 @@ class MaintenanceManagementClient: # pylint: disable=client-accepts-api-version :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2022-07-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-04-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ @@ -83,9 +93,9 @@ def __init__( self._config = MaintenanceManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -108,6 +118,12 @@ def __init__( self.configuration_assignments_within_subscription = ConfigurationAssignmentsWithinSubscriptionOperations( self._client, self._config, self._serialize, self._deserialize ) + self.configuration_assignments_for_subscriptions = ConfigurationAssignmentsForSubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.configuration_assignments_for_resource_group = ConfigurationAssignmentsForResourceGroupOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.updates = UpdatesOperations(self._client, self._config, self._serialize, self._deserialize) @@ -133,15 +149,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MaintenanceManagementClient + def __enter__(self) -> "MaintenanceManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_serialization.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_serialization.py index 7c1dedb5133d3..842ae727fbbce 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_serialization.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_serialization.py @@ -25,6 +25,7 @@ # -------------------------------------------------------------------------- # pylint: skip-file +# pyright: reportUnnecessaryTypeIgnoreComment=false from base64 import b64decode, b64encode import calendar @@ -37,23 +38,38 @@ import re import sys import codecs +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + TypeVar, + MutableMapping, + Type, + List, + Mapping, +) try: from urllib import quote # type: ignore except ImportError: - from urllib.parse import quote # type: ignore + from urllib.parse import quote import xml.etree.ElementTree as ET -import isodate - -from typing import Dict, Any, cast, TYPE_CHECKING +import isodate # type: ignore from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback +from azure.core.serialization import NULL as AzureCoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") -if TYPE_CHECKING: - from typing import Optional, Union, AnyStr, IO, Mapping +ModelType = TypeVar("ModelType", bound="Model") +JSON = MutableMapping[str, Any] class RawDeserializer: @@ -65,8 +81,7 @@ class RawDeserializer: CONTEXT_NAME = "deserialized_data" @classmethod - def deserialize_from_text(cls, data, content_type=None): - # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: """Decode data according to content-type. Accept a stream of data as well, but will be load at once in memory for now. @@ -132,8 +147,7 @@ def _json_attemp(data): raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod - def deserialize_from_http_generics(cls, body_bytes, headers): - # type: (Optional[Union[AnyStr, IO]], Mapping) -> Any + def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: """Deserialize from HTTP response. Use bytes and headers to NOT use any requests/aiohttp or whatever @@ -160,8 +174,8 @@ def deserialize_from_http_generics(cls, body_bytes, headers): basestring # type: ignore unicode_str = unicode # type: ignore except NameError: - basestring = str # type: ignore - unicode_str = str # type: ignore + basestring = str + unicode_str = str _LOGGER = logging.getLogger(__name__) @@ -188,7 +202,7 @@ def dst(self, dt): try: - from datetime import timezone as _FixedOffset + from datetime import timezone as _FixedOffset # type: ignore except ImportError: # Python 2.7 class _FixedOffset(datetime.tzinfo): # type: ignore @@ -219,7 +233,7 @@ def __getinitargs__(self): try: from datetime import timezone - TZ_UTC = timezone.utc # type: ignore + TZ_UTC = timezone.utc except ImportError: TZ_UTC = UTC() # type: ignore @@ -276,12 +290,12 @@ class Model(object): serialization and deserialization. """ - _subtype_map = {} # type: Dict[str, Dict[str, Any]] - _attribute_map = {} # type: Dict[str, Dict[str, Any]] - _validation = {} # type: Dict[str, Dict[str, Any]] + _subtype_map: Dict[str, Dict[str, Any]] = {} + _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: 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__) @@ -290,27 +304,27 @@ 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 + cls._xml_map # type: ignore except AttributeError: return False return True @@ -319,13 +333,13 @@ def is_xml_model(cls): def _create_xml_node(cls): """Create XML node.""" try: - xml_map = cls._xml_map + xml_map = cls._xml_map # type: ignore except AttributeError: xml_map = {} 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): + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: """Return the JSON that would be sent to azure from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -339,8 +353,13 @@ def serialize(self, keep_readonly=False, **kwargs): serializer = Serializer(self._infer_class_models()) return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) - 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: @@ -387,7 +406,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. @@ -399,7 +418,12 @@ def deserialize(cls, data, content_type=None): return deserializer(cls.__name__, data, content_type=content_type) @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 @@ -412,8 +436,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, @@ -453,7 +477,7 @@ def _classify(cls, response, objects): return cls flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) try: - return objects[flatten_mapping_type[subtype_value]] + return objects[flatten_mapping_type[subtype_value]] # type: ignore except KeyError: _LOGGER.warning( "Subtype value %s has no mapping, use base class %s.", @@ -521,7 +545,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes=None): + def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -537,7 +561,7 @@ def __init__(self, classes=None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies = dict(classes) if classes else {} + self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -605,14 +629,14 @@ 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) - serialized.set(xml_name, new_attr) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) # type: ignore continue if xml_desc.get("text", False): - serialized.text = new_attr + serialized.text = new_attr # type: ignore continue if isinstance(new_attr, list): - serialized.extend(new_attr) + serialized.extend(new_attr) # type: ignore elif isinstance(new_attr, ET.Element): # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. if "name" not in getattr(orig_attr, "_xml_map", {}): @@ -621,23 +645,22 @@ def _serialize(self, target_obj, data_type=None, **kwargs): new_attr.tag = "}".join([splitted_tag[0], xml_name]) else: new_attr.tag = xml_name - serialized.append(new_attr) + serialized.append(new_attr) # type: ignore 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) - serialized.append(local_node) + serialized.append(local_node) # type: ignore else: # JSON - for k in reversed(keys): - unflattened = {k: new_attr} - new_attr = unflattened + for k in reversed(keys): # type: ignore + new_attr = {k: new_attr} _new_attr = new_attr _serialized = serialized - for k in keys: + for k in keys: # type: ignore if k not in _serialized: - _serialized.update(_new_attr) - _new_attr = _new_attr[k] + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] except ValueError: continue @@ -659,8 +682,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: @@ -675,7 +698,7 @@ def body(self, data, data_type, **kwargs): # We're not able to deal with additional properties for now. deserializer.additional_properties_detection = False if is_xml_model_serialization: - deserializer.key_extractors = [ + deserializer.key_extractors = [ # type: ignore attribute_key_case_insensitive_extractor, ] else: @@ -780,6 +803,8 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: + if data is AzureCoreNull: + return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -843,7 +868,7 @@ def serialize_unicode(cls, data): pass try: - if isinstance(data, unicode): + if isinstance(data, unicode): # type: ignore # Don't change it, JSON and XML ElementTree are totally able # to serialize correctly u'' strings return data @@ -1001,10 +1026,10 @@ def serialize_enum(attr, enum_obj=None): except AttributeError: result = attr try: - enum_obj(result) + enum_obj(result) # type: ignore return result except ValueError: - for enum_value in enum_obj: + for enum_value in enum_obj: # type: ignore if enum_value.value.lower() == str(attr).lower(): return enum_value.value error = "{!r} is not valid value for enum {!r}" @@ -1164,7 +1189,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 @@ -1245,7 +1271,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 @@ -1269,7 +1295,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): @@ -1335,7 +1361,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[ModelType]]] = None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1355,7 +1381,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[ModelType]] = 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 @@ -1416,7 +1442,7 @@ def _deserialize(self, target_obj, data): if data is None: return data try: - attributes = response._attribute_map + attributes = response._attribute_map # type: ignore d_attrs = {} for attr, attr_desc in attributes.items(): # Check empty string. If it's not empty, someone has a real "additionalProperties"... @@ -1444,7 +1470,7 @@ def _deserialize(self, target_obj, data): value = self.deserialize_data(raw_value, attr_desc["type"]) d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name + msg = "Unable to deserialize to object: " + class_name # type: ignore raise_with_traceback(DeserializationError, msg, err) else: additional_properties = self._build_additional_properties(attributes, data) @@ -1474,7 +1500,7 @@ 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 @@ -1489,7 +1515,7 @@ def _classify_target(self, target, data): target = target._classify(data, self.dependencies) 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, @@ -1499,7 +1525,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: @@ -1543,7 +1569,7 @@ def _unpack_content(raw_data, content_type=None): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) + return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data def _instantiate_model(self, response, attrs, additional_properties=None): @@ -1565,7 +1591,7 @@ def _instantiate_model(self, response, attrs, additional_properties=None): response_obj.additional_properties = additional_properties return response_obj except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore raise DeserializationError(msg + str(err)) else: try: @@ -1747,7 +1773,7 @@ def deserialize_unicode(data): # Consider this is real string try: - if isinstance(data, unicode): + if isinstance(data, unicode): # type: ignore return data except NameError: return str(data) @@ -1798,7 +1824,7 @@ def deserialize_bytearray(attr): """ if isinstance(attr, ET.Element): attr = attr.text - return bytearray(b64decode(attr)) + return bytearray(b64decode(attr)) # type: ignore @staticmethod def deserialize_base64(attr): @@ -1810,8 +1836,8 @@ def deserialize_base64(attr): """ if isinstance(attr, ET.Element): attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) - attr = attr + padding + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore encoded = attr.replace("-", "+").replace("_", "/") return b64decode(encoded) @@ -1826,7 +1852,7 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) + return decimal.Decimal(attr) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) raise_with_traceback(DeserializationError, msg, err) @@ -1841,7 +1867,7 @@ def deserialize_long(attr): """ if isinstance(attr, ET.Element): attr = attr.text - return _long_type(attr) + return _long_type(attr) # type: ignore @staticmethod def deserialize_duration(attr): @@ -1871,7 +1897,7 @@ def deserialize_date(attr): """ if isinstance(attr, ET.Element): attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): + 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) @@ -1886,7 +1912,7 @@ def deserialize_time(attr): """ if isinstance(attr, ET.Element): attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) return isodate.parse_time(attr) @@ -1901,7 +1927,7 @@ def deserialize_rfc(attr): if isinstance(attr, ET.Element): attr = attr.text try: - parsed_date = email.utils.parsedate_tz(attr) + parsed_date = email.utils.parsedate_tz(attr) # type: ignore date_obj = datetime.datetime( *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) ) @@ -1924,7 +1950,7 @@ def deserialize_iso(attr): if isinstance(attr, ET.Element): attr = attr.text try: - attr = attr.upper() + attr = attr.upper() # type: ignore match = Deserializer.valid_date.match(attr) if not match: raise ValueError("Invalid datetime string: " + attr) @@ -1960,7 +1986,7 @@ def deserialize_unix(attr): :raises: DeserializationError if format invalid """ if isinstance(attr, ET.Element): - attr = int(attr.text) + attr = int(attr.text) # type: ignore try: date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_vendor.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_vendor.py index 9aad73fc743e7..bd0df84f5319f 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_vendor.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_version.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_version.py index b2fff948b5bb0..e5754a47ce68f 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_version.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.1.0b2" +VERSION = "1.0.0b1" diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/__init__.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/__init__.py index a6f12cf8a1e08..af6f205899408 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/__init__.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/__init__.py @@ -10,7 +10,7 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/_configuration.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/_configuration.py index 37ba2a971635a..1db964a8d97ab 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/_configuration.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -36,14 +30,14 @@ class MaintenanceManagementClientConfiguration(Configuration): # pylint: disabl :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-07-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-04-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MaintenanceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-07-01-preview") # type: Literal["2022-07-01-preview"] + api_version: str = kwargs.pop("api_version", "2023-04-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/_maintenance_management_client.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/_maintenance_management_client.py index de7f892371d04..8b272feb97704 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/_maintenance_management_client.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/_maintenance_management_client.py @@ -12,12 +12,14 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MaintenanceManagementClientConfiguration from .operations import ( ApplyUpdateForResourceGroupOperations, ApplyUpdatesOperations, + ConfigurationAssignmentsForResourceGroupOperations, + ConfigurationAssignmentsForSubscriptionsOperations, ConfigurationAssignmentsOperations, ConfigurationAssignmentsWithinSubscriptionOperations, MaintenanceConfigurationsForResourceGroupOperations, @@ -57,6 +59,14 @@ class MaintenanceManagementClient: # pylint: disable=client-accepts-api-version ConfigurationAssignmentsWithinSubscriptionOperations operations :vartype configuration_assignments_within_subscription: azure.mgmt.maintenance.aio.operations.ConfigurationAssignmentsWithinSubscriptionOperations + :ivar configuration_assignments_for_subscriptions: + ConfigurationAssignmentsForSubscriptionsOperations operations + :vartype configuration_assignments_for_subscriptions: + azure.mgmt.maintenance.aio.operations.ConfigurationAssignmentsForSubscriptionsOperations + :ivar configuration_assignments_for_resource_group: + ConfigurationAssignmentsForResourceGroupOperations operations + :vartype configuration_assignments_for_resource_group: + azure.mgmt.maintenance.aio.operations.ConfigurationAssignmentsForResourceGroupOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.maintenance.aio.operations.Operations :ivar updates: UpdatesOperations operations @@ -68,8 +78,8 @@ class MaintenanceManagementClient: # pylint: disable=client-accepts-api-version :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2022-07-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-04-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ @@ -83,9 +93,9 @@ def __init__( self._config = MaintenanceManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -108,6 +118,12 @@ def __init__( self.configuration_assignments_within_subscription = ConfigurationAssignmentsWithinSubscriptionOperations( self._client, self._config, self._serialize, self._deserialize ) + self.configuration_assignments_for_subscriptions = ConfigurationAssignmentsForSubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.configuration_assignments_for_resource_group = ConfigurationAssignmentsForResourceGroupOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.updates = UpdatesOperations(self._client, self._config, self._serialize, self._deserialize) @@ -140,5 +156,5 @@ async def __aenter__(self) -> "MaintenanceManagementClient": 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/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/__init__.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/__init__.py index 66913fca334e5..722f9ecf0f5e3 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/__init__.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/__init__.py @@ -17,11 +17,13 @@ from ._configuration_assignments_within_subscription_operations import ( ConfigurationAssignmentsWithinSubscriptionOperations, ) +from ._configuration_assignments_for_subscriptions_operations import ConfigurationAssignmentsForSubscriptionsOperations +from ._configuration_assignments_for_resource_group_operations import ConfigurationAssignmentsForResourceGroupOperations from ._operations import Operations from ._updates_operations import UpdatesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -32,6 +34,8 @@ "MaintenanceConfigurationsForResourceGroupOperations", "ApplyUpdateForResourceGroupOperations", "ConfigurationAssignmentsWithinSubscriptionOperations", + "ConfigurationAssignmentsForSubscriptionsOperations", + "ConfigurationAssignmentsForResourceGroupOperations", "Operations", "UpdatesOperations", ] diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_apply_update_for_resource_group_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_apply_update_for_resource_group_operations.py index f41151a8c24c8..4dc87d60c9eae 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_apply_update_for_resource_group_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_apply_update_for_resource_group_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._apply_update_for_resource_group_operations import build_list_request -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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,10 +68,8 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ListApplyUpdate] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListApplyUpdate] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -98,7 +91,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -114,7 +107,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -122,14 +115,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ListApplyUpdate", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -142,4 +136,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/applyUpdates"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/applyUpdates" + } diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_apply_updates_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_apply_updates_operations.py index e1c2e912c6510..d57e89082a0f7 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_apply_updates_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_apply_updates_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -37,10 +36,6 @@ build_list_request, ) -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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,9 +63,9 @@ def __init__(self, *args, **kwargs) -> None: async def get_parent( self, resource_group_name: str, + provider_name: str, resource_parent_type: str, resource_parent_name: str, - provider_name: str, resource_type: str, resource_name: str, apply_update_name: str, @@ -82,12 +77,12 @@ async def get_parent( :param resource_group_name: Resource group name. Required. :type resource_group_name: str + :param provider_name: Resource provider name. Required. + :type provider_name: str :param resource_parent_type: Resource parent type. Required. :type resource_parent_type: str :param resource_parent_name: Resource parent identifier. Required. :type resource_parent_name: str - :param provider_name: Resource provider name. Required. - :type provider_name: str :param resource_type: Resource type. Required. :type resource_type: str :param resource_name: Resource identifier. Required. @@ -110,16 +105,14 @@ async def get_parent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplyUpdate] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApplyUpdate] = kwargs.pop("cls", None) request = build_get_parent_request( resource_group_name=resource_group_name, + provider_name=provider_name, resource_parent_type=resource_parent_type, resource_parent_name=resource_parent_name, - provider_name=provider_name, resource_type=resource_type, resource_name=resource_name, apply_update_name=apply_update_name, @@ -130,10 +123,11 @@ async def get_parent( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -150,7 +144,9 @@ async def get_parent( return deserialized - get_parent.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}"} # type: ignore + get_parent.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}" + } @distributed_trace_async async def get( @@ -192,10 +188,8 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplyUpdate] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApplyUpdate] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -210,10 +204,11 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -230,7 +225,9 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}" + } @distributed_trace_async async def create_or_update_parent( @@ -275,10 +272,8 @@ async def create_or_update_parent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplyUpdate] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApplyUpdate] = kwargs.pop("cls", None) request = build_create_or_update_parent_request( resource_group_name=resource_group_name, @@ -294,27 +289,34 @@ async def create_or_update_parent( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _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]: + 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.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplyUpdate", pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize("ApplyUpdate", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ApplyUpdate", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update_parent.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/default"} # type: ignore + create_or_update_parent.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/default" + } @distributed_trace_async async def create_or_update( @@ -348,10 +350,8 @@ async def create_or_update( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplyUpdate] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApplyUpdate] = kwargs.pop("cls", None) request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -365,27 +365,34 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _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]: + 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.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplyUpdate", pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize("ApplyUpdate", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ApplyUpdate", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/default"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/default" + } @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.ApplyUpdate"]: @@ -401,10 +408,8 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ApplyUpdate"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ListApplyUpdate] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListApplyUpdate] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -425,7 +430,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -441,7 +446,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -449,14 +454,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ListApplyUpdate", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -469,4 +475,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/applyUpdates"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/applyUpdates"} diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_configuration_assignments_for_resource_group_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_configuration_assignments_for_resource_group_operations.py new file mode 100644 index 0000000000000..17f6475b4e350 --- /dev/null +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_configuration_assignments_for_resource_group_operations.py @@ -0,0 +1,486 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._configuration_assignments_for_resource_group_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_update_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ConfigurationAssignmentsForResourceGroupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.maintenance.aio.MaintenanceManagementClient`'s + :attr:`configuration_assignments_for_resource_group` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, configuration_assignment_name: str, **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Get configuration assignment. + + Get configuration assignment for resource.. + + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ConfigurationAssignment] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + configuration_assignment_name=configuration_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + configuration_assignment_name: str, + configuration_assignment: _models.ConfigurationAssignment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Create configuration assignment. + + Register configuration for resource. + + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :param configuration_assignment: The configurationAssignment. Required. + :type configuration_assignment: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + configuration_assignment_name: str, + configuration_assignment: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Create configuration assignment. + + Register configuration for resource. + + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :param configuration_assignment: The configurationAssignment. Required. + :type configuration_assignment: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + configuration_assignment_name: str, + configuration_assignment: Union[_models.ConfigurationAssignment, IO], + **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Create configuration assignment. + + Register configuration for resource. + + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :param configuration_assignment: The configurationAssignment. Is either a + ConfigurationAssignment type or a IO type. Required. + :type configuration_assignment: ~azure.mgmt.maintenance.models.ConfigurationAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationAssignment] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(configuration_assignment, (IO, bytes)): + _content = configuration_assignment + else: + _json = self._serialize.body(configuration_assignment, "ConfigurationAssignment") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + configuration_assignment_name=configuration_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ConfigurationAssignment", 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.Maintenance/configurationAssignments/{configurationAssignmentName}" + } + + @overload + async def update( + self, + resource_group_name: str, + configuration_assignment_name: str, + configuration_assignment: _models.ConfigurationAssignment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Create configuration assignment. + + Register configuration for resource. + + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :param configuration_assignment: The configurationAssignment. Required. + :type configuration_assignment: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + configuration_assignment_name: str, + configuration_assignment: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Create configuration assignment. + + Register configuration for resource. + + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :param configuration_assignment: The configurationAssignment. Required. + :type configuration_assignment: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + configuration_assignment_name: str, + configuration_assignment: Union[_models.ConfigurationAssignment, IO], + **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Create configuration assignment. + + Register configuration for resource. + + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :param configuration_assignment: The configurationAssignment. Is either a + ConfigurationAssignment type or a IO type. Required. + :type configuration_assignment: ~azure.mgmt.maintenance.models.ConfigurationAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationAssignment] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(configuration_assignment, (IO, bytes)): + _content = configuration_assignment + else: + _json = self._serialize.body(configuration_assignment, "ConfigurationAssignment") + + request = build_update_request( + resource_group_name=resource_group_name, + configuration_assignment_name=configuration_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } + + @distributed_trace_async + async def delete( + self, resource_group_name: str, configuration_assignment_name: str, **kwargs: Any + ) -> Optional[_models.ConfigurationAssignment]: + """Unregister configuration for resource. + + Unregister configuration for resource. + + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param configuration_assignment_name: Unique configuration assignment name. Required. + :type configuration_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationAssignment or None or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.ConfigurationAssignment]] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + configuration_assignment_name=configuration_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_configuration_assignments_for_subscriptions_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_configuration_assignments_for_subscriptions_operations.py new file mode 100644 index 0000000000000..3d6de1789a042 --- /dev/null +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_configuration_assignments_for_subscriptions_operations.py @@ -0,0 +1,458 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._configuration_assignments_for_subscriptions_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_update_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ConfigurationAssignmentsForSubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.maintenance.aio.MaintenanceManagementClient`'s + :attr:`configuration_assignments_for_subscriptions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, configuration_assignment_name: str, **kwargs: Any) -> _models.ConfigurationAssignment: + """Get configuration assignment. + + Get configuration assignment for resource.. + + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ConfigurationAssignment] = kwargs.pop("cls", None) + + request = build_get_request( + configuration_assignment_name=configuration_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } + + @overload + async def create_or_update( + self, + configuration_assignment_name: str, + configuration_assignment: _models.ConfigurationAssignment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Create configuration assignment. + + Register configuration for resource. + + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :param configuration_assignment: The configurationAssignment. Required. + :type configuration_assignment: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + configuration_assignment_name: str, + configuration_assignment: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Create configuration assignment. + + Register configuration for resource. + + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :param configuration_assignment: The configurationAssignment. Required. + :type configuration_assignment: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + configuration_assignment_name: str, + configuration_assignment: Union[_models.ConfigurationAssignment, IO], + **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Create configuration assignment. + + Register configuration for resource. + + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :param configuration_assignment: The configurationAssignment. Is either a + ConfigurationAssignment type or a IO type. Required. + :type configuration_assignment: ~azure.mgmt.maintenance.models.ConfigurationAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationAssignment] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(configuration_assignment, (IO, bytes)): + _content = configuration_assignment + else: + _json = self._serialize.body(configuration_assignment, "ConfigurationAssignment") + + request = build_create_or_update_request( + configuration_assignment_name=configuration_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } + + @overload + async def update( + self, + configuration_assignment_name: str, + configuration_assignment: _models.ConfigurationAssignment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Create configuration assignment. + + Register configuration for resource. + + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :param configuration_assignment: The configurationAssignment. Required. + :type configuration_assignment: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + configuration_assignment_name: str, + configuration_assignment: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Create configuration assignment. + + Register configuration for resource. + + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :param configuration_assignment: The configurationAssignment. Required. + :type configuration_assignment: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + configuration_assignment_name: str, + configuration_assignment: Union[_models.ConfigurationAssignment, IO], + **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Create configuration assignment. + + Register configuration for resource. + + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :param configuration_assignment: The configurationAssignment. Is either a + ConfigurationAssignment type or a IO type. Required. + :type configuration_assignment: ~azure.mgmt.maintenance.models.ConfigurationAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationAssignment] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(configuration_assignment, (IO, bytes)): + _content = configuration_assignment + else: + _json = self._serialize.body(configuration_assignment, "ConfigurationAssignment") + + request = build_update_request( + configuration_assignment_name=configuration_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } + + @distributed_trace_async + async def delete( + self, configuration_assignment_name: str, **kwargs: Any + ) -> Optional[_models.ConfigurationAssignment]: + """Unregister configuration for resource. + + Unregister configuration for resource. + + :param configuration_assignment_name: Unique configuration assignment name. Required. + :type configuration_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationAssignment or None or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.ConfigurationAssignment]] = kwargs.pop("cls", None) + + request = build_delete_request( + configuration_assignment_name=configuration_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_configuration_assignments_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_configuration_assignments_operations.py index cd135b332fa05..6b73b32adf89a 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_configuration_assignments_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_configuration_assignments_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -40,10 +39,6 @@ build_list_request, ) -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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -81,7 +76,7 @@ async def get_parent( ) -> _models.ConfigurationAssignment: """Get configuration assignment. - Get configuration for resource. + Get configuration assignment for resource.. :param resource_group_name: Resource group name. Required. :type resource_group_name: str @@ -113,10 +108,8 @@ async def get_parent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationAssignment] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ConfigurationAssignment] = kwargs.pop("cls", None) request = build_get_parent_request( resource_group_name=resource_group_name, @@ -133,10 +126,11 @@ async def get_parent( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -153,7 +147,9 @@ async def get_parent( return deserialized - get_parent.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}"} # type: ignore + get_parent.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } @overload async def create_or_update_parent( @@ -274,8 +270,8 @@ async def create_or_update_parent( :type resource_name: str :param configuration_assignment_name: Configuration assignment name. Required. :type configuration_assignment_name: str - :param configuration_assignment: The configurationAssignment. Is either a model type or a IO - type. Required. + :param configuration_assignment: The configurationAssignment. Is either a + ConfigurationAssignment type or a IO type. Required. :type configuration_assignment: ~azure.mgmt.maintenance.models.ConfigurationAssignment or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -296,11 +292,9 @@ async def create_or_update_parent( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationAssignment] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -328,27 +322,34 @@ async def create_or_update_parent( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _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]: + 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.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update_parent.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}"} # type: ignore + create_or_update_parent.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } @distributed_trace_async async def delete_parent( @@ -396,10 +397,8 @@ async def delete_parent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ConfigurationAssignment]] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.ConfigurationAssignment]] = kwargs.pop("cls", None) request = build_delete_parent_request( resource_group_name=resource_group_name, @@ -416,10 +415,11 @@ async def delete_parent( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -438,7 +438,9 @@ async def delete_parent( return deserialized - delete_parent.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}"} # type: ignore + delete_parent.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } @distributed_trace_async async def get( @@ -452,7 +454,7 @@ async def get( ) -> _models.ConfigurationAssignment: """Get configuration assignment. - Get configuration for resource. + Get configuration assignment for resource.. :param resource_group_name: Resource group name. Required. :type resource_group_name: str @@ -480,10 +482,8 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationAssignment] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ConfigurationAssignment] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -498,10 +498,11 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -518,7 +519,9 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } @overload async def create_or_update( @@ -621,8 +624,8 @@ async def create_or_update( :type resource_name: str :param configuration_assignment_name: Configuration assignment name. Required. :type configuration_assignment_name: str - :param configuration_assignment: The configurationAssignment. Is either a model type or a IO - type. Required. + :param configuration_assignment: The configurationAssignment. Is either a + ConfigurationAssignment type or a IO type. Required. :type configuration_assignment: ~azure.mgmt.maintenance.models.ConfigurationAssignment or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -643,11 +646,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationAssignment] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -673,27 +674,34 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _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]: + 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.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } @distributed_trace_async async def delete( @@ -735,10 +743,8 @@ async def delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ConfigurationAssignment]] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.ConfigurationAssignment]] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -753,10 +759,11 @@ async def delete( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -775,7 +782,9 @@ async def delete( return deserialized - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } @distributed_trace def list_parent( @@ -814,10 +823,8 @@ def list_parent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ListConfigurationAssignmentsResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListConfigurationAssignmentsResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -844,7 +851,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -860,7 +867,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -868,14 +875,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ListConfigurationAssignmentsResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -888,7 +896,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_parent.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments"} # type: ignore + list_parent.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments" + } @distributed_trace def list( @@ -916,10 +926,8 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ListConfigurationAssignmentsResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListConfigurationAssignmentsResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -944,7 +952,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -960,7 +968,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -968,14 +976,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ListConfigurationAssignmentsResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -988,4 +997,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments" + } diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_configuration_assignments_within_subscription_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_configuration_assignments_within_subscription_operations.py index 058d570fe916f..8096fd2ee8d43 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_configuration_assignments_within_subscription_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_configuration_assignments_within_subscription_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._configuration_assignments_within_subscription_operations import build_list_request -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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,10 +68,8 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ConfigurationAssignment" _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ListConfigurationAssignmentsResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListConfigurationAssignmentsResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -97,7 +90,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -113,7 +106,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -121,14 +114,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ListConfigurationAssignmentsResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -141,4 +135,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments"} diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_maintenance_configurations_for_resource_group_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_maintenance_configurations_for_resource_group_operations.py index dd64ac8e4c05e..7a7b184d55617 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_maintenance_configurations_for_resource_group_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_maintenance_configurations_for_resource_group_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._maintenance_configurations_for_resource_group_operations import build_list_request -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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -75,10 +70,8 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ListMaintenanceConfigurationsResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListMaintenanceConfigurationsResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -100,7 +93,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -116,7 +109,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -124,14 +117,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ListMaintenanceConfigurationsResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -144,4 +138,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations" + } diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_maintenance_configurations_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_maintenance_configurations_operations.py index 0238bb8911a2c..1ed054bdef4c3 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_maintenance_configurations_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_maintenance_configurations_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -37,10 +36,6 @@ build_update_request, ) -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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -92,10 +87,8 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.MaintenanceConfiguration] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.MaintenanceConfiguration] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -107,10 +100,11 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -127,7 +121,9 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}" + } @overload async def create_or_update( @@ -203,7 +199,8 @@ async def create_or_update( :type resource_group_name: str :param resource_name: Maintenance Configuration Name. Required. :type resource_name: str - :param configuration: The configuration. Is either a model type or a IO type. Required. + :param configuration: The configuration. Is either a MaintenanceConfiguration type or a IO + type. Required. :type configuration: ~azure.mgmt.maintenance.models.MaintenanceConfiguration or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -224,11 +221,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.MaintenanceConfiguration] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MaintenanceConfiguration] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -251,27 +246,34 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _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]: + 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.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MaintenanceConfiguration", pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize("MaintenanceConfiguration", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("MaintenanceConfiguration", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}" + } @distributed_trace_async async def delete( @@ -301,10 +303,8 @@ async def delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.MaintenanceConfiguration]] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.MaintenanceConfiguration]] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -316,10 +316,11 @@ async def delete( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -338,7 +339,9 @@ async def delete( return deserialized - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}" + } @overload async def update( @@ -414,7 +417,8 @@ async def update( :type resource_group_name: str :param resource_name: Maintenance Configuration Name. Required. :type resource_name: str - :param configuration: The configuration. Is either a model type or a IO type. Required. + :param configuration: The configuration. Is either a MaintenanceConfiguration type or a IO + type. Required. :type configuration: ~azure.mgmt.maintenance.models.MaintenanceConfiguration or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -435,11 +439,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.MaintenanceConfiguration] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MaintenanceConfiguration] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -462,10 +464,11 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -482,7 +485,9 @@ async def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}" + } @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.MaintenanceConfiguration"]: @@ -500,10 +505,8 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.MaintenanceConfiguration _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ListMaintenanceConfigurationsResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListMaintenanceConfigurationsResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -524,7 +527,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -540,7 +543,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -548,14 +551,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ListMaintenanceConfigurationsResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -568,4 +572,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/maintenanceConfigurations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/maintenanceConfigurations"} diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_operations.py index 90e8c75dbce64..7a27f7984ad55 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._operations import build_list_request -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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,10 +66,8 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationsListResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationsListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -94,7 +87,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -110,7 +103,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -118,14 +111,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -138,4 +132,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/Microsoft.Maintenance/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Maintenance/operations"} diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_public_maintenance_configurations_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_public_maintenance_configurations_operations.py index 72685c657e890..9dc3d5a0a504d 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_public_maintenance_configurations_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_public_maintenance_configurations_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -31,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._public_maintenance_configurations_operations import build_get_request, build_list_request -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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,10 +69,8 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.MaintenanceConfiguration _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ListMaintenanceConfigurationsResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListMaintenanceConfigurationsResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -98,7 +91,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -114,7 +107,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -122,14 +115,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ListMaintenanceConfigurationsResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -142,7 +136,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations" + } @distributed_trace_async async def get(self, resource_name: str, **kwargs: Any) -> _models.MaintenanceConfiguration: @@ -168,10 +164,8 @@ async def get(self, resource_name: str, **kwargs: Any) -> _models.MaintenanceCon _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.MaintenanceConfiguration] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.MaintenanceConfiguration] = kwargs.pop("cls", None) request = build_get_request( resource_name=resource_name, @@ -182,10 +176,11 @@ async def get(self, resource_name: str, **kwargs: Any) -> _models.MaintenanceCon params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -202,4 +197,6 @@ async def get(self, resource_name: str, **kwargs: Any) -> _models.MaintenanceCon return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/{resourceName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/{resourceName}" + } diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_updates_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_updates_operations.py index 8114098390c49..f1f8efd0e766c 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_updates_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_updates_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._updates_operations import build_list_parent_request, build_list_request -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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -92,10 +87,8 @@ def list_parent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ListUpdatesResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListUpdatesResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -122,7 +115,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -138,7 +131,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -146,14 +139,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ListUpdatesResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -166,7 +160,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_parent.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates"} # type: ignore + list_parent.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates" + } @distributed_trace def list( @@ -192,10 +188,8 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ListUpdatesResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListUpdatesResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -220,7 +214,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -236,7 +230,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -244,14 +238,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ListUpdatesResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -264,4 +259,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates" + } diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/__init__.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/__init__.py index ab2a71efac418..ee401483070ef 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/__init__.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/__init__.py @@ -8,6 +8,7 @@ from ._models_py3 import ApplyUpdate from ._models_py3 import ConfigurationAssignment +from ._models_py3 import ConfigurationAssignmentFilterProperties from ._models_py3 import ErrorDetails from ._models_py3 import InputLinuxParameters from ._models_py3 import InputPatchConfiguration @@ -23,23 +24,24 @@ from ._models_py3 import OperationsListResult from ._models_py3 import Resource from ._models_py3 import SystemData -from ._models_py3 import TaskProperties +from ._models_py3 import TagSettingsProperties from ._models_py3 import Update from ._maintenance_management_client_enums import CreatedByType from ._maintenance_management_client_enums import ImpactType from ._maintenance_management_client_enums import MaintenanceScope from ._maintenance_management_client_enums import RebootOptions -from ._maintenance_management_client_enums import TaskScope +from ._maintenance_management_client_enums import TagOperators from ._maintenance_management_client_enums import UpdateStatus from ._maintenance_management_client_enums import Visibility from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ "ApplyUpdate", "ConfigurationAssignment", + "ConfigurationAssignmentFilterProperties", "ErrorDetails", "InputLinuxParameters", "InputPatchConfiguration", @@ -55,13 +57,13 @@ "OperationsListResult", "Resource", "SystemData", - "TaskProperties", + "TagSettingsProperties", "Update", "CreatedByType", "ImpactType", "MaintenanceScope", "RebootOptions", - "TaskScope", + "TagOperators", "UpdateStatus", "Visibility", ] diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/_maintenance_management_client_enums.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/_maintenance_management_client_enums.py index a0c977056f134..0b35a1d6ee3b1 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/_maintenance_management_client_enums.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/_maintenance_management_client_enums.py @@ -22,34 +22,34 @@ class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): class ImpactType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The impact type.""" - #: Pending updates has no impact on resource. NONE = "None" - #: Pending updates can freeze network or disk io operation on resource. + """Pending updates has no impact on resource.""" FREEZE = "Freeze" - #: Pending updates can cause resource to restart. + """Pending updates can freeze network or disk io operation on resource.""" RESTART = "Restart" - #: Pending updates can redeploy resource. + """Pending updates can cause resource to restart.""" REDEPLOY = "Redeploy" + """Pending updates can redeploy resource.""" class MaintenanceScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets maintenanceScope of the configuration.""" - #: This maintenance scope controls installation of azure platform updates i.e. services on - #: physical nodes hosting customer VMs. HOST = "Host" - #: This maintenance scope controls the default update maintenance of the Azure Resource + """This maintenance scope controls installation of azure platform updates i.e. services on + #: physical nodes hosting customer VMs.""" RESOURCE = "Resource" - #: This maintenance scope controls os image installation on VM/VMSS + """This maintenance scope controls the default update maintenance of the Azure Resource""" OS_IMAGE = "OSImage" - #: This maintenance scope controls extension installation on VM/VMSS + """This maintenance scope controls os image installation on VM/VMSS""" EXTENSION = "Extension" - #: This maintenance scope controls installation of windows and linux packages on VM/VMSS + """This maintenance scope controls extension installation on VM/VMSS""" IN_GUEST_PATCH = "InGuestPatch" - #: This maintenance scope controls installation of SQL server platform updates. + """This maintenance scope controls installation of windows and linux packages on VM/VMSS""" SQLDB = "SQLDB" - #: This maintenance scope controls installation of SQL managed instance platform update. + """This maintenance scope controls installation of SQL server platform updates.""" SQL_MANAGED_INSTANCE = "SQLManagedInstance" + """This maintenance scope controls installation of SQL managed instance platform update.""" class RebootOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -62,32 +62,32 @@ class RebootOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): ALWAYS = "Always" -class TaskScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Global Task execute once when schedule trigger. Resource task execute for each VM.""" +class TagOperators(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Filter VMs by Any or All specified tags.""" - GLOBAL = "Global" - RESOURCE = "Resource" + ALL = "All" + ANY = "Any" class UpdateStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status.""" - #: There are pending updates to be installed. PENDING = "Pending" - #: Updates installation are in progress. + """There are pending updates to be installed.""" IN_PROGRESS = "InProgress" - #: All updates are successfully applied. + """Updates installation are in progress.""" COMPLETED = "Completed" - #: Updates installation failed but are ready to retry again. + """All updates are successfully applied.""" RETRY_NOW = "RetryNow" - #: Updates installation failed and should be retried later. + """Updates installation failed but are ready to retry again.""" RETRY_LATER = "RetryLater" + """Updates installation failed and should be retried later.""" class Visibility(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the visibility of the configuration. The default value is 'Custom'.""" - #: Only visible to users with permissions. CUSTOM = "Custom" - #: Visible to all users. + """Only visible to users with permissions.""" PUBLIC = "Public" + """Visible to all users.""" diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/_models_py3.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/_models_py3.py index fa85410b96a55..dcc7eefff3801 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/_models_py3.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/_models_py3.py @@ -54,7 +54,7 @@ class Resource(_serialization.Model): "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None @@ -109,8 +109,8 @@ def __init__( status: Optional[Union[str, "_models.UpdateStatus"]] = None, resource_id: Optional[str] = None, last_update_time: Optional[datetime.datetime] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword status: The status. Known values are: "Pending", "InProgress", "Completed", "RetryNow", and "RetryLater". @@ -146,6 +146,8 @@ class ConfigurationAssignment(Resource): :vartype maintenance_configuration_id: str :ivar resource_id: The unique resourceId. :vartype resource_id: str + :ivar filter: Properties of the configuration assignment. + :vartype filter: ~azure.mgmt.maintenance.models.ConfigurationAssignmentFilterProperties """ _validation = { @@ -163,6 +165,7 @@ class ConfigurationAssignment(Resource): "location": {"key": "location", "type": "str"}, "maintenance_configuration_id": {"key": "properties.maintenanceConfigurationId", "type": "str"}, "resource_id": {"key": "properties.resourceId", "type": "str"}, + "filter": {"key": "properties.filter", "type": "ConfigurationAssignmentFilterProperties"}, } def __init__( @@ -171,8 +174,9 @@ def __init__( location: Optional[str] = None, maintenance_configuration_id: Optional[str] = None, resource_id: Optional[str] = None, - **kwargs - ): + filter: Optional["_models.ConfigurationAssignmentFilterProperties"] = None, # pylint: disable=redefined-builtin + **kwargs: Any + ) -> None: """ :keyword location: Location of the resource. :paramtype location: str @@ -180,11 +184,67 @@ def __init__( :paramtype maintenance_configuration_id: str :keyword resource_id: The unique resourceId. :paramtype resource_id: str + :keyword filter: Properties of the configuration assignment. + :paramtype filter: ~azure.mgmt.maintenance.models.ConfigurationAssignmentFilterProperties """ super().__init__(**kwargs) self.location = location self.maintenance_configuration_id = maintenance_configuration_id self.resource_id = resource_id + self.filter = filter + + +class ConfigurationAssignmentFilterProperties(_serialization.Model): + """Azure query for the update configuration. + + :ivar resource_types: List of allowed resources. + :vartype resource_types: list[str] + :ivar resource_groups: List of allowed resource groups. + :vartype resource_groups: list[str] + :ivar os_types: List of allowed operating systems. + :vartype os_types: list[str] + :ivar locations: List of locations to scope the query to. + :vartype locations: list[str] + :ivar tag_settings: Tag settings for the VM. + :vartype tag_settings: ~azure.mgmt.maintenance.models.TagSettingsProperties + """ + + _attribute_map = { + "resource_types": {"key": "resourceTypes", "type": "[str]"}, + "resource_groups": {"key": "resourceGroups", "type": "[str]"}, + "os_types": {"key": "osTypes", "type": "[str]"}, + "locations": {"key": "locations", "type": "[str]"}, + "tag_settings": {"key": "tagSettings", "type": "TagSettingsProperties"}, + } + + def __init__( + self, + *, + resource_types: Optional[List[str]] = None, + resource_groups: Optional[List[str]] = None, + os_types: Optional[List[str]] = None, + locations: Optional[List[str]] = None, + tag_settings: Optional["_models.TagSettingsProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword resource_types: List of allowed resources. + :paramtype resource_types: list[str] + :keyword resource_groups: List of allowed resource groups. + :paramtype resource_groups: list[str] + :keyword os_types: List of allowed operating systems. + :paramtype os_types: list[str] + :keyword locations: List of locations to scope the query to. + :paramtype locations: list[str] + :keyword tag_settings: Tag settings for the VM. + :paramtype tag_settings: ~azure.mgmt.maintenance.models.TagSettingsProperties + """ + super().__init__(**kwargs) + self.resource_types = resource_types + self.resource_groups = resource_groups + self.os_types = os_types + self.locations = locations + self.tag_settings = tag_settings class ErrorDetails(_serialization.Model): @@ -202,7 +262,7 @@ class ErrorDetails(_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: Service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response. @@ -238,8 +298,8 @@ def __init__( package_name_masks_to_exclude: Optional[List[str]] = None, package_name_masks_to_include: Optional[List[str]] = None, classifications_to_include: Optional[List[str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword package_name_masks_to_exclude: Package names to be excluded for patching. :paramtype package_name_masks_to_exclude: list[str] @@ -267,20 +327,12 @@ class InputPatchConfiguration(_serialization.Model): :ivar linux_parameters: Input parameters specific to patching Linux machine. For Windows machines, do not pass this property. :vartype linux_parameters: ~azure.mgmt.maintenance.models.InputLinuxParameters - :ivar pre_tasks: List of pre tasks. e.g. [{'source' :'runbook', 'taskScope': 'Global', - 'parameters': { 'arg1': 'value1'}}]. - :vartype pre_tasks: list[~azure.mgmt.maintenance.models.TaskProperties] - :ivar post_tasks: List of post tasks. e.g. [{'source' :'runbook', 'taskScope': 'Resource', - 'parameters': { 'arg1': 'value1'}}]. - :vartype post_tasks: list[~azure.mgmt.maintenance.models.TaskProperties] """ _attribute_map = { "reboot_setting": {"key": "rebootSetting", "type": "str"}, "windows_parameters": {"key": "windowsParameters", "type": "InputWindowsParameters"}, "linux_parameters": {"key": "linuxParameters", "type": "InputLinuxParameters"}, - "pre_tasks": {"key": "tasks.preTasks", "type": "[TaskProperties]"}, - "post_tasks": {"key": "tasks.postTasks", "type": "[TaskProperties]"}, } def __init__( @@ -289,10 +341,8 @@ def __init__( reboot_setting: Union[str, "_models.RebootOptions"] = "IfRequired", windows_parameters: Optional["_models.InputWindowsParameters"] = None, linux_parameters: Optional["_models.InputLinuxParameters"] = None, - pre_tasks: Optional[List["_models.TaskProperties"]] = None, - post_tasks: Optional[List["_models.TaskProperties"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword reboot_setting: Possible reboot preference as defined by the user based on which it would be decided to reboot the machine or not after the patch operation is completed. Known @@ -304,19 +354,11 @@ def __init__( :keyword linux_parameters: Input parameters specific to patching Linux machine. For Windows machines, do not pass this property. :paramtype linux_parameters: ~azure.mgmt.maintenance.models.InputLinuxParameters - :keyword pre_tasks: List of pre tasks. e.g. [{'source' :'runbook', 'taskScope': 'Global', - 'parameters': { 'arg1': 'value1'}}]. - :paramtype pre_tasks: list[~azure.mgmt.maintenance.models.TaskProperties] - :keyword post_tasks: List of post tasks. e.g. [{'source' :'runbook', 'taskScope': 'Resource', - 'parameters': { 'arg1': 'value1'}}]. - :paramtype post_tasks: list[~azure.mgmt.maintenance.models.TaskProperties] """ super().__init__(**kwargs) self.reboot_setting = reboot_setting self.windows_parameters = windows_parameters self.linux_parameters = linux_parameters - self.pre_tasks = pre_tasks - self.post_tasks = post_tasks class InputWindowsParameters(_serialization.Model): @@ -346,8 +388,8 @@ def __init__( kb_numbers_to_include: Optional[List[str]] = None, classifications_to_include: Optional[List[str]] = None, exclude_kbs_requiring_reboot: Optional[bool] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword kb_numbers_to_exclude: Windows KBID to be excluded for patching. :paramtype kb_numbers_to_exclude: list[str] @@ -376,7 +418,7 @@ class ListApplyUpdate(_serialization.Model): "value": {"key": "value", "type": "[ApplyUpdate]"}, } - def __init__(self, *, value: Optional[List["_models.ApplyUpdate"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.ApplyUpdate"]] = None, **kwargs: Any) -> None: """ :keyword value: The list of apply updates. :paramtype value: list[~azure.mgmt.maintenance.models.ApplyUpdate] @@ -396,7 +438,7 @@ class ListConfigurationAssignmentsResult(_serialization.Model): "value": {"key": "value", "type": "[ConfigurationAssignment]"}, } - def __init__(self, *, value: Optional[List["_models.ConfigurationAssignment"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.ConfigurationAssignment"]] = None, **kwargs: Any) -> None: """ :keyword value: The list of configuration Assignments. :paramtype value: list[~azure.mgmt.maintenance.models.ConfigurationAssignment] @@ -416,7 +458,7 @@ class ListMaintenanceConfigurationsResult(_serialization.Model): "value": {"key": "value", "type": "[MaintenanceConfiguration]"}, } - def __init__(self, *, value: Optional[List["_models.MaintenanceConfiguration"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.MaintenanceConfiguration"]] = None, **kwargs: Any) -> None: """ :keyword value: The list of maintenance Configurations. :paramtype value: list[~azure.mgmt.maintenance.models.MaintenanceConfiguration] @@ -436,7 +478,7 @@ class ListUpdatesResult(_serialization.Model): "value": {"key": "value", "type": "[Update]"}, } - def __init__(self, *, value: Optional[List["_models.Update"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.Update"]] = None, **kwargs: Any) -> None: """ :keyword value: The pending updates. :paramtype value: list[~azure.mgmt.maintenance.models.Update] @@ -548,8 +590,8 @@ def __init__( duration: Optional[str] = None, time_zone: Optional[str] = None, recur_every: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Gets or sets location of the resource. :paramtype location: str @@ -626,7 +668,7 @@ class MaintenanceError(_serialization.Model): "error": {"key": "error", "type": "ErrorDetails"}, } - def __init__(self, *, error: Optional["_models.ErrorDetails"] = None, **kwargs): + def __init__(self, *, error: Optional["_models.ErrorDetails"] = None, **kwargs: Any) -> None: """ :keyword error: Details of the error. :paramtype error: ~azure.mgmt.maintenance.models.ErrorDetails @@ -666,8 +708,8 @@ def __init__( origin: Optional[str] = None, properties: Optional[JSON] = None, is_data_action: Optional[bool] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Name of the operation. :paramtype name: str @@ -715,8 +757,8 @@ def __init__( resource: Optional[str] = None, operation: Optional[str] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword provider: Name of the provider. :paramtype provider: str @@ -745,7 +787,7 @@ class OperationsListResult(_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: A collection of operations. :paramtype value: list[~azure.mgmt.maintenance.models.Operation] @@ -791,8 +833,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 @@ -818,45 +860,38 @@ def __init__( self.last_modified_at = last_modified_at -class TaskProperties(_serialization.Model): - """Task properties of the software update configuration. +class TagSettingsProperties(_serialization.Model): + """Tag filter information for the VM. - :ivar parameters: Gets or sets the parameters of the task. - :vartype parameters: dict[str, str] - :ivar source: Gets or sets the name of the runbook. - :vartype source: str - :ivar task_scope: Global Task execute once when schedule trigger. Resource task execute for - each VM. Known values are: "Global" and "Resource". - :vartype task_scope: str or ~azure.mgmt.maintenance.models.TaskScope + :ivar tags: Dictionary of tags with its list of values. + :vartype tags: dict[str, list[str]] + :ivar filter_operator: Filter VMs by Any or All specified tags. Known values are: "All" and + "Any". + :vartype filter_operator: str or ~azure.mgmt.maintenance.models.TagOperators """ _attribute_map = { - "parameters": {"key": "parameters", "type": "{str}"}, - "source": {"key": "source", "type": "str"}, - "task_scope": {"key": "taskScope", "type": "str"}, + "tags": {"key": "tags", "type": "{[str]}"}, + "filter_operator": {"key": "filterOperator", "type": "str"}, } def __init__( self, *, - parameters: Optional[Dict[str, str]] = None, - source: Optional[str] = None, - task_scope: Union[str, "_models.TaskScope"] = "Global", - **kwargs - ): - """ - :keyword parameters: Gets or sets the parameters of the task. - :paramtype parameters: dict[str, str] - :keyword source: Gets or sets the name of the runbook. - :paramtype source: str - :keyword task_scope: Global Task execute once when schedule trigger. Resource task execute for - each VM. Known values are: "Global" and "Resource". - :paramtype task_scope: str or ~azure.mgmt.maintenance.models.TaskScope + tags: Optional[Dict[str, List[str]]] = None, + filter_operator: Optional[Union[str, "_models.TagOperators"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Dictionary of tags with its list of values. + :paramtype tags: dict[str, list[str]] + :keyword filter_operator: Filter VMs by Any or All specified tags. Known values are: "All" and + "Any". + :paramtype filter_operator: str or ~azure.mgmt.maintenance.models.TagOperators """ super().__init__(**kwargs) - self.parameters = parameters - self.source = source - self.task_scope = task_scope + self.tags = tags + self.filter_operator = filter_operator class Update(_serialization.Model): @@ -898,8 +933,8 @@ def __init__( impact_duration_in_sec: Optional[int] = None, not_before: Optional[datetime.datetime] = None, resource_id: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword maintenance_scope: The impact area. Known values are: "Host", "Resource", "OSImage", "Extension", "InGuestPatch", "SQLDB", and "SQLManagedInstance". diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/__init__.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/__init__.py index 66913fca334e5..722f9ecf0f5e3 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/__init__.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/__init__.py @@ -17,11 +17,13 @@ from ._configuration_assignments_within_subscription_operations import ( ConfigurationAssignmentsWithinSubscriptionOperations, ) +from ._configuration_assignments_for_subscriptions_operations import ConfigurationAssignmentsForSubscriptionsOperations +from ._configuration_assignments_for_resource_group_operations import ConfigurationAssignmentsForResourceGroupOperations from ._operations import Operations from ._updates_operations import UpdatesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -32,6 +34,8 @@ "MaintenanceConfigurationsForResourceGroupOperations", "ApplyUpdateForResourceGroupOperations", "ConfigurationAssignmentsWithinSubscriptionOperations", + "ConfigurationAssignmentsForSubscriptionsOperations", + "ConfigurationAssignmentsForResourceGroupOperations", "Operations", "UpdatesOperations", ] diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_apply_update_for_resource_group_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_apply_update_for_resource_group_operations.py index e2edbb45af8c8..00275ba064ff1 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_apply_update_for_resource_group_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_apply_update_for_resource_group_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +40,7 @@ def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -60,7 +53,7 @@ def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -106,10 +99,8 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.App _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ListApplyUpdate] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListApplyUpdate] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -131,7 +122,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -147,7 +138,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -155,14 +146,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ListApplyUpdate", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -175,4 +167,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/applyUpdates"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/applyUpdates" + } diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_apply_updates_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_apply_updates_operations.py index 95d47562d6b80..13286c3a0eb5d 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_apply_updates_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_apply_updates_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,9 +38,9 @@ def build_get_parent_request( resource_group_name: str, + provider_name: str, resource_parent_type: str, resource_parent_name: str, - provider_name: str, resource_type: str, resource_name: str, apply_update_name: str, @@ -55,9 +50,7 @@ def build_get_parent_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -68,15 +61,15 @@ def build_get_parent_request( path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "providerName": _SERIALIZER.url("provider_name", provider_name, "str"), "resourceParentType": _SERIALIZER.url("resource_parent_type", resource_parent_type, "str"), "resourceParentName": _SERIALIZER.url("resource_parent_name", resource_parent_name, "str"), - "providerName": _SERIALIZER.url("provider_name", provider_name, "str"), "resourceType": _SERIALIZER.url("resource_type", resource_type, "str"), "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), "applyUpdateName": _SERIALIZER.url("apply_update_name", apply_update_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -99,9 +92,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -118,7 +109,7 @@ def build_get_request( "applyUpdateName": _SERIALIZER.url("apply_update_name", apply_update_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -142,9 +133,7 @@ def build_create_or_update_parent_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -162,7 +151,7 @@ def build_create_or_update_parent_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -184,9 +173,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 = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -202,7 +189,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -217,9 +204,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 = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -228,7 +213,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -262,9 +247,9 @@ def __init__(self, *args, **kwargs): def get_parent( self, resource_group_name: str, + provider_name: str, resource_parent_type: str, resource_parent_name: str, - provider_name: str, resource_type: str, resource_name: str, apply_update_name: str, @@ -276,12 +261,12 @@ def get_parent( :param resource_group_name: Resource group name. Required. :type resource_group_name: str + :param provider_name: Resource provider name. Required. + :type provider_name: str :param resource_parent_type: Resource parent type. Required. :type resource_parent_type: str :param resource_parent_name: Resource parent identifier. Required. :type resource_parent_name: str - :param provider_name: Resource provider name. Required. - :type provider_name: str :param resource_type: Resource type. Required. :type resource_type: str :param resource_name: Resource identifier. Required. @@ -304,16 +289,14 @@ def get_parent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplyUpdate] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApplyUpdate] = kwargs.pop("cls", None) request = build_get_parent_request( resource_group_name=resource_group_name, + provider_name=provider_name, resource_parent_type=resource_parent_type, resource_parent_name=resource_parent_name, - provider_name=provider_name, resource_type=resource_type, resource_name=resource_name, apply_update_name=apply_update_name, @@ -324,10 +307,11 @@ def get_parent( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -344,7 +328,9 @@ def get_parent( return deserialized - get_parent.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}"} # type: ignore + get_parent.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}" + } @distributed_trace def get( @@ -386,10 +372,8 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplyUpdate] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApplyUpdate] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -404,10 +388,11 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -424,7 +409,9 @@ def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}" + } @distributed_trace def create_or_update_parent( @@ -469,10 +456,8 @@ def create_or_update_parent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplyUpdate] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApplyUpdate] = kwargs.pop("cls", None) request = build_create_or_update_parent_request( resource_group_name=resource_group_name, @@ -488,27 +473,34 @@ def create_or_update_parent( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _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]: + 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.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplyUpdate", pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize("ApplyUpdate", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ApplyUpdate", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update_parent.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/default"} # type: ignore + create_or_update_parent.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/default" + } @distributed_trace def create_or_update( @@ -542,10 +534,8 @@ def create_or_update( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplyUpdate] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApplyUpdate] = kwargs.pop("cls", None) request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -559,27 +549,34 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _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]: + 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.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplyUpdate", pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize("ApplyUpdate", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ApplyUpdate", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/default"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/default" + } @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.ApplyUpdate"]: @@ -595,10 +592,8 @@ def list(self, **kwargs: Any) -> Iterable["_models.ApplyUpdate"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ListApplyUpdate] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListApplyUpdate] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -619,7 +614,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -635,7 +630,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -643,14 +638,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ListApplyUpdate", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -663,4 +659,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/applyUpdates"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/applyUpdates"} diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_configuration_assignments_for_resource_group_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_configuration_assignments_for_resource_group_operations.py new file mode 100644 index 0000000000000..c23878f6da251 --- /dev/null +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_configuration_assignments_for_resource_group_operations.py @@ -0,0 +1,622 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, configuration_assignment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "configurationAssignmentName": _SERIALIZER.url( + "configuration_assignment_name", configuration_assignment_name, "str", pattern=r"^.+$" + ), + } + + _url: str = _format_url_section(_url, **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, configuration_assignment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-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.Maintenance/configurationAssignments/{configurationAssignmentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "configurationAssignmentName": _SERIALIZER.url( + "configuration_assignment_name", configuration_assignment_name, "str" + ), + } + + _url: str = _format_url_section(_url, **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, configuration_assignment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-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.Maintenance/configurationAssignments/{configurationAssignmentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "configurationAssignmentName": _SERIALIZER.url( + "configuration_assignment_name", configuration_assignment_name, "str" + ), + } + + _url: str = _format_url_section(_url, **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_delete_request( + resource_group_name: str, configuration_assignment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "configurationAssignmentName": _SERIALIZER.url( + "configuration_assignment_name", configuration_assignment_name, "str" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class ConfigurationAssignmentsForResourceGroupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.maintenance.MaintenanceManagementClient`'s + :attr:`configuration_assignments_for_resource_group` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, configuration_assignment_name: str, **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Get configuration assignment. + + Get configuration assignment for resource.. + + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ConfigurationAssignment] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + configuration_assignment_name=configuration_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + configuration_assignment_name: str, + configuration_assignment: _models.ConfigurationAssignment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Create configuration assignment. + + Register configuration for resource. + + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :param configuration_assignment: The configurationAssignment. Required. + :type configuration_assignment: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + configuration_assignment_name: str, + configuration_assignment: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Create configuration assignment. + + Register configuration for resource. + + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :param configuration_assignment: The configurationAssignment. Required. + :type configuration_assignment: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + configuration_assignment_name: str, + configuration_assignment: Union[_models.ConfigurationAssignment, IO], + **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Create configuration assignment. + + Register configuration for resource. + + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :param configuration_assignment: The configurationAssignment. Is either a + ConfigurationAssignment type or a IO type. Required. + :type configuration_assignment: ~azure.mgmt.maintenance.models.ConfigurationAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationAssignment] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(configuration_assignment, (IO, bytes)): + _content = configuration_assignment + else: + _json = self._serialize.body(configuration_assignment, "ConfigurationAssignment") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + configuration_assignment_name=configuration_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ConfigurationAssignment", 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.Maintenance/configurationAssignments/{configurationAssignmentName}" + } + + @overload + def update( + self, + resource_group_name: str, + configuration_assignment_name: str, + configuration_assignment: _models.ConfigurationAssignment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Create configuration assignment. + + Register configuration for resource. + + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :param configuration_assignment: The configurationAssignment. Required. + :type configuration_assignment: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + configuration_assignment_name: str, + configuration_assignment: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Create configuration assignment. + + Register configuration for resource. + + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :param configuration_assignment: The configurationAssignment. Required. + :type configuration_assignment: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + configuration_assignment_name: str, + configuration_assignment: Union[_models.ConfigurationAssignment, IO], + **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Create configuration assignment. + + Register configuration for resource. + + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :param configuration_assignment: The configurationAssignment. Is either a + ConfigurationAssignment type or a IO type. Required. + :type configuration_assignment: ~azure.mgmt.maintenance.models.ConfigurationAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationAssignment] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(configuration_assignment, (IO, bytes)): + _content = configuration_assignment + else: + _json = self._serialize.body(configuration_assignment, "ConfigurationAssignment") + + request = build_update_request( + resource_group_name=resource_group_name, + configuration_assignment_name=configuration_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } + + @distributed_trace + def delete( + self, resource_group_name: str, configuration_assignment_name: str, **kwargs: Any + ) -> Optional[_models.ConfigurationAssignment]: + """Unregister configuration for resource. + + Unregister configuration for resource. + + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param configuration_assignment_name: Unique configuration assignment name. Required. + :type configuration_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationAssignment or None or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.ConfigurationAssignment]] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + configuration_assignment_name=configuration_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_configuration_assignments_for_subscriptions_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_configuration_assignments_for_subscriptions_operations.py new file mode 100644 index 0000000000000..c853e4b20ada9 --- /dev/null +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_configuration_assignments_for_subscriptions_operations.py @@ -0,0 +1,582 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(configuration_assignment_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "configurationAssignmentName": _SERIALIZER.url( + "configuration_assignment_name", configuration_assignment_name, "str" + ), + } + + _url: str = _format_url_section(_url, **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( + configuration_assignment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "configurationAssignmentName": _SERIALIZER.url( + "configuration_assignment_name", configuration_assignment_name, "str" + ), + } + + _url: str = _format_url_section(_url, **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(configuration_assignment_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "configurationAssignmentName": _SERIALIZER.url( + "configuration_assignment_name", configuration_assignment_name, "str" + ), + } + + _url: str = _format_url_section(_url, **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_delete_request(configuration_assignment_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "configurationAssignmentName": _SERIALIZER.url( + "configuration_assignment_name", configuration_assignment_name, "str" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class ConfigurationAssignmentsForSubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.maintenance.MaintenanceManagementClient`'s + :attr:`configuration_assignments_for_subscriptions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, configuration_assignment_name: str, **kwargs: Any) -> _models.ConfigurationAssignment: + """Get configuration assignment. + + Get configuration assignment for resource.. + + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ConfigurationAssignment] = kwargs.pop("cls", None) + + request = build_get_request( + configuration_assignment_name=configuration_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } + + @overload + def create_or_update( + self, + configuration_assignment_name: str, + configuration_assignment: _models.ConfigurationAssignment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Create configuration assignment. + + Register configuration for resource. + + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :param configuration_assignment: The configurationAssignment. Required. + :type configuration_assignment: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + configuration_assignment_name: str, + configuration_assignment: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Create configuration assignment. + + Register configuration for resource. + + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :param configuration_assignment: The configurationAssignment. Required. + :type configuration_assignment: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + configuration_assignment_name: str, + configuration_assignment: Union[_models.ConfigurationAssignment, IO], + **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Create configuration assignment. + + Register configuration for resource. + + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :param configuration_assignment: The configurationAssignment. Is either a + ConfigurationAssignment type or a IO type. Required. + :type configuration_assignment: ~azure.mgmt.maintenance.models.ConfigurationAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationAssignment] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(configuration_assignment, (IO, bytes)): + _content = configuration_assignment + else: + _json = self._serialize.body(configuration_assignment, "ConfigurationAssignment") + + request = build_create_or_update_request( + configuration_assignment_name=configuration_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } + + @overload + def update( + self, + configuration_assignment_name: str, + configuration_assignment: _models.ConfigurationAssignment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Create configuration assignment. + + Register configuration for resource. + + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :param configuration_assignment: The configurationAssignment. Required. + :type configuration_assignment: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + configuration_assignment_name: str, + configuration_assignment: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Create configuration assignment. + + Register configuration for resource. + + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :param configuration_assignment: The configurationAssignment. Required. + :type configuration_assignment: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + configuration_assignment_name: str, + configuration_assignment: Union[_models.ConfigurationAssignment, IO], + **kwargs: Any + ) -> _models.ConfigurationAssignment: + """Create configuration assignment. + + Register configuration for resource. + + :param configuration_assignment_name: Configuration assignment name. Required. + :type configuration_assignment_name: str + :param configuration_assignment: The configurationAssignment. Is either a + ConfigurationAssignment type or a IO type. Required. + :type configuration_assignment: ~azure.mgmt.maintenance.models.ConfigurationAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ConfigurationAssignment or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationAssignment] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(configuration_assignment, (IO, bytes)): + _content = configuration_assignment + else: + _json = self._serialize.body(configuration_assignment, "ConfigurationAssignment") + + request = build_update_request( + configuration_assignment_name=configuration_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } + + @distributed_trace + def delete(self, configuration_assignment_name: str, **kwargs: Any) -> Optional[_models.ConfigurationAssignment]: + """Unregister configuration for resource. + + Unregister configuration for resource. + + :param configuration_assignment_name: Unique configuration assignment name. Required. + :type configuration_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationAssignment or None or the result of cls(response) + :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.ConfigurationAssignment]] = kwargs.pop("cls", None) + + request = build_delete_request( + configuration_assignment_name=configuration_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_configuration_assignments_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_configuration_assignments_operations.py index 9bc92dedaf773..4109961a17953 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_configuration_assignments_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_configuration_assignments_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -30,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,9 +50,7 @@ def build_get_parent_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,7 +71,7 @@ def build_get_parent_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -103,10 +96,8 @@ def build_create_or_update_parent_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -127,7 +118,7 @@ def build_create_or_update_parent_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,9 +145,7 @@ def build_delete_parent_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -177,7 +166,7 @@ def build_delete_parent_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -200,9 +189,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -221,7 +208,7 @@ def build_get_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -244,10 +231,8 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -266,7 +251,7 @@ def build_create_or_update_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -291,9 +276,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -312,7 +295,7 @@ def build_delete_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -336,9 +319,7 @@ def build_list_parent_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -356,7 +337,7 @@ def build_list_parent_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -378,9 +359,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -396,7 +375,7 @@ def build_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -440,7 +419,7 @@ def get_parent( ) -> _models.ConfigurationAssignment: """Get configuration assignment. - Get configuration for resource. + Get configuration assignment for resource.. :param resource_group_name: Resource group name. Required. :type resource_group_name: str @@ -472,10 +451,8 @@ def get_parent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationAssignment] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ConfigurationAssignment] = kwargs.pop("cls", None) request = build_get_parent_request( resource_group_name=resource_group_name, @@ -492,10 +469,11 @@ def get_parent( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -512,7 +490,9 @@ def get_parent( return deserialized - get_parent.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}"} # type: ignore + get_parent.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } @overload def create_or_update_parent( @@ -633,8 +613,8 @@ def create_or_update_parent( :type resource_name: str :param configuration_assignment_name: Configuration assignment name. Required. :type configuration_assignment_name: str - :param configuration_assignment: The configurationAssignment. Is either a model type or a IO - type. Required. + :param configuration_assignment: The configurationAssignment. Is either a + ConfigurationAssignment type or a IO type. Required. :type configuration_assignment: ~azure.mgmt.maintenance.models.ConfigurationAssignment or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -655,11 +635,9 @@ def create_or_update_parent( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationAssignment] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -687,27 +665,34 @@ def create_or_update_parent( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _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]: + 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.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update_parent.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}"} # type: ignore + create_or_update_parent.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } @distributed_trace def delete_parent( @@ -755,10 +740,8 @@ def delete_parent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ConfigurationAssignment]] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.ConfigurationAssignment]] = kwargs.pop("cls", None) request = build_delete_parent_request( resource_group_name=resource_group_name, @@ -775,10 +758,11 @@ def delete_parent( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -797,7 +781,9 @@ def delete_parent( return deserialized - delete_parent.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}"} # type: ignore + delete_parent.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } @distributed_trace def get( @@ -811,7 +797,7 @@ def get( ) -> _models.ConfigurationAssignment: """Get configuration assignment. - Get configuration for resource. + Get configuration assignment for resource.. :param resource_group_name: Resource group name. Required. :type resource_group_name: str @@ -839,10 +825,8 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationAssignment] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ConfigurationAssignment] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -857,10 +841,11 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -877,7 +862,9 @@ def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } @overload def create_or_update( @@ -980,8 +967,8 @@ def create_or_update( :type resource_name: str :param configuration_assignment_name: Configuration assignment name. Required. :type configuration_assignment_name: str - :param configuration_assignment: The configurationAssignment. Is either a model type or a IO - type. Required. + :param configuration_assignment: The configurationAssignment. Is either a + ConfigurationAssignment type or a IO type. Required. :type configuration_assignment: ~azure.mgmt.maintenance.models.ConfigurationAssignment or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -1002,11 +989,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ConfigurationAssignment] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1032,27 +1017,34 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _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]: + 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.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ConfigurationAssignment", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } @distributed_trace def delete( @@ -1094,10 +1086,8 @@ def delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ConfigurationAssignment]] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.ConfigurationAssignment]] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -1112,10 +1102,11 @@ def delete( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1134,7 +1125,9 @@ def delete( return deserialized - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" + } @distributed_trace def list_parent( @@ -1172,10 +1165,8 @@ def list_parent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ListConfigurationAssignmentsResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListConfigurationAssignmentsResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -1202,7 +1193,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -1218,7 +1209,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1226,14 +1217,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ListConfigurationAssignmentsResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1246,7 +1238,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_parent.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments"} # type: ignore + list_parent.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments" + } @distributed_trace def list( @@ -1273,10 +1267,8 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ListConfigurationAssignmentsResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListConfigurationAssignmentsResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -1301,7 +1293,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -1317,7 +1309,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1325,14 +1317,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ListConfigurationAssignmentsResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1345,4 +1338,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments" + } diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_configuration_assignments_within_subscription_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_configuration_assignments_within_subscription_operations.py index 12d1e228ff8de..5eaac024cd54f 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_configuration_assignments_within_subscription_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_configuration_assignments_within_subscription_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +40,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 = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -58,7 +51,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -103,10 +96,8 @@ def list(self, **kwargs: Any) -> Iterable["_models.ConfigurationAssignment"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ListConfigurationAssignmentsResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListConfigurationAssignmentsResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -127,7 +118,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -143,7 +134,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -151,14 +142,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ListConfigurationAssignmentsResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -171,4 +163,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments"} diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_maintenance_configurations_for_resource_group_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_maintenance_configurations_for_resource_group_operations.py index ff73cd0b762e8..41d49053cd46c 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_maintenance_configurations_for_resource_group_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_maintenance_configurations_for_resource_group_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +40,7 @@ def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -60,7 +53,7 @@ def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -107,10 +100,8 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Mai _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ListMaintenanceConfigurationsResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListMaintenanceConfigurationsResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -132,7 +123,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -148,7 +139,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -156,14 +147,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ListMaintenanceConfigurationsResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -176,4 +168,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations" + } diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_maintenance_configurations_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_maintenance_configurations_operations.py index 38c2b4c2b8d2c..e10db02f1b4ff 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_maintenance_configurations_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_maintenance_configurations_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -30,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +40,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +54,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,10 +71,8 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -95,7 +86,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,9 +105,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -130,7 +119,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -147,10 +136,8 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -164,7 +151,7 @@ def build_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -181,9 +168,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 = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -194,7 +179,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -250,10 +235,8 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.MaintenanceConfiguration] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.MaintenanceConfiguration] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -265,10 +248,11 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -285,7 +269,9 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}" + } @overload def create_or_update( @@ -361,7 +347,8 @@ def create_or_update( :type resource_group_name: str :param resource_name: Maintenance Configuration Name. Required. :type resource_name: str - :param configuration: The configuration. Is either a model type or a IO type. Required. + :param configuration: The configuration. Is either a MaintenanceConfiguration type or a IO + type. Required. :type configuration: ~azure.mgmt.maintenance.models.MaintenanceConfiguration or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -382,11 +369,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.MaintenanceConfiguration] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MaintenanceConfiguration] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -409,27 +394,34 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _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]: + 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.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MaintenanceConfiguration", pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize("MaintenanceConfiguration", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("MaintenanceConfiguration", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}" + } @distributed_trace def delete( @@ -459,10 +451,8 @@ def delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.MaintenanceConfiguration]] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.MaintenanceConfiguration]] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -474,10 +464,11 @@ def delete( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -496,7 +487,9 @@ def delete( return deserialized - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}" + } @overload def update( @@ -572,7 +565,8 @@ def update( :type resource_group_name: str :param resource_name: Maintenance Configuration Name. Required. :type resource_name: str - :param configuration: The configuration. Is either a model type or a IO type. Required. + :param configuration: The configuration. Is either a MaintenanceConfiguration type or a IO + type. Required. :type configuration: ~azure.mgmt.maintenance.models.MaintenanceConfiguration or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -593,11 +587,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.MaintenanceConfiguration] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MaintenanceConfiguration] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -620,10 +612,11 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -640,7 +633,9 @@ def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}" + } @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.MaintenanceConfiguration"]: @@ -657,10 +652,8 @@ def list(self, **kwargs: Any) -> Iterable["_models.MaintenanceConfiguration"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ListMaintenanceConfigurationsResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListMaintenanceConfigurationsResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -681,7 +674,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -697,7 +690,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -705,14 +698,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ListMaintenanceConfigurationsResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -725,4 +719,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/maintenanceConfigurations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/maintenanceConfigurations"} diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_operations.py index 9ba637a80b36f..31a2a30e65535 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +40,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 = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -95,10 +88,8 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationsListResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationsListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -118,7 +109,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -134,7 +125,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -142,14 +133,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -162,4 +154,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/Microsoft.Maintenance/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Maintenance/operations"} diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_public_maintenance_configurations_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_public_maintenance_configurations_operations.py index 2c2d449f879e1..08bdcf517bea2 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_public_maintenance_configurations_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_public_maintenance_configurations_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +40,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 = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +52,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -74,9 +67,7 @@ def build_get_request(resource_name: str, subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -89,7 +80,7 @@ def build_get_request(resource_name: str, subscription_id: str, **kwargs: Any) - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -134,10 +125,8 @@ def list(self, **kwargs: Any) -> Iterable["_models.MaintenanceConfiguration"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ListMaintenanceConfigurationsResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListMaintenanceConfigurationsResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -158,7 +147,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -174,7 +163,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -182,14 +171,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ListMaintenanceConfigurationsResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -202,7 +192,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations" + } @distributed_trace def get(self, resource_name: str, **kwargs: Any) -> _models.MaintenanceConfiguration: @@ -228,10 +220,8 @@ def get(self, resource_name: str, **kwargs: Any) -> _models.MaintenanceConfigura _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.MaintenanceConfiguration] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.MaintenanceConfiguration] = kwargs.pop("cls", None) request = build_get_request( resource_name=resource_name, @@ -242,10 +232,11 @@ def get(self, resource_name: str, **kwargs: Any) -> _models.MaintenanceConfigura params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -262,4 +253,6 @@ def get(self, resource_name: str, **kwargs: Any) -> _models.MaintenanceConfigura return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/{resourceName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/{resourceName}" + } diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_updates_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_updates_operations.py index 0ea6e8015a2ef..258f483ed4847 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_updates_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_updates_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,9 +49,7 @@ def build_list_parent_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -74,7 +67,7 @@ def build_list_parent_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -96,9 +89,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", "2022-07-01-preview") - ) # type: Literal["2022-07-01-preview"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -114,7 +105,7 @@ def build_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -179,10 +170,8 @@ def list_parent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ListUpdatesResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListUpdatesResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -209,7 +198,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -225,7 +214,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -233,14 +222,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ListUpdatesResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -253,7 +243,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_parent.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates"} # type: ignore + list_parent.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates" + } @distributed_trace def list( @@ -279,10 +271,8 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2022-07-01-preview"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ListUpdatesResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ListUpdatesResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -307,7 +297,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -323,7 +313,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -331,14 +321,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ListUpdatesResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -351,4 +342,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates" + } diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/apply_updates_create_or_update.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/apply_updates_create_or_update.py index ab11de511ab14..944a1b1b30cb1 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/apply_updates_create_or_update.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/apply_updates_create_or_update.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/ApplyUpdates_CreateOrUpdate.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/ApplyUpdates_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/apply_updates_create_or_update_parent.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/apply_updates_create_or_update_parent.py index 7f15a09a7cf96..033a285ea08c3 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/apply_updates_create_or_update_parent.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/apply_updates_create_or_update_parent.py @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/ApplyUpdates_CreateOrUpdateParent.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/ApplyUpdates_CreateOrUpdateParent.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/apply_updates_get.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/apply_updates_get.py index e22ccf50b832a..18794ab9aa2b8 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/apply_updates_get.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/apply_updates_get.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/ApplyUpdates_Get.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/ApplyUpdates_Get.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/apply_updates_get_parent.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/apply_updates_get_parent.py index b669caf590202..546d9cb43137a 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/apply_updates_get_parent.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/apply_updates_get_parent.py @@ -31,9 +31,9 @@ def main(): response = client.apply_updates.get_parent( resource_group_name="examplerg", + provider_name="Microsoft.Compute", resource_parent_type="virtualMachineScaleSets", resource_parent_name="smdtest1", - provider_name="Microsoft.Compute", resource_type="virtualMachines", resource_name="smdvm1", apply_update_name="e9b9685d-78e4-44c4-a81c-64a14f9b87b6", @@ -41,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/ApplyUpdates_GetParent.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/ApplyUpdates_GetParent.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/apply_updates_list.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/apply_updates_list.py index a41457e8e92c2..99f0f9c7f122f 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/apply_updates_list.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/apply_updates_list.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/ApplyUpdates_List.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/ApplyUpdates_List.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/apply_updates_resource_group_list.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/apply_updates_resource_group_list.py index 310b723a5a54f..4c3dbe86b3100 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/apply_updates_resource_group_list.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/apply_updates_resource_group_list.py @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/ApplyUpdatesResourceGroup_List.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/ApplyUpdatesResourceGroup_List.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_create_or_update.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_create_or_update.py index e0e94206b4f3c..5b69014230919 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_create_or_update.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_create_or_update.py @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/ConfigurationAssignments_CreateOrUpdate.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/ConfigurationAssignments_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_create_or_update_parent.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_create_or_update_parent.py index e2a772f23a83e..276850868c974 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_create_or_update_parent.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_create_or_update_parent.py @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/ConfigurationAssignments_CreateOrUpdateParent.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/ConfigurationAssignments_CreateOrUpdateParent.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_delete.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_delete.py index 5dccc98c7db0d..a318fee9fc1b9 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_delete.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_delete.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/ConfigurationAssignments_Delete.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/ConfigurationAssignments_Delete.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_delete_parent.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_delete_parent.py index dd9f8e131af5b..eebd02e052c62 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_delete_parent.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_delete_parent.py @@ -41,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/ConfigurationAssignments_DeleteParent.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/ConfigurationAssignments_DeleteParent.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_resource_group_create_or_update.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_resource_group_create_or_update.py new file mode 100644 index 0000000000000..244a9a495aadf --- /dev/null +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_resource_group_create_or_update.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 azure.identity import DefaultAzureCredential +from azure.mgmt.maintenance import MaintenanceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-maintenance +# USAGE + python configuration_assignments_for_resource_group_create_or_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MaintenanceManagementClient( + credential=DefaultAzureCredential(), + subscription_id="5b4b650e-28b9-4790-b3ab-ddbd88d727c4", + ) + + response = client.configuration_assignments_for_resource_group.create_or_update( + resource_group_name="examplerg", + configuration_assignment_name="workervmConfiguration", + configuration_assignment={ + "properties": { + "filter": { + "locations": ["Japan East", "UK South"], + "resourceTypes": ["Microsoft.HybridCompute/machines", "Microsoft.Compute/virtualMachines"], + "tagSettings": { + "filterOperator": "Any", + "tags": { + "tag1": ["tag1Value1", "tag1Value2", "tag1Value3"], + "tag2": ["tag2Value1", "tag2Value2", "tag2Value3"], + }, + }, + }, + "maintenanceConfigurationId": "/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/ConfigurationAssignmentsForResourceGroup_CreateOrUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_resource_group_delete.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_resource_group_delete.py new file mode 100644 index 0000000000000..96cb68f96eaf0 --- /dev/null +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_resource_group_delete.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.maintenance import MaintenanceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-maintenance +# USAGE + python configuration_assignments_for_resource_group_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MaintenanceManagementClient( + credential=DefaultAzureCredential(), + subscription_id="5b4b650e-28b9-4790-b3ab-ddbd88d727c4", + ) + + response = client.configuration_assignments_for_resource_group.delete( + resource_group_name="examplerg", + configuration_assignment_name="workervmConfiguration", + ) + print(response) + + +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/ConfigurationAssignmentsForResourceGroup_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_resource_group_get.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_resource_group_get.py new file mode 100644 index 0000000000000..f0aa60ef64394 --- /dev/null +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_resource_group_get.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.maintenance import MaintenanceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-maintenance +# USAGE + python configuration_assignments_for_resource_group_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MaintenanceManagementClient( + credential=DefaultAzureCredential(), + subscription_id="5b4b650e-28b9-4790-b3ab-ddbd88d727c4", + ) + + response = client.configuration_assignments_for_resource_group.get( + resource_group_name="examplerg", + configuration_assignment_name="workervmConfiguration", + ) + print(response) + + +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/ConfigurationAssignmentsForResourceGroup_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_resource_group_update_for_resource.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_resource_group_update_for_resource.py new file mode 100644 index 0000000000000..4d7470cb83c2c --- /dev/null +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_resource_group_update_for_resource.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 azure.identity import DefaultAzureCredential +from azure.mgmt.maintenance import MaintenanceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-maintenance +# USAGE + python configuration_assignments_for_resource_group_update_for_resource.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 = MaintenanceManagementClient( + credential=DefaultAzureCredential(), + subscription_id="5b4b650e-28b9-4790-b3ab-ddbd88d727c4", + ) + + response = client.configuration_assignments_for_resource_group.update( + resource_group_name="examplerg", + configuration_assignment_name="workervmConfiguration", + configuration_assignment={ + "properties": { + "filter": { + "locations": ["Japan East", "UK South"], + "resourceTypes": ["Microsoft.HybridCompute/machines", "Microsoft.Compute/virtualMachines"], + "tagSettings": { + "filterOperator": "Any", + "tags": { + "tag1": ["tag1Value1", "tag1Value2", "tag1Value3"], + "tag2": ["tag2Value1", "tag2Value2", "tag2Value3"], + }, + }, + }, + "maintenanceConfigurationId": "/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/ConfigurationAssignmentsForResourceGroup_UpdateForResource.json +if __name__ == "__main__": + main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_subscriptions_create_or_update.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_subscriptions_create_or_update.py new file mode 100644 index 0000000000000..818d26f1f19c8 --- /dev/null +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_subscriptions_create_or_update.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 azure.identity import DefaultAzureCredential +from azure.mgmt.maintenance import MaintenanceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-maintenance +# USAGE + python configuration_assignments_for_subscriptions_create_or_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MaintenanceManagementClient( + credential=DefaultAzureCredential(), + subscription_id="5b4b650e-28b9-4790-b3ab-ddbd88d727c4", + ) + + response = client.configuration_assignments_for_subscriptions.create_or_update( + configuration_assignment_name="workervmConfiguration", + configuration_assignment={ + "properties": { + "filter": { + "locations": ["Japan East", "UK South"], + "resourceGroups": ["RG1", "RG2"], + "resourceTypes": ["Microsoft.HybridCompute/machines", "Microsoft.Compute/virtualMachines"], + "tagSettings": { + "filterOperator": "Any", + "tags": { + "tag1": ["tag1Value1", "tag1Value2", "tag1Value3"], + "tag2": ["tag2Value1", "tag2Value2", "tag2Value3"], + }, + }, + }, + "maintenanceConfigurationId": "/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/ConfigurationAssignmentsForSubscriptions_CreateOrUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_subscriptions_delete.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_subscriptions_delete.py new file mode 100644 index 0000000000000..93a90e6484d12 --- /dev/null +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_subscriptions_delete.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.maintenance import MaintenanceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-maintenance +# USAGE + python configuration_assignments_for_subscriptions_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MaintenanceManagementClient( + credential=DefaultAzureCredential(), + subscription_id="5b4b650e-28b9-4790-b3ab-ddbd88d727c4", + ) + + response = client.configuration_assignments_for_subscriptions.delete( + configuration_assignment_name="workervmConfiguration", + ) + print(response) + + +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/ConfigurationAssignmentsForSubscriptions_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_subscriptions_get.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_subscriptions_get.py new file mode 100644 index 0000000000000..11972f42cf66c --- /dev/null +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_subscriptions_get.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.maintenance import MaintenanceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-maintenance +# USAGE + python configuration_assignments_for_subscriptions_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MaintenanceManagementClient( + credential=DefaultAzureCredential(), + subscription_id="5b4b650e-28b9-4790-b3ab-ddbd88d727c4", + ) + + response = client.configuration_assignments_for_subscriptions.get( + configuration_assignment_name="workervmConfiguration", + ) + print(response) + + +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/ConfigurationAssignmentsForSubscriptions_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_subscriptions_update_for_resource.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_subscriptions_update_for_resource.py new file mode 100644 index 0000000000000..ddcbf3d3ee320 --- /dev/null +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_for_subscriptions_update_for_resource.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 azure.identity import DefaultAzureCredential +from azure.mgmt.maintenance import MaintenanceManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-maintenance +# USAGE + python configuration_assignments_for_subscriptions_update_for_resource.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 = MaintenanceManagementClient( + credential=DefaultAzureCredential(), + subscription_id="5b4b650e-28b9-4790-b3ab-ddbd88d727c4", + ) + + response = client.configuration_assignments_for_subscriptions.update( + configuration_assignment_name="workervmConfiguration", + configuration_assignment={ + "properties": { + "filter": { + "locations": ["Japan East", "UK South"], + "resourceGroups": ["RG1", "RG2"], + "resourceTypes": ["Microsoft.HybridCompute/machines", "Microsoft.Compute/virtualMachines"], + "tagSettings": { + "filterOperator": "Any", + "tags": { + "tag1": ["tag1Value1", "tag1Value2", "tag1Value3"], + "tag2": ["tag2Value1", "tag2Value2", "tag2Value3"], + }, + }, + }, + "maintenanceConfigurationId": "/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/ConfigurationAssignmentsForSubscriptions_UpdateForResource.json +if __name__ == "__main__": + main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_get.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_get.py index fc13bb6376004..e63be2b986644 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_get.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_get.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/ConfigurationAssignments_Get.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/ConfigurationAssignments_Get.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_get_parent.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_get_parent.py index 91bb7980cf069..8e8316bd4884f 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_get_parent.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_get_parent.py @@ -41,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/ConfigurationAssignments_GetParent.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/ConfigurationAssignments_GetParent.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_list.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_list.py index 055676105feb0..c2fe31d56bb7e 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_list.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_list.py @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/ConfigurationAssignments_List.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/ConfigurationAssignments_List.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_list_parent.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_list_parent.py index 2a9e9e6b49e03..47c047d72ee81 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_list_parent.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_list_parent.py @@ -41,6 +41,6 @@ def main(): print(item) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/ConfigurationAssignments_ListParent.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/ConfigurationAssignments_ListParent.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_result_within_subscription_list.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_result_within_subscription_list.py index 65921c85108bb..3a4be705671ee 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_result_within_subscription_list.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/configuration_assignments_result_within_subscription_list.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/ConfigurationAssignmentsResultWithinSubscription_List.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/ConfigurationAssignmentsResultWithinSubscription_List.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_create_or_update_for_resource.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_create_or_update_for_resource.py index c95180cf1a727..6ab7f60004481 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_create_or_update_for_resource.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_create_or_update_for_resource.py @@ -51,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/MaintenanceConfigurations_CreateOrUpdateForResource.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/MaintenanceConfigurations_CreateOrUpdateForResource.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_delete_for_resource.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_delete_for_resource.py index 201000b9376e1..d43ab99792d60 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_delete_for_resource.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_delete_for_resource.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/MaintenanceConfigurations_DeleteForResource.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/MaintenanceConfigurations_DeleteForResource.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_get_for_resource.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_get_for_resource.py index 5e43e70dd0a51..8285084d68a77 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_get_for_resource.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_get_for_resource.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/MaintenanceConfigurations_GetForResource.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/MaintenanceConfigurations_GetForResource.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_get_for_resource_guest_os_patch_linux.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_get_for_resource_guest_os_patch_linux.py index be4d2b375fdb4..f9b23681d1b1d 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_get_for_resource_guest_os_patch_linux.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_get_for_resource_guest_os_patch_linux.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/MaintenanceConfigurations_GetForResource_GuestOSPatchLinux.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/MaintenanceConfigurations_GetForResource_GuestOSPatchLinux.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_get_for_resource_guest_os_patch_windows.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_get_for_resource_guest_os_patch_windows.py index 1bef7393e7d74..5384f66a6132f 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_get_for_resource_guest_os_patch_windows.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_get_for_resource_guest_os_patch_windows.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/MaintenanceConfigurations_GetForResource_GuestOSPatchWindows.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/MaintenanceConfigurations_GetForResource_GuestOSPatchWindows.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_list.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_list.py index 818e4dc49d144..43e20a5c655e9 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_list.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_list.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/MaintenanceConfigurations_List.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/MaintenanceConfigurations_List.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_resource_group_list.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_resource_group_list.py index ce95514b7598c..80f54fb1c87c6 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_resource_group_list.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_resource_group_list.py @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/MaintenanceConfigurationsResourceGroup_List.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/MaintenanceConfigurationsResourceGroup_List.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_update_for_resource.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_update_for_resource.py index 198fa11090a28..034f303722795 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_update_for_resource.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/maintenance_configurations_update_for_resource.py @@ -51,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/MaintenanceConfigurations_UpdateForResource.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/MaintenanceConfigurations_UpdateForResource.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/operations_list.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/operations_list.py index 57811594d9102..a0806e1dd237b 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/operations_list.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/operations_list.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/Operations_List.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/Operations_List.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/public_maintenance_configurations_get_for_resource.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/public_maintenance_configurations_get_for_resource.py index c194553e1a67e..b2f020c15bb49 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/public_maintenance_configurations_get_for_resource.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/public_maintenance_configurations_get_for_resource.py @@ -35,6 +35,6 @@ def main(): print(response) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/PublicMaintenanceConfigurations_GetForResource.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/PublicMaintenanceConfigurations_GetForResource.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/public_maintenance_configurations_list.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/public_maintenance_configurations_list.py index ebaeeb157cd65..9e05e83ee833f 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/public_maintenance_configurations_list.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/public_maintenance_configurations_list.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/PublicMaintenanceConfigurations_List.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/PublicMaintenanceConfigurations_List.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/updates_list.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/updates_list.py index 95a2446998796..b9dd8c42d4899 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/updates_list.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/updates_list.py @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/Updates_List.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/Updates_List.json if __name__ == "__main__": main() diff --git a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/updates_list_parent.py b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/updates_list_parent.py index e5e653faafd42..5844e08ea6396 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/generated_samples/updates_list_parent.py +++ b/sdk/maintenance/azure-mgmt-maintenance/generated_samples/updates_list_parent.py @@ -41,6 +41,6 @@ def main(): print(item) -# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2022-07-01-preview/examples/Updates_ListParent.json +# x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/stable/2023-04-01/examples/Updates_ListParent.json if __name__ == "__main__": main()