diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/_meta.json b/sdk/resourcehealth/azure-mgmt-resourcehealth/_meta.json index 348f67fb8209..b47d1dc98a9d 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/_meta.json +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/_meta.json @@ -1,11 +1,15 @@ { - "commit": "1fea23ac36b111293dc3efc30f725e9ebb790f7f", + "commit": "0c115976508540feb1ecb3216b1d875d4ad1bb48", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.9.7", "use": [ - "@autorest/python@6.4.12", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.7.1", + "@autorest/modelerfour@4.26.2" ], - "autorest_command": "autorest specification/resourcehealth/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.4.12 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", - "readme": "specification/resourcehealth/resource-manager/readme.md" + "autorest_command": "autorest specification/resourcehealth/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", + "readme": "specification/resourcehealth/resource-manager/readme.md", + "package-preview-2023-10": "2023-10-09 01:38:27 -0700 d9f13b4f513be56ca9bb14e97f8a699ac9a5a1cc Microsoft.ResourceHealth/preview/2023-10-01-preview/ResourceHealth.json", + "package-2022-10": "2023-03-30 22:08:54 -0700 635b756c218c138de49cf3f4a3204e75630fc300 Microsoft.ResourceHealth/stable/2022-10-01/ResourceHealth.json", + "package-2018-07-01": "2023-03-29 21:56:50 -0700 f0e86b9b4ab51cddbc451c9ead25781b552342f0 Microsoft.ResourceHealth/stable/2018-07-01/ResourceHealth.json", + "package-2015-01": "2023-03-29 21:56:50 -0700 f0e86b9b4ab51cddbc451c9ead25781b552342f0 Microsoft.ResourceHealth/stable/2015-01-01/resourcehealth.json" } \ No newline at end of file diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/_resource_health_mgmt_client.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/_resource_health_mgmt_client.py index f2bbdd9a0288..458500607467 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/_resource_health_mgmt_client.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/_resource_health_mgmt_client.py @@ -70,6 +70,8 @@ def __init__( profile: KnownProfiles=KnownProfiles.default, **kwargs: Any ): + if api_version: + kwargs.setdefault('api_version', api_version) self._config = ResourceHealthMgmtClientConfiguration(credential, subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(ResourceHealthMgmtClient, self).__init__( @@ -88,6 +90,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2015-01-01: :mod:`v2015_01_01.models` * 2018-07-01: :mod:`v2018_07_01.models` * 2022-10-01: :mod:`v2022_10_01.models` + * 2023-10-01-preview: :mod:`v2023_10_01_preview.models` """ if api_version == '2015-01-01': from .v2015_01_01 import models @@ -98,6 +101,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-10-01': from .v2022_10_01 import models return models + elif api_version == '2023-10-01-preview': + from .v2023_10_01_preview import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -107,6 +113,7 @@ def availability_statuses(self): * 2015-01-01: :class:`AvailabilityStatusesOperations` * 2018-07-01: :class:`AvailabilityStatusesOperations` * 2022-10-01: :class:`AvailabilityStatusesOperations` + * 2023-10-01-preview: :class:`AvailabilityStatusesOperations` """ api_version = self._get_api_version('availability_statuses') if api_version == '2015-01-01': @@ -115,10 +122,12 @@ def availability_statuses(self): from .v2018_07_01.operations import AvailabilityStatusesOperations as OperationClass elif api_version == '2022-10-01': from .v2022_10_01.operations import AvailabilityStatusesOperations as OperationClass + elif api_version == '2023-10-01-preview': + from .v2023_10_01_preview.operations import AvailabilityStatusesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'availability_statuses'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def child_availability_statuses(self): @@ -126,16 +135,19 @@ def child_availability_statuses(self): * 2015-01-01: :class:`ChildAvailabilityStatusesOperations` * 2022-10-01: :class:`ChildAvailabilityStatusesOperations` + * 2023-10-01-preview: :class:`ChildAvailabilityStatusesOperations` """ api_version = self._get_api_version('child_availability_statuses') if api_version == '2015-01-01': from .v2015_01_01.operations import ChildAvailabilityStatusesOperations as OperationClass elif api_version == '2022-10-01': from .v2022_10_01.operations import ChildAvailabilityStatusesOperations as OperationClass + elif api_version == '2023-10-01-preview': + from .v2023_10_01_preview.operations import ChildAvailabilityStatusesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'child_availability_statuses'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def child_resources(self): @@ -143,16 +155,19 @@ def child_resources(self): * 2015-01-01: :class:`ChildResourcesOperations` * 2022-10-01: :class:`ChildResourcesOperations` + * 2023-10-01-preview: :class:`ChildResourcesOperations` """ api_version = self._get_api_version('child_resources') if api_version == '2015-01-01': from .v2015_01_01.operations import ChildResourcesOperations as OperationClass elif api_version == '2022-10-01': from .v2022_10_01.operations import ChildResourcesOperations as OperationClass + elif api_version == '2023-10-01-preview': + from .v2023_10_01_preview.operations import ChildResourcesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'child_resources'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def emerging_issues(self): @@ -160,30 +175,36 @@ def emerging_issues(self): * 2018-07-01: :class:`EmergingIssuesOperations` * 2022-10-01: :class:`EmergingIssuesOperations` + * 2023-10-01-preview: :class:`EmergingIssuesOperations` """ api_version = self._get_api_version('emerging_issues') if api_version == '2018-07-01': from .v2018_07_01.operations import EmergingIssuesOperations as OperationClass elif api_version == '2022-10-01': from .v2022_10_01.operations import EmergingIssuesOperations as OperationClass + elif api_version == '2023-10-01-preview': + from .v2023_10_01_preview.operations import EmergingIssuesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'emerging_issues'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def event(self): """Instance depends on the API version: * 2022-10-01: :class:`EventOperations` + * 2023-10-01-preview: :class:`EventOperations` """ api_version = self._get_api_version('event') if api_version == '2022-10-01': from .v2022_10_01.operations import EventOperations as OperationClass + elif api_version == '2023-10-01-preview': + from .v2023_10_01_preview.operations import EventOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'event'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def events(self): @@ -191,30 +212,36 @@ def events(self): * 2018-07-01: :class:`EventsOperations` * 2022-10-01: :class:`EventsOperations` + * 2023-10-01-preview: :class:`EventsOperations` """ api_version = self._get_api_version('events') if api_version == '2018-07-01': from .v2018_07_01.operations import EventsOperations as OperationClass elif api_version == '2022-10-01': from .v2022_10_01.operations import EventsOperations as OperationClass + elif api_version == '2023-10-01-preview': + from .v2023_10_01_preview.operations import EventsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'events'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def impacted_resources(self): """Instance depends on the API version: * 2022-10-01: :class:`ImpactedResourcesOperations` + * 2023-10-01-preview: :class:`ImpactedResourcesOperations` """ api_version = self._get_api_version('impacted_resources') if api_version == '2022-10-01': from .v2022_10_01.operations import ImpactedResourcesOperations as OperationClass + elif api_version == '2023-10-01-preview': + from .v2023_10_01_preview.operations import ImpactedResourcesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'impacted_resources'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def metadata(self): @@ -222,16 +249,19 @@ def metadata(self): * 2018-07-01: :class:`MetadataOperations` * 2022-10-01: :class:`MetadataOperations` + * 2023-10-01-preview: :class:`MetadataOperations` """ api_version = self._get_api_version('metadata') if api_version == '2018-07-01': from .v2018_07_01.operations import MetadataOperations as OperationClass elif api_version == '2022-10-01': from .v2022_10_01.operations import MetadataOperations as OperationClass + elif api_version == '2023-10-01-preview': + from .v2023_10_01_preview.operations import MetadataOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'metadata'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def operations(self): @@ -240,6 +270,7 @@ def operations(self): * 2015-01-01: :class:`Operations` * 2018-07-01: :class:`Operations` * 2022-10-01: :class:`Operations` + * 2023-10-01-preview: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2015-01-01': @@ -248,24 +279,29 @@ def operations(self): from .v2018_07_01.operations import Operations as OperationClass elif api_version == '2022-10-01': from .v2022_10_01.operations import Operations as OperationClass + elif api_version == '2023-10-01-preview': + from .v2023_10_01_preview.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def security_advisory_impacted_resources(self): """Instance depends on the API version: * 2022-10-01: :class:`SecurityAdvisoryImpactedResourcesOperations` + * 2023-10-01-preview: :class:`SecurityAdvisoryImpactedResourcesOperations` """ api_version = self._get_api_version('security_advisory_impacted_resources') if api_version == '2022-10-01': from .v2022_10_01.operations import SecurityAdvisoryImpactedResourcesOperations as OperationClass + elif api_version == '2023-10-01-preview': + from .v2023_10_01_preview.operations import SecurityAdvisoryImpactedResourcesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'security_advisory_impacted_resources'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) def close(self): self._client.close() diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/_serialization.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/_serialization.py index e3cc6ce6ed6f..a00658b1fc19 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/_serialization.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/_serialization.py @@ -664,8 +664,9 @@ def _serialize(self, target_obj, data_type=None, **kwargs): _serialized.update(_new_attr) # type: ignore _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] - except ValueError: - continue + except ValueError as err: + if isinstance(err, SerializationError): + raise except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) @@ -743,6 +744,8 @@ def query(self, name, data, data_type, **kwargs): :param data: The data to be serialized. :param str data_type: The type to be serialized from. + :keyword bool skip_quote: Whether to skip quote the serialized result. + Defaults to False. :rtype: str :raises: TypeError if serialization fails. :raises: ValueError if data is None @@ -751,10 +754,8 @@ def query(self, name, data, data_type, **kwargs): # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] - if not kwargs.get("skip_quote", False): - data = [quote(str(d), safe="") for d in data] - return str(self.serialize_iter(data, internal_data_type, **kwargs)) + do_quote = not kwargs.get('skip_quote', False) + return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -893,6 +894,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. + :keyword bool do_quote: Whether to quote the serialized result of each iterable element. + Defaults to False. :rtype: list, str """ if isinstance(data, str): @@ -905,9 +908,18 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get('do_quote', False): + serialized = [ + '' if s is None else quote(str(s), safe='') + for s + in serialized + ] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -952,7 +964,9 @@ def serialize_dict(self, attr, dict_type, **kwargs): for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/aio/_resource_health_mgmt_client.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/aio/_resource_health_mgmt_client.py index 4e62c555b63c..a6a218416f71 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/aio/_resource_health_mgmt_client.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/aio/_resource_health_mgmt_client.py @@ -70,6 +70,8 @@ def __init__( profile: KnownProfiles = KnownProfiles.default, **kwargs: Any ) -> None: + if api_version: + kwargs.setdefault('api_version', api_version) self._config = ResourceHealthMgmtClientConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(ResourceHealthMgmtClient, self).__init__( @@ -88,6 +90,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2015-01-01: :mod:`v2015_01_01.models` * 2018-07-01: :mod:`v2018_07_01.models` * 2022-10-01: :mod:`v2022_10_01.models` + * 2023-10-01-preview: :mod:`v2023_10_01_preview.models` """ if api_version == '2015-01-01': from ..v2015_01_01 import models @@ -98,6 +101,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-10-01': from ..v2022_10_01 import models return models + elif api_version == '2023-10-01-preview': + from ..v2023_10_01_preview import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -107,6 +113,7 @@ def availability_statuses(self): * 2015-01-01: :class:`AvailabilityStatusesOperations` * 2018-07-01: :class:`AvailabilityStatusesOperations` * 2022-10-01: :class:`AvailabilityStatusesOperations` + * 2023-10-01-preview: :class:`AvailabilityStatusesOperations` """ api_version = self._get_api_version('availability_statuses') if api_version == '2015-01-01': @@ -115,10 +122,12 @@ def availability_statuses(self): from ..v2018_07_01.aio.operations import AvailabilityStatusesOperations as OperationClass elif api_version == '2022-10-01': from ..v2022_10_01.aio.operations import AvailabilityStatusesOperations as OperationClass + elif api_version == '2023-10-01-preview': + from ..v2023_10_01_preview.aio.operations import AvailabilityStatusesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'availability_statuses'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def child_availability_statuses(self): @@ -126,16 +135,19 @@ def child_availability_statuses(self): * 2015-01-01: :class:`ChildAvailabilityStatusesOperations` * 2022-10-01: :class:`ChildAvailabilityStatusesOperations` + * 2023-10-01-preview: :class:`ChildAvailabilityStatusesOperations` """ api_version = self._get_api_version('child_availability_statuses') if api_version == '2015-01-01': from ..v2015_01_01.aio.operations import ChildAvailabilityStatusesOperations as OperationClass elif api_version == '2022-10-01': from ..v2022_10_01.aio.operations import ChildAvailabilityStatusesOperations as OperationClass + elif api_version == '2023-10-01-preview': + from ..v2023_10_01_preview.aio.operations import ChildAvailabilityStatusesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'child_availability_statuses'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def child_resources(self): @@ -143,16 +155,19 @@ def child_resources(self): * 2015-01-01: :class:`ChildResourcesOperations` * 2022-10-01: :class:`ChildResourcesOperations` + * 2023-10-01-preview: :class:`ChildResourcesOperations` """ api_version = self._get_api_version('child_resources') if api_version == '2015-01-01': from ..v2015_01_01.aio.operations import ChildResourcesOperations as OperationClass elif api_version == '2022-10-01': from ..v2022_10_01.aio.operations import ChildResourcesOperations as OperationClass + elif api_version == '2023-10-01-preview': + from ..v2023_10_01_preview.aio.operations import ChildResourcesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'child_resources'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def emerging_issues(self): @@ -160,30 +175,36 @@ def emerging_issues(self): * 2018-07-01: :class:`EmergingIssuesOperations` * 2022-10-01: :class:`EmergingIssuesOperations` + * 2023-10-01-preview: :class:`EmergingIssuesOperations` """ api_version = self._get_api_version('emerging_issues') if api_version == '2018-07-01': from ..v2018_07_01.aio.operations import EmergingIssuesOperations as OperationClass elif api_version == '2022-10-01': from ..v2022_10_01.aio.operations import EmergingIssuesOperations as OperationClass + elif api_version == '2023-10-01-preview': + from ..v2023_10_01_preview.aio.operations import EmergingIssuesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'emerging_issues'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def event(self): """Instance depends on the API version: * 2022-10-01: :class:`EventOperations` + * 2023-10-01-preview: :class:`EventOperations` """ api_version = self._get_api_version('event') if api_version == '2022-10-01': from ..v2022_10_01.aio.operations import EventOperations as OperationClass + elif api_version == '2023-10-01-preview': + from ..v2023_10_01_preview.aio.operations import EventOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'event'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def events(self): @@ -191,30 +212,36 @@ def events(self): * 2018-07-01: :class:`EventsOperations` * 2022-10-01: :class:`EventsOperations` + * 2023-10-01-preview: :class:`EventsOperations` """ api_version = self._get_api_version('events') if api_version == '2018-07-01': from ..v2018_07_01.aio.operations import EventsOperations as OperationClass elif api_version == '2022-10-01': from ..v2022_10_01.aio.operations import EventsOperations as OperationClass + elif api_version == '2023-10-01-preview': + from ..v2023_10_01_preview.aio.operations import EventsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'events'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def impacted_resources(self): """Instance depends on the API version: * 2022-10-01: :class:`ImpactedResourcesOperations` + * 2023-10-01-preview: :class:`ImpactedResourcesOperations` """ api_version = self._get_api_version('impacted_resources') if api_version == '2022-10-01': from ..v2022_10_01.aio.operations import ImpactedResourcesOperations as OperationClass + elif api_version == '2023-10-01-preview': + from ..v2023_10_01_preview.aio.operations import ImpactedResourcesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'impacted_resources'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def metadata(self): @@ -222,16 +249,19 @@ def metadata(self): * 2018-07-01: :class:`MetadataOperations` * 2022-10-01: :class:`MetadataOperations` + * 2023-10-01-preview: :class:`MetadataOperations` """ api_version = self._get_api_version('metadata') if api_version == '2018-07-01': from ..v2018_07_01.aio.operations import MetadataOperations as OperationClass elif api_version == '2022-10-01': from ..v2022_10_01.aio.operations import MetadataOperations as OperationClass + elif api_version == '2023-10-01-preview': + from ..v2023_10_01_preview.aio.operations import MetadataOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'metadata'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def operations(self): @@ -240,6 +270,7 @@ def operations(self): * 2015-01-01: :class:`Operations` * 2018-07-01: :class:`Operations` * 2022-10-01: :class:`Operations` + * 2023-10-01-preview: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2015-01-01': @@ -248,24 +279,29 @@ def operations(self): from ..v2018_07_01.aio.operations import Operations as OperationClass elif api_version == '2022-10-01': from ..v2022_10_01.aio.operations import Operations as OperationClass + elif api_version == '2023-10-01-preview': + from ..v2023_10_01_preview.aio.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def security_advisory_impacted_resources(self): """Instance depends on the API version: * 2022-10-01: :class:`SecurityAdvisoryImpactedResourcesOperations` + * 2023-10-01-preview: :class:`SecurityAdvisoryImpactedResourcesOperations` """ api_version = self._get_api_version('security_advisory_impacted_resources') if api_version == '2022-10-01': from ..v2022_10_01.aio.operations import SecurityAdvisoryImpactedResourcesOperations as OperationClass + elif api_version == '2023-10-01-preview': + from ..v2023_10_01_preview.aio.operations import SecurityAdvisoryImpactedResourcesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'security_advisory_impacted_resources'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) async def close(self): await self._client.close() diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_resource_health_mgmt_client.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_resource_health_mgmt_client.py index 1fb29e989145..6c3bb22ad3c9 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_resource_health_mgmt_client.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_resource_health_mgmt_client.py @@ -70,13 +70,15 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.availability_statuses = AvailabilityStatusesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2015-01-01" ) self.child_availability_statuses = ChildAvailabilityStatusesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2015-01-01" ) - self.child_resources = ChildResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.child_resources = ChildResourcesOperations( + self._client, self._config, self._serialize, self._deserialize, "2015-01-01" + ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2015-01-01") def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_vendor.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_vendor.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): if files: request.set_formdata_body(files) return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_version.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_version.py index 8d50297ac8eb..e5754a47ce68 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_version.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b4" +VERSION = "1.0.0b1" diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/_resource_health_mgmt_client.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/_resource_health_mgmt_client.py index f0471eb572b5..854fa5dfdbdf 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/_resource_health_mgmt_client.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/_resource_health_mgmt_client.py @@ -70,13 +70,15 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.availability_statuses = AvailabilityStatusesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2015-01-01" ) self.child_availability_statuses = ChildAvailabilityStatusesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2015-01-01" ) - self.child_resources = ChildResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.child_resources = ChildResourcesOperations( + self._client, self._config, self._serialize, self._deserialize, "2015-01-01" + ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2015-01-01") def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_availability_statuses_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_availability_statuses_operations.py index 05e4b3c40b4f..efb50d7cec68 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_availability_statuses_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_availability_statuses_operations.py @@ -57,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_subscription_id( @@ -81,7 +82,7 @@ def list_by_subscription_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-01-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { @@ -179,7 +180,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-01-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { @@ -289,7 +290,7 @@ async def get_by_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-01-01")) cls: ClsType[_models.AvailabilityStatus] = kwargs.pop("cls", None) request = build_get_by_resource_request( @@ -355,7 +356,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-01-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_child_availability_statuses_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_child_availability_statuses_operations.py index e8d52945f782..c6700153a4c5 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_child_availability_statuses_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_child_availability_statuses_operations.py @@ -52,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get_by_resource( @@ -87,7 +88,7 @@ async def get_by_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-01-01")) cls: ClsType[_models.AvailabilityStatus] = kwargs.pop("cls", None) request = build_get_by_resource_request( @@ -153,7 +154,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-01-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_child_resources_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_child_resources_operations.py index 73bbb75e9c60..aa9a1f327e40 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_child_resources_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_child_resources_operations.py @@ -51,6 +51,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -80,7 +81,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-01-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_operations.py index 9f1e1eb2d1d1..665e58e227a0 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_operations.py @@ -49,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list(self, **kwargs: Any) -> _models.OperationListResult: @@ -70,7 +71,7 @@ async def list(self, **kwargs: Any) -> _models.OperationListResult: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-01-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) request = build_list_request( diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_availability_statuses_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_availability_statuses_operations.py index 76c52d3f11d4..657c42689a88 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_availability_statuses_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_availability_statuses_operations.py @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +53,7 @@ def build_list_by_subscription_id_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -92,7 +92,7 @@ def build_list_by_resource_group_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -122,7 +122,7 @@ def build_get_by_resource_request( "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -152,7 +152,7 @@ def build_list_request( "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -185,6 +185,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_subscription_id( @@ -209,7 +210,7 @@ def list_by_subscription_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-01-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { @@ -307,7 +308,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-01-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { @@ -417,7 +418,7 @@ def get_by_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-01-01")) cls: ClsType[_models.AvailabilityStatus] = kwargs.pop("cls", None) request = build_get_by_resource_request( @@ -483,7 +484,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-01-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_child_availability_statuses_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_child_availability_statuses_operations.py index b548ec7525ab..ca7a992d34eb 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_child_availability_statuses_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_child_availability_statuses_operations.py @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +53,7 @@ def build_get_by_resource_request( "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +83,7 @@ def build_list_request( "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,6 +116,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get_by_resource( @@ -151,7 +152,7 @@ def get_by_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-01-01")) cls: ClsType[_models.AvailabilityStatus] = kwargs.pop("cls", None) request = build_get_by_resource_request( @@ -217,7 +218,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-01-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_child_resources_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_child_resources_operations.py index ca0729a00893..f2e14c3a83d9 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_child_resources_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_child_resources_operations.py @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +51,7 @@ def build_list_request( "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -84,6 +84,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -113,7 +114,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-01-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_operations.py index 19afc3e49089..a2bdc6565631 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_operations.py @@ -71,6 +71,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> _models.OperationListResult: @@ -92,7 +93,7 @@ def list(self, **kwargs: Any) -> _models.OperationListResult: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-01-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) request = build_list_request( diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/_resource_health_mgmt_client.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/_resource_health_mgmt_client.py index 27ea200df321..7c02652f5bac 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/_resource_health_mgmt_client.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/_resource_health_mgmt_client.py @@ -71,13 +71,15 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.events = EventsOperations(self._client, self._config, self._serialize, self._deserialize) + self.events = EventsOperations(self._client, self._config, self._serialize, self._deserialize, "2018-07-01") self.availability_statuses = AvailabilityStatusesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2018-07-01" ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.emerging_issues = EmergingIssuesOperations(self._client, self._config, self._serialize, self._deserialize) - self.metadata = MetadataOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2018-07-01") + self.emerging_issues = EmergingIssuesOperations( + self._client, self._config, self._serialize, self._deserialize, "2018-07-01" + ) + self.metadata = MetadataOperations(self._client, self._config, self._serialize, self._deserialize, "2018-07-01") def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/_vendor.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/_vendor.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): if files: request.set_formdata_body(files) return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/_version.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/_version.py index 8d50297ac8eb..e5754a47ce68 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/_version.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b4" +VERSION = "1.0.0b1" diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/aio/_resource_health_mgmt_client.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/aio/_resource_health_mgmt_client.py index 03f50a61e6f5..47dae5690a43 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/aio/_resource_health_mgmt_client.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/aio/_resource_health_mgmt_client.py @@ -71,13 +71,15 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.events = EventsOperations(self._client, self._config, self._serialize, self._deserialize) + self.events = EventsOperations(self._client, self._config, self._serialize, self._deserialize, "2018-07-01") self.availability_statuses = AvailabilityStatusesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2018-07-01" ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.emerging_issues = EmergingIssuesOperations(self._client, self._config, self._serialize, self._deserialize) - self.metadata = MetadataOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2018-07-01") + self.emerging_issues = EmergingIssuesOperations( + self._client, self._config, self._serialize, self._deserialize, "2018-07-01" + ) + self.metadata = MetadataOperations(self._client, self._config, self._serialize, self._deserialize, "2018-07-01") def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/aio/operations/_availability_statuses_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/aio/operations/_availability_statuses_operations.py index c9f530bf4c4a..daff89368b4c 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/aio/operations/_availability_statuses_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/aio/operations/_availability_statuses_operations.py @@ -57,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_subscription_id( @@ -82,7 +83,7 @@ def list_by_subscription_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { @@ -181,7 +182,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { @@ -293,7 +294,7 @@ async def get_by_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.AvailabilityStatus] = kwargs.pop("cls", None) request = build_get_by_resource_request( @@ -360,7 +361,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/aio/operations/_emerging_issues_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/aio/operations/_emerging_issues_operations.py index 276f63767bf1..0bd25f6747c6 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/aio/operations/_emerging_issues_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/aio/operations/_emerging_issues_operations.py @@ -52,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, issue_name: Union[str, _models.Enum8], **kwargs: Any) -> _models.EmergingIssuesGetResult: @@ -75,7 +76,7 @@ async def get(self, issue_name: Union[str, _models.Enum8], **kwargs: Any) -> _mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.EmergingIssuesGetResult] = kwargs.pop("cls", None) request = build_get_request( @@ -123,7 +124,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.EmergingIssuesGetResult" _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.EmergingIssueListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/aio/operations/_events_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/aio/operations/_events_operations.py index 971e3e075e31..d559f9526c71 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/aio/operations/_events_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/aio/operations/_events_operations.py @@ -54,6 +54,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_subscription_id( @@ -86,7 +87,7 @@ def list_by_subscription_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.Events] = kwargs.pop("cls", None) error_map = { @@ -190,7 +191,7 @@ def list_by_single_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.Events] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/aio/operations/_metadata_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/aio/operations/_metadata_operations.py index 8ba02caf94cc..f35e799c90f2 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/aio/operations/_metadata_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/aio/operations/_metadata_operations.py @@ -52,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.MetadataEntity"]: @@ -66,7 +67,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.MetadataEntity"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.MetadataEntityListResult] = kwargs.pop("cls", None) error_map = { @@ -156,7 +157,7 @@ async def get_entity(self, name: str, **kwargs: Any) -> _models.MetadataEntity: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.MetadataEntity] = kwargs.pop("cls", None) request = build_get_entity_request( diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/aio/operations/_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/aio/operations/_operations.py index 3463eaca98cb..1cfa6b6927bc 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/aio/operations/_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/aio/operations/_operations.py @@ -49,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list(self, **kwargs: Any) -> _models.OperationListResult: @@ -70,7 +71,7 @@ async def list(self, **kwargs: Any) -> _models.OperationListResult: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) request = build_list_request( diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/operations/_availability_statuses_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/operations/_availability_statuses_operations.py index c9487f9aea51..9a43dace345e 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/operations/_availability_statuses_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/operations/_availability_statuses_operations.py @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +53,7 @@ def build_list_by_subscription_id_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -92,7 +92,7 @@ def build_list_by_resource_group_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -122,7 +122,7 @@ def build_get_by_resource_request( "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -152,7 +152,7 @@ def build_list_request( "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -185,6 +185,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_subscription_id( @@ -210,7 +211,7 @@ def list_by_subscription_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { @@ -309,7 +310,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { @@ -421,7 +422,7 @@ def get_by_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.AvailabilityStatus] = kwargs.pop("cls", None) request = build_get_by_resource_request( @@ -488,7 +489,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/operations/_emerging_issues_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/operations/_emerging_issues_operations.py index 03790aaabe60..d65dda980754 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/operations/_emerging_issues_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/operations/_emerging_issues_operations.py @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +49,7 @@ def build_get_request(issue_name: Union[str, _models.Enum8], **kwargs: Any) -> H "issueName": _SERIALIZER.url("issue_name", issue_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -97,6 +97,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, issue_name: Union[str, _models.Enum8], **kwargs: Any) -> _models.EmergingIssuesGetResult: @@ -120,7 +121,7 @@ def get(self, issue_name: Union[str, _models.Enum8], **kwargs: Any) -> _models.E _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.EmergingIssuesGetResult] = kwargs.pop("cls", None) request = build_get_request( @@ -168,7 +169,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.EmergingIssuesGetResult"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.EmergingIssueListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/operations/_events_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/operations/_events_operations.py index e5f4c4992b75..ca3c11733d30 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/operations/_events_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/operations/_events_operations.py @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +56,7 @@ def build_list_by_subscription_id_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -88,7 +88,7 @@ def build_list_by_single_resource_request( "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -121,6 +121,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_subscription_id( @@ -152,7 +153,7 @@ def list_by_subscription_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.Events] = kwargs.pop("cls", None) error_map = { @@ -255,7 +256,7 @@ def list_by_single_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.Events] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/operations/_metadata_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/operations/_metadata_operations.py index f58b3d2d1228..4e244f8af4a4 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/operations/_metadata_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/operations/_metadata_operations.py @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +68,7 @@ def build_get_entity_request(name: str, **kwargs: Any) -> HttpRequest: "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -97,6 +97,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.MetadataEntity"]: @@ -111,7 +112,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.MetadataEntity"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.MetadataEntityListResult] = kwargs.pop("cls", None) error_map = { @@ -201,7 +202,7 @@ def get_entity(self, name: str, **kwargs: Any) -> _models.MetadataEntity: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.MetadataEntity] = kwargs.pop("cls", None) request = build_get_entity_request( diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/operations/_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/operations/_operations.py index 07d9a37dd47b..d0671807cc1b 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/operations/_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2018_07_01/operations/_operations.py @@ -71,6 +71,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> _models.OperationListResult: @@ -92,7 +93,7 @@ def list(self, **kwargs: Any) -> _models.OperationListResult: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) request = build_list_request( diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/_resource_health_mgmt_client.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/_resource_health_mgmt_client.py index ba0ff2c9df59..25d2d5c6fa9c 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/_resource_health_mgmt_client.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/_resource_health_mgmt_client.py @@ -91,23 +91,27 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.availability_statuses = AvailabilityStatusesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-10-01" ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.metadata = MetadataOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2022-10-01") + self.metadata = MetadataOperations(self._client, self._config, self._serialize, self._deserialize, "2022-10-01") self.impacted_resources = ImpactedResourcesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-10-01" ) self.security_advisory_impacted_resources = SecurityAdvisoryImpactedResourcesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-10-01" ) - self.events = EventsOperations(self._client, self._config, self._serialize, self._deserialize) - self.event = EventOperations(self._client, self._config, self._serialize, self._deserialize) + self.events = EventsOperations(self._client, self._config, self._serialize, self._deserialize, "2022-10-01") + self.event = EventOperations(self._client, self._config, self._serialize, self._deserialize, "2022-10-01") self.child_availability_statuses = ChildAvailabilityStatusesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-10-01" + ) + self.child_resources = ChildResourcesOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-10-01" + ) + self.emerging_issues = EmergingIssuesOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-10-01" ) - self.child_resources = ChildResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.emerging_issues = EmergingIssuesOperations(self._client, self._config, self._serialize, self._deserialize) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/_vendor.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/_vendor.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): if files: request.set_formdata_body(files) return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/_version.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/_version.py index 8d50297ac8eb..e5754a47ce68 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/_version.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b4" +VERSION = "1.0.0b1" diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/_resource_health_mgmt_client.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/_resource_health_mgmt_client.py index 4a24fd2c9c22..51897642a163 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/_resource_health_mgmt_client.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/_resource_health_mgmt_client.py @@ -91,23 +91,27 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.availability_statuses = AvailabilityStatusesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-10-01" ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.metadata = MetadataOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2022-10-01") + self.metadata = MetadataOperations(self._client, self._config, self._serialize, self._deserialize, "2022-10-01") self.impacted_resources = ImpactedResourcesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-10-01" ) self.security_advisory_impacted_resources = SecurityAdvisoryImpactedResourcesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-10-01" ) - self.events = EventsOperations(self._client, self._config, self._serialize, self._deserialize) - self.event = EventOperations(self._client, self._config, self._serialize, self._deserialize) + self.events = EventsOperations(self._client, self._config, self._serialize, self._deserialize, "2022-10-01") + self.event = EventOperations(self._client, self._config, self._serialize, self._deserialize, "2022-10-01") self.child_availability_statuses = ChildAvailabilityStatusesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-10-01" + ) + self.child_resources = ChildResourcesOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-10-01" + ) + self.emerging_issues = EmergingIssuesOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-10-01" ) - self.child_resources = ChildResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.emerging_issues = EmergingIssuesOperations(self._client, self._config, self._serialize, self._deserialize) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_availability_statuses_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_availability_statuses_operations.py index 7c1074661418..995adf31f2a1 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_availability_statuses_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_availability_statuses_operations.py @@ -57,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_subscription_id( @@ -80,7 +81,7 @@ def list_by_subscription_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { @@ -178,7 +179,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { @@ -288,7 +289,7 @@ async def get_by_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.AvailabilityStatus] = kwargs.pop("cls", None) request = build_get_by_resource_request( @@ -353,7 +354,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_child_availability_statuses_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_child_availability_statuses_operations.py index e8fd034549bd..dc9c59d60e57 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_child_availability_statuses_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_child_availability_statuses_operations.py @@ -52,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get_by_resource( @@ -87,7 +88,7 @@ async def get_by_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.AvailabilityStatus] = kwargs.pop("cls", None) request = build_get_by_resource_request( @@ -153,7 +154,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_child_resources_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_child_resources_operations.py index d1670fc6246a..42043104d28b 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_child_resources_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_child_resources_operations.py @@ -51,6 +51,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -80,7 +81,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_emerging_issues_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_emerging_issues_operations.py index 0d130fb393dd..4ebb1a5c9670 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_emerging_issues_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_emerging_issues_operations.py @@ -52,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.EmergingIssuesGetResult"]: @@ -67,7 +68,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.EmergingIssuesGetResult" _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.EmergingIssueListResult] = kwargs.pop("cls", None) error_map = { @@ -159,7 +160,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.EmergingIssuesGetResult] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_event_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_event_operations.py index c78a67e0eaf8..12fc545630a9 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_event_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_event_operations.py @@ -54,6 +54,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get_by_subscription_id_and_tracking_id( @@ -91,7 +92,7 @@ async def get_by_subscription_id_and_tracking_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.Event] = kwargs.pop("cls", None) request = build_get_by_subscription_id_and_tracking_id_request( @@ -155,7 +156,7 @@ async def fetch_details_by_subscription_id_and_tracking_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.Event] = kwargs.pop("cls", None) request = build_fetch_details_by_subscription_id_and_tracking_id_request( @@ -228,7 +229,7 @@ async def get_by_tenant_id_and_tracking_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.Event] = kwargs.pop("cls", None) request = build_get_by_tenant_id_and_tracking_id_request( @@ -287,7 +288,7 @@ async def fetch_details_by_tenant_id_and_tracking_id(self, event_tracking_id: st _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.Event] = kwargs.pop("cls", None) request = build_fetch_details_by_tenant_id_and_tracking_id_request( diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_events_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_events_operations.py index aadb256df1fb..19b29bfa3610 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_events_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_events_operations.py @@ -55,6 +55,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_subscription_id( @@ -79,7 +80,7 @@ def list_by_subscription_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.Events] = kwargs.pop("cls", None) error_map = { @@ -175,7 +176,7 @@ def list_by_tenant_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.Events] = kwargs.pop("cls", None) error_map = { @@ -271,7 +272,7 @@ def list_by_single_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.Events] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_impacted_resources_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_impacted_resources_operations.py index bed481914cde..2a73eadb4660 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_impacted_resources_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_impacted_resources_operations.py @@ -57,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_subscription_id_and_event_id( @@ -80,7 +81,7 @@ def list_by_subscription_id_and_event_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.EventImpactedResourceListResult] = kwargs.pop("cls", None) error_map = { @@ -179,7 +180,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.EventImpactedResource] = kwargs.pop("cls", None) request = build_get_request( @@ -239,7 +240,7 @@ def list_by_tenant_id_and_event_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.EventImpactedResourceListResult] = kwargs.pop("cls", None) error_map = { @@ -337,7 +338,7 @@ async def get_by_tenant_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.EventImpactedResource] = kwargs.pop("cls", None) request = build_get_by_tenant_id_request( diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_metadata_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_metadata_operations.py index 09875675d015..86c8850c6eb5 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_metadata_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_metadata_operations.py @@ -52,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.MetadataEntity"]: @@ -66,7 +67,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.MetadataEntity"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.MetadataEntityListResult] = kwargs.pop("cls", None) error_map = { @@ -156,7 +157,7 @@ async def get_entity(self, name: str, **kwargs: Any) -> _models.MetadataEntity: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.MetadataEntity] = kwargs.pop("cls", None) request = build_get_entity_request( diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_operations.py index be645058def4..589dbe0aa522 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_operations.py @@ -49,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list(self, **kwargs: Any) -> _models.OperationListResult: @@ -70,7 +71,7 @@ async def list(self, **kwargs: Any) -> _models.OperationListResult: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) request = build_list_request( diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_security_advisory_impacted_resources_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_security_advisory_impacted_resources_operations.py index 3aa7d5d9e321..0983cb5ceb1c 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_security_advisory_impacted_resources_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/aio/operations/_security_advisory_impacted_resources_operations.py @@ -54,6 +54,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_subscription_id_and_event_id( @@ -77,7 +78,7 @@ def list_by_subscription_id_and_event_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.EventImpactedResourceListResult] = kwargs.pop("cls", None) error_map = { @@ -172,7 +173,7 @@ def list_by_tenant_id_and_event_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.EventImpactedResourceListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_availability_statuses_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_availability_statuses_operations.py index 65f22fef7955..70ca087e83a1 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_availability_statuses_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_availability_statuses_operations.py @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +53,7 @@ def build_list_by_subscription_id_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -94,7 +94,7 @@ def build_list_by_resource_group_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -124,7 +124,7 @@ def build_get_by_resource_request( "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,7 +154,7 @@ def build_list_request( "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -187,6 +187,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_subscription_id( @@ -210,7 +211,7 @@ def list_by_subscription_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { @@ -308,7 +309,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { @@ -418,7 +419,7 @@ def get_by_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.AvailabilityStatus] = kwargs.pop("cls", None) request = build_get_by_resource_request( @@ -483,7 +484,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_child_availability_statuses_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_child_availability_statuses_operations.py index b9d7306faf15..655968fa5859 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_child_availability_statuses_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_child_availability_statuses_operations.py @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +53,7 @@ def build_get_by_resource_request( "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +83,7 @@ def build_list_request( "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,6 +116,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get_by_resource( @@ -151,7 +152,7 @@ def get_by_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.AvailabilityStatus] = kwargs.pop("cls", None) request = build_get_by_resource_request( @@ -217,7 +218,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_child_resources_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_child_resources_operations.py index 388fdcab4010..a50935eb74a3 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_child_resources_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_child_resources_operations.py @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +51,7 @@ def build_list_request( "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -84,6 +84,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -113,7 +114,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_emerging_issues_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_emerging_issues_operations.py index 18ad945e5f1e..55034311246a 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_emerging_issues_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_emerging_issues_operations.py @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +68,7 @@ def build_get_request(issue_name: Union[str, _models.IssueNameParameter], **kwar "issueName": _SERIALIZER.url("issue_name", issue_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -97,6 +97,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.EmergingIssuesGetResult"]: @@ -112,7 +113,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.EmergingIssuesGetResult"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.EmergingIssueListResult] = kwargs.pop("cls", None) error_map = { @@ -202,7 +203,7 @@ def get(self, issue_name: Union[str, _models.IssueNameParameter], **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.EmergingIssuesGetResult] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_event_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_event_operations.py index e91f5dcff250..7a0b81cf10a9 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_event_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_event_operations.py @@ -25,7 +25,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -57,7 +57,7 @@ def build_get_by_subscription_id_and_tracking_id_request( "eventTrackingId": _SERIALIZER.url("event_tracking_id", event_tracking_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -91,7 +91,7 @@ def build_fetch_details_by_subscription_id_and_tracking_id_request( "eventTrackingId": _SERIALIZER.url("event_tracking_id", event_tracking_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -117,7 +117,7 @@ def build_get_by_tenant_id_and_tracking_id_request( "eventTrackingId": _SERIALIZER.url("event_tracking_id", event_tracking_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -145,7 +145,7 @@ def build_fetch_details_by_tenant_id_and_tracking_id_request(event_tracking_id: "eventTrackingId": _SERIALIZER.url("event_tracking_id", event_tracking_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -174,6 +174,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get_by_subscription_id_and_tracking_id( @@ -211,7 +212,7 @@ def get_by_subscription_id_and_tracking_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.Event] = kwargs.pop("cls", None) request = build_get_by_subscription_id_and_tracking_id_request( @@ -273,7 +274,7 @@ def fetch_details_by_subscription_id_and_tracking_id(self, event_tracking_id: st _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.Event] = kwargs.pop("cls", None) request = build_fetch_details_by_subscription_id_and_tracking_id_request( @@ -346,7 +347,7 @@ def get_by_tenant_id_and_tracking_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.Event] = kwargs.pop("cls", None) request = build_get_by_tenant_id_and_tracking_id_request( @@ -405,7 +406,7 @@ def fetch_details_by_tenant_id_and_tracking_id(self, event_tracking_id: str, **k _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.Event] = kwargs.pop("cls", None) request = build_fetch_details_by_tenant_id_and_tracking_id_request( diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_events_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_events_operations.py index b063fecb493f..7a735558db7f 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_events_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_events_operations.py @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +51,7 @@ def build_list_by_subscription_id_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -106,7 +106,7 @@ def build_list_by_single_resource_request( "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -137,6 +137,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_subscription_id( @@ -160,7 +161,7 @@ def list_by_subscription_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.Events] = kwargs.pop("cls", None) error_map = { @@ -255,7 +256,7 @@ def list_by_tenant_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.Events] = kwargs.pop("cls", None) error_map = { @@ -350,7 +351,7 @@ def list_by_single_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.Events] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_impacted_resources_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_impacted_resources_operations.py index 580ea78fe17a..24c5614010df 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_impacted_resources_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_impacted_resources_operations.py @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,7 +55,7 @@ def build_list_by_subscription_id_and_event_id_request( "eventTrackingId": _SERIALIZER.url("event_tracking_id", event_tracking_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -90,7 +90,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,7 +116,7 @@ def build_list_by_tenant_id_and_event_id_request( "eventTrackingId": _SERIALIZER.url("event_tracking_id", event_tracking_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -148,7 +148,7 @@ def build_get_by_tenant_id_request(event_tracking_id: str, impacted_resource_nam ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -177,6 +177,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_subscription_id_and_event_id( @@ -200,7 +201,7 @@ def list_by_subscription_id_and_event_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.EventImpactedResourceListResult] = kwargs.pop("cls", None) error_map = { @@ -297,7 +298,7 @@ def get(self, event_tracking_id: str, impacted_resource_name: str, **kwargs: Any _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.EventImpactedResource] = kwargs.pop("cls", None) request = build_get_request( @@ -357,7 +358,7 @@ def list_by_tenant_id_and_event_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.EventImpactedResourceListResult] = kwargs.pop("cls", None) error_map = { @@ -455,7 +456,7 @@ def get_by_tenant_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.EventImpactedResource] = kwargs.pop("cls", None) request = build_get_by_tenant_id_request( diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_metadata_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_metadata_operations.py index 93e80d6b74fc..679f9865e495 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_metadata_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_metadata_operations.py @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +68,7 @@ def build_get_entity_request(name: str, **kwargs: Any) -> HttpRequest: "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -97,6 +97,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.MetadataEntity"]: @@ -111,7 +112,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.MetadataEntity"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.MetadataEntityListResult] = kwargs.pop("cls", None) error_map = { @@ -201,7 +202,7 @@ def get_entity(self, name: str, **kwargs: Any) -> _models.MetadataEntity: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.MetadataEntity] = kwargs.pop("cls", None) request = build_get_entity_request( diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_operations.py index 9e49943e4a03..72cd36ec1aa9 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_operations.py @@ -71,6 +71,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> _models.OperationListResult: @@ -92,7 +93,7 @@ def list(self, **kwargs: Any) -> _models.OperationListResult: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) request = build_list_request( diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_security_advisory_impacted_resources_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_security_advisory_impacted_resources_operations.py index 01d33373dc44..64715383ba9e 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_security_advisory_impacted_resources_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2022_10_01/operations/_security_advisory_impacted_resources_operations.py @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,7 +55,7 @@ def build_list_by_subscription_id_and_event_id_request( "eventTrackingId": _SERIALIZER.url("event_tracking_id", event_tracking_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -86,7 +86,7 @@ def build_list_by_tenant_id_and_event_id_request( "eventTrackingId": _SERIALIZER.url("event_tracking_id", event_tracking_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -117,6 +117,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_subscription_id_and_event_id( @@ -140,7 +141,7 @@ def list_by_subscription_id_and_event_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.EventImpactedResourceListResult] = kwargs.pop("cls", None) error_map = { @@ -235,7 +236,7 @@ def list_by_tenant_id_and_event_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-10-01")) cls: ClsType[_models.EventImpactedResourceListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/__init__.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/__init__.py new file mode 100644 index 000000000000..f1e7a4fdd09e --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/__init__.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._resource_health_mgmt_client import ResourceHealthMgmtClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ResourceHealthMgmtClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/_configuration.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/_configuration.py new file mode 100644 index 000000000000..e435fb2605e4 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/_configuration.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class ResourceHealthMgmtClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ResourceHealthMgmtClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-10-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(ResourceHealthMgmtClientConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-10-01-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resourcehealth/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/_metadata.json b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/_metadata.json new file mode 100644 index 000000000000..98086c039d39 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/_metadata.json @@ -0,0 +1,119 @@ +{ + "chosen_version": "2023-10-01-preview", + "total_api_version_list": ["2023-10-01-preview"], + "client": { + "name": "ResourceHealthMgmtClient", + "filename": "_resource_health_mgmt_client", + "description": "The Resource Health Client.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceHealthMgmtClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceHealthMgmtClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true, + "method_location": "positional" + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", + "docstring_type": "str", + "required": true, + "method_location": "positional" + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version: Optional[str]=None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles=KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "availability_statuses": "AvailabilityStatusesOperations", + "operations": "Operations", + "metadata": "MetadataOperations", + "impacted_resources": "ImpactedResourcesOperations", + "security_advisory_impacted_resources": "SecurityAdvisoryImpactedResourcesOperations", + "events": "EventsOperations", + "event": "EventOperations", + "child_availability_statuses": "ChildAvailabilityStatusesOperations", + "child_resources": "ChildResourcesOperations", + "emerging_issues": "EmergingIssuesOperations" + } +} diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/_patch.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/_resource_health_mgmt_client.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/_resource_health_mgmt_client.py new file mode 100644 index 000000000000..81f1a9e79cb4 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/_resource_health_mgmt_client.py @@ -0,0 +1,154 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import ResourceHealthMgmtClientConfiguration +from .operations import ( + AvailabilityStatusesOperations, + ChildAvailabilityStatusesOperations, + ChildResourcesOperations, + EmergingIssuesOperations, + EventOperations, + EventsOperations, + ImpactedResourcesOperations, + MetadataOperations, + Operations, + SecurityAdvisoryImpactedResourcesOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class ResourceHealthMgmtClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """The Resource Health Client. + + :ivar availability_statuses: AvailabilityStatusesOperations operations + :vartype availability_statuses: + azure.mgmt.resourcehealth.v2023_10_01_preview.operations.AvailabilityStatusesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.resourcehealth.v2023_10_01_preview.operations.Operations + :ivar metadata: MetadataOperations operations + :vartype metadata: azure.mgmt.resourcehealth.v2023_10_01_preview.operations.MetadataOperations + :ivar impacted_resources: ImpactedResourcesOperations operations + :vartype impacted_resources: + azure.mgmt.resourcehealth.v2023_10_01_preview.operations.ImpactedResourcesOperations + :ivar security_advisory_impacted_resources: SecurityAdvisoryImpactedResourcesOperations + operations + :vartype security_advisory_impacted_resources: + azure.mgmt.resourcehealth.v2023_10_01_preview.operations.SecurityAdvisoryImpactedResourcesOperations + :ivar events: EventsOperations operations + :vartype events: azure.mgmt.resourcehealth.v2023_10_01_preview.operations.EventsOperations + :ivar event: EventOperations operations + :vartype event: azure.mgmt.resourcehealth.v2023_10_01_preview.operations.EventOperations + :ivar child_availability_statuses: ChildAvailabilityStatusesOperations operations + :vartype child_availability_statuses: + azure.mgmt.resourcehealth.v2023_10_01_preview.operations.ChildAvailabilityStatusesOperations + :ivar child_resources: ChildResourcesOperations operations + :vartype child_resources: + azure.mgmt.resourcehealth.v2023_10_01_preview.operations.ChildResourcesOperations + :ivar emerging_issues: EmergingIssuesOperations operations + :vartype emerging_issues: + azure.mgmt.resourcehealth.v2023_10_01_preview.operations.EmergingIssuesOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2023-10-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ResourceHealthMgmtClientConfiguration( + credential=credential, subscription_id=subscription_id, **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)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.availability_statuses = AvailabilityStatusesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-10-01-preview" + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize, "2023-10-01-preview" + ) + self.metadata = MetadataOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-10-01-preview" + ) + self.impacted_resources = ImpactedResourcesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-10-01-preview" + ) + self.security_advisory_impacted_resources = SecurityAdvisoryImpactedResourcesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-10-01-preview" + ) + self.events = EventsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-10-01-preview" + ) + self.event = EventOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-10-01-preview" + ) + self.child_availability_statuses = ChildAvailabilityStatusesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-10-01-preview" + ) + self.child_resources = ChildResourcesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-10-01-preview" + ) + self.emerging_issues = EmergingIssuesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-10-01-preview" + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> "ResourceHealthMgmtClient": + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/_vendor.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/_vendor.py new file mode 100644 index 000000000000..0dafe0e287ff --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/_version.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/__init__.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/__init__.py new file mode 100644 index 000000000000..d95ad182aa0f --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._resource_health_mgmt_client import ResourceHealthMgmtClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ResourceHealthMgmtClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/_configuration.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/_configuration.py new file mode 100644 index 000000000000..8d5320353c3d --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/_configuration.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class ResourceHealthMgmtClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ResourceHealthMgmtClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-10-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(ResourceHealthMgmtClientConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-10-01-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resourcehealth/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/_patch.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/_resource_health_mgmt_client.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/_resource_health_mgmt_client.py new file mode 100644 index 000000000000..390c59ffdbf2 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/_resource_health_mgmt_client.py @@ -0,0 +1,155 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models as _models +from ..._serialization import Deserializer, Serializer +from ._configuration import ResourceHealthMgmtClientConfiguration +from .operations import ( + AvailabilityStatusesOperations, + ChildAvailabilityStatusesOperations, + ChildResourcesOperations, + EmergingIssuesOperations, + EventOperations, + EventsOperations, + ImpactedResourcesOperations, + MetadataOperations, + Operations, + SecurityAdvisoryImpactedResourcesOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class ResourceHealthMgmtClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """The Resource Health Client. + + :ivar availability_statuses: AvailabilityStatusesOperations operations + :vartype availability_statuses: + azure.mgmt.resourcehealth.v2023_10_01_preview.aio.operations.AvailabilityStatusesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.resourcehealth.v2023_10_01_preview.aio.operations.Operations + :ivar metadata: MetadataOperations operations + :vartype metadata: + azure.mgmt.resourcehealth.v2023_10_01_preview.aio.operations.MetadataOperations + :ivar impacted_resources: ImpactedResourcesOperations operations + :vartype impacted_resources: + azure.mgmt.resourcehealth.v2023_10_01_preview.aio.operations.ImpactedResourcesOperations + :ivar security_advisory_impacted_resources: SecurityAdvisoryImpactedResourcesOperations + operations + :vartype security_advisory_impacted_resources: + azure.mgmt.resourcehealth.v2023_10_01_preview.aio.operations.SecurityAdvisoryImpactedResourcesOperations + :ivar events: EventsOperations operations + :vartype events: azure.mgmt.resourcehealth.v2023_10_01_preview.aio.operations.EventsOperations + :ivar event: EventOperations operations + :vartype event: azure.mgmt.resourcehealth.v2023_10_01_preview.aio.operations.EventOperations + :ivar child_availability_statuses: ChildAvailabilityStatusesOperations operations + :vartype child_availability_statuses: + azure.mgmt.resourcehealth.v2023_10_01_preview.aio.operations.ChildAvailabilityStatusesOperations + :ivar child_resources: ChildResourcesOperations operations + :vartype child_resources: + azure.mgmt.resourcehealth.v2023_10_01_preview.aio.operations.ChildResourcesOperations + :ivar emerging_issues: EmergingIssuesOperations operations + :vartype emerging_issues: + azure.mgmt.resourcehealth.v2023_10_01_preview.aio.operations.EmergingIssuesOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2023-10-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ResourceHealthMgmtClientConfiguration( + credential=credential, subscription_id=subscription_id, **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)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.availability_statuses = AvailabilityStatusesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-10-01-preview" + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize, "2023-10-01-preview" + ) + self.metadata = MetadataOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-10-01-preview" + ) + self.impacted_resources = ImpactedResourcesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-10-01-preview" + ) + self.security_advisory_impacted_resources = SecurityAdvisoryImpactedResourcesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-10-01-preview" + ) + self.events = EventsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-10-01-preview" + ) + self.event = EventOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-10-01-preview" + ) + self.child_availability_statuses = ChildAvailabilityStatusesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-10-01-preview" + ) + self.child_resources = ChildResourcesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-10-01-preview" + ) + self.emerging_issues = EmergingIssuesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-10-01-preview" + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ResourceHealthMgmtClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/__init__.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/__init__.py new file mode 100644 index 000000000000..5ef1b5084a40 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/__init__.py @@ -0,0 +1,37 @@ +# 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 ._availability_statuses_operations import AvailabilityStatusesOperations +from ._operations import Operations +from ._metadata_operations import MetadataOperations +from ._impacted_resources_operations import ImpactedResourcesOperations +from ._security_advisory_impacted_resources_operations import SecurityAdvisoryImpactedResourcesOperations +from ._events_operations import EventsOperations +from ._event_operations import EventOperations +from ._child_availability_statuses_operations import ChildAvailabilityStatusesOperations +from ._child_resources_operations import ChildResourcesOperations +from ._emerging_issues_operations import EmergingIssuesOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AvailabilityStatusesOperations", + "Operations", + "MetadataOperations", + "ImpactedResourcesOperations", + "SecurityAdvisoryImpactedResourcesOperations", + "EventsOperations", + "EventOperations", + "ChildAvailabilityStatusesOperations", + "ChildResourcesOperations", + "EmergingIssuesOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_availability_statuses_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_availability_statuses_operations.py new file mode 100644 index 000000000000..b71ba2185d58 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_availability_statuses_operations.py @@ -0,0 +1,434 @@ +# 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, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._availability_statuses_operations import ( + build_get_by_resource_request, + build_list_by_resource_group_request, + build_list_by_subscription_id_request, + build_list_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AvailabilityStatusesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resourcehealth.v2023_10_01_preview.aio.ResourceHealthMgmtClient`'s + :attr:`availability_statuses` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_subscription_id( + self, filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.AvailabilityStatus"]: + """Lists the current availability status for all the resources in the subscription. + + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :param expand: Setting $expand=recommendedactions in url query expands the recommendedactions + in the response. Default value is None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AvailabilityStatus or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.AvailabilityStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + filter=filter, + expand=expand, + api_version=api_version, + template_url=self.list_by_subscription_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AvailabilityStatusListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/availabilityStatuses" + } + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.AvailabilityStatus"]: + """Lists the current availability status for all the resources in the resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :param expand: Setting $expand=recommendedactions in url query expands the recommendedactions + in the response. Default value is None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AvailabilityStatus or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.AvailabilityStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + expand=expand, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AvailabilityStatusListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ResourceHealth/availabilityStatuses" + } + + @distributed_trace_async + async def get_by_resource( + self, resource_uri: str, filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any + ) -> _models.AvailabilityStatus: + """Gets current availability status for a single resource. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Currently the API support not nested and one nesting level resource types : + /subscriptions/{subscriptionId}/resourceGroups/{resource-group-name}/providers/{resource-provider-name}/{resource-type}/{resource-name} + and + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resource-provider-name}/{parentResourceType}/{parentResourceName}/{resourceType}/{resourceName}. + Required. + :type resource_uri: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :param expand: Setting $expand=recommendedactions in url query expands the recommendedactions + in the response. Default value is None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AvailabilityStatus or the result of cls(response) + :rtype: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.AvailabilityStatus + :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._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.AvailabilityStatus] = kwargs.pop("cls", None) + + request = build_get_by_resource_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + api_version=api_version, + template_url=self.get_by_resource.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AvailabilityStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.ResourceHealth/availabilityStatuses/current"} + + @distributed_trace + def list( + self, resource_uri: str, filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.AvailabilityStatus"]: + """Lists all historical availability transitions and impacting events for a single resource. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Currently the API support not nested and one nesting level resource types : + /subscriptions/{subscriptionId}/resourceGroups/{resource-group-name}/providers/{resource-provider-name}/{resource-type}/{resource-name} + and + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resource-provider-name}/{parentResourceType}/{parentResourceName}/{resourceType}/{resourceName}. + Required. + :type resource_uri: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :param expand: Setting $expand=recommendedactions in url query expands the recommendedactions + in the response. Default value is None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AvailabilityStatus or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.AvailabilityStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AvailabilityStatusListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.ResourceHealth/availabilityStatuses"} diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_child_availability_statuses_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_child_availability_statuses_operations.py new file mode 100644 index 000000000000..227bcc2cb71a --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_child_availability_statuses_operations.py @@ -0,0 +1,230 @@ +# 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, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._child_availability_statuses_operations import build_get_by_resource_request, build_list_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ChildAvailabilityStatusesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resourcehealth.v2023_10_01_preview.aio.ResourceHealthMgmtClient`'s + :attr:`child_availability_statuses` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def get_by_resource( + self, resource_uri: str, filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any + ) -> _models.AvailabilityStatus: + """Gets current availability status for a single resource. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Currently the API only support one nesting level resource types : + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resource-provider-name}/{parentResourceType}/{parentResourceName}/{resourceType}/{resourceName}. + Required. + :type resource_uri: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :param expand: Setting $expand=recommendedactions in url query expands the recommendedactions + in the response. Default value is None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AvailabilityStatus or the result of cls(response) + :rtype: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.AvailabilityStatus + :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._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.AvailabilityStatus] = kwargs.pop("cls", None) + + request = build_get_by_resource_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + api_version=api_version, + template_url=self.get_by_resource.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AvailabilityStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_resource.metadata = { + "url": "/{resourceUri}/providers/Microsoft.ResourceHealth/childAvailabilityStatuses/current" + } + + @distributed_trace + def list( + self, resource_uri: str, filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.AvailabilityStatus"]: + """Lists the historical availability statuses for a single child resource. Use the nextLink + property in the response to get the next page of availability status. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Currently the API only support one nesting level resource types : + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resource-provider-name}/{parentResourceType}/{parentResourceName}/{resourceType}/{resourceName}. + Required. + :type resource_uri: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :param expand: Setting $expand=recommendedactions in url query expands the recommendedactions + in the response. Default value is None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AvailabilityStatus or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.AvailabilityStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AvailabilityStatusListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.ResourceHealth/childAvailabilityStatuses"} diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_child_resources_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_child_resources_operations.py new file mode 100644 index 000000000000..f5db178c35e5 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_child_resources_operations.py @@ -0,0 +1,155 @@ +# 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, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._child_resources_operations import build_list_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ChildResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resourcehealth.v2023_10_01_preview.aio.ResourceHealthMgmtClient`'s + :attr:`child_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, resource_uri: str, filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.AvailabilityStatus"]: + """Lists the all the children and its current health status for a parent resource. Use the + nextLink property in the response to get the next page of children current health. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Currently the API only support not nested parent resource type: + /subscriptions/{subscriptionId}/resourceGroups/{resource-group-name}/providers/{resource-provider-name}/{resource-type}/{resource-name}. + Required. + :type resource_uri: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :param expand: Setting $expand=recommendedactions in url query expands the recommendedactions + in the response. Default value is None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AvailabilityStatus or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.AvailabilityStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AvailabilityStatusListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.ResourceHealth/childResources"} diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_emerging_issues_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_emerging_issues_operations.py new file mode 100644 index 000000000000..2e30ed2d4174 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_emerging_issues_operations.py @@ -0,0 +1,200 @@ +# 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, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._emerging_issues_operations import build_get_request, build_list_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class EmergingIssuesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resourcehealth.v2023_10_01_preview.aio.ResourceHealthMgmtClient`'s + :attr:`emerging_issues` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.EmergingIssuesGetResult"]: + """Lists Azure services' emerging issues. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EmergingIssuesGetResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EmergingIssuesGetResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.EmergingIssueListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("EmergingIssueListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.ResourceHealth/emergingIssues"} + + @distributed_trace_async + async def get( + self, issue_name: Union[str, _models.IssueNameParameter], **kwargs: Any + ) -> _models.EmergingIssuesGetResult: + """Gets Azure services' emerging issues. + + :param issue_name: The name of the emerging issue. "default" Required. + :type issue_name: str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.IssueNameParameter + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EmergingIssuesGetResult or the result of cls(response) + :rtype: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EmergingIssuesGetResult + :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._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.EmergingIssuesGetResult] = kwargs.pop("cls", None) + + request = build_get_request( + issue_name=issue_name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EmergingIssuesGetResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/providers/Microsoft.ResourceHealth/emergingIssues/{issueName}"} diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_event_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_event_operations.py new file mode 100644 index 000000000000..896bebec6500 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_event_operations.py @@ -0,0 +1,333 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._event_operations import ( + build_fetch_details_by_subscription_id_and_tracking_id_request, + build_fetch_details_by_tenant_id_and_tracking_id_request, + build_get_by_subscription_id_and_tracking_id_request, + build_get_by_tenant_id_and_tracking_id_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class EventOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resourcehealth.v2023_10_01_preview.aio.ResourceHealthMgmtClient`'s + :attr:`event` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def get_by_subscription_id_and_tracking_id( + self, + event_tracking_id: str, + filter: Optional[str] = None, + query_start_time: Optional[str] = None, + **kwargs: Any + ) -> _models.Event: + """Service health event in the subscription by event tracking id. + + :param event_tracking_id: Event Id which uniquely identifies ServiceHealth event. Required. + :type event_tracking_id: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :param query_start_time: Specifies from when to return events, based on the lastUpdateTime + property. For example, queryStartTime = 7/24/2020 OR queryStartTime=7%2F24%2F2020. Default + value is None. + :type query_start_time: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Event or the result of cls(response) + :rtype: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Event + :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._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.Event] = kwargs.pop("cls", None) + + request = build_get_by_subscription_id_and_tracking_id_request( + event_tracking_id=event_tracking_id, + subscription_id=self._config.subscription_id, + filter=filter, + query_start_time=query_start_time, + api_version=api_version, + template_url=self.get_by_subscription_id_and_tracking_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Event", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_subscription_id_and_tracking_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/events/{eventTrackingId}" + } + + @distributed_trace_async + async def fetch_details_by_subscription_id_and_tracking_id( + self, event_tracking_id: str, **kwargs: Any + ) -> _models.Event: + """Service health event details in the subscription by event tracking id. This can be used to + fetch sensitive properties for Security Advisory events. + + :param event_tracking_id: Event Id which uniquely identifies ServiceHealth event. Required. + :type event_tracking_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Event or the result of cls(response) + :rtype: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Event + :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._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.Event] = kwargs.pop("cls", None) + + request = build_fetch_details_by_subscription_id_and_tracking_id_request( + event_tracking_id=event_tracking_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.fetch_details_by_subscription_id_and_tracking_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Event", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + fetch_details_by_subscription_id_and_tracking_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/fetchEventDetails" + } + + @distributed_trace_async + async def get_by_tenant_id_and_tracking_id( + self, + event_tracking_id: str, + filter: Optional[str] = None, + query_start_time: Optional[str] = None, + **kwargs: Any + ) -> _models.Event: + """Service health event in the tenant by event tracking id. + + :param event_tracking_id: Event Id which uniquely identifies ServiceHealth event. Required. + :type event_tracking_id: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :param query_start_time: Specifies from when to return events, based on the lastUpdateTime + property. For example, queryStartTime = 7/24/2020 OR queryStartTime=7%2F24%2F2020. Default + value is None. + :type query_start_time: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Event or the result of cls(response) + :rtype: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Event + :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._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.Event] = kwargs.pop("cls", None) + + request = build_get_by_tenant_id_and_tracking_id_request( + event_tracking_id=event_tracking_id, + filter=filter, + query_start_time=query_start_time, + api_version=api_version, + template_url=self.get_by_tenant_id_and_tracking_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Event", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_tenant_id_and_tracking_id.metadata = {"url": "/providers/Microsoft.ResourceHealth/events/{eventTrackingId}"} + + @distributed_trace_async + async def fetch_details_by_tenant_id_and_tracking_id(self, event_tracking_id: str, **kwargs: Any) -> _models.Event: + """Service health event details in the tenant by event tracking id. This can be used to fetch + sensitive properties for Security Advisory events. + + :param event_tracking_id: Event Id which uniquely identifies ServiceHealth event. Required. + :type event_tracking_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Event or the result of cls(response) + :rtype: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Event + :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._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.Event] = kwargs.pop("cls", None) + + request = build_fetch_details_by_tenant_id_and_tracking_id_request( + event_tracking_id=event_tracking_id, + api_version=api_version, + template_url=self.fetch_details_by_tenant_id_and_tracking_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Event", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + fetch_details_by_tenant_id_and_tracking_id.metadata = { + "url": "/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/fetchEventDetails" + } diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_events_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_events_operations.py new file mode 100644 index 000000000000..2beb7f72dbcb --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_events_operations.py @@ -0,0 +1,349 @@ +# 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, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._events_operations import ( + build_list_by_single_resource_request, + build_list_by_subscription_id_request, + build_list_by_tenant_id_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class EventsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resourcehealth.v2023_10_01_preview.aio.ResourceHealthMgmtClient`'s + :attr:`events` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_subscription_id( + self, filter: Optional[str] = None, query_start_time: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Event"]: + """Lists service health events in the subscription. + + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :param query_start_time: Specifies from when to return events, based on the lastUpdateTime + property. For example, queryStartTime = 7/24/2020 OR queryStartTime=7%2F24%2F2020. Default + value is None. + :type query_start_time: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Event or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.Events] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + filter=filter, + query_start_time=query_start_time, + api_version=api_version, + template_url=self.list_by_subscription_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("Events", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/events" + } + + @distributed_trace + def list_by_tenant_id( + self, filter: Optional[str] = None, query_start_time: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Event"]: + """Lists current service health events in the tenant. + + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :param query_start_time: Specifies from when to return events, based on the lastUpdateTime + property. For example, queryStartTime = 7/24/2020 OR queryStartTime=7%2F24%2F2020. Default + value is None. + :type query_start_time: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Event or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.Events] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_tenant_id_request( + filter=filter, + query_start_time=query_start_time, + api_version=api_version, + template_url=self.list_by_tenant_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("Events", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_tenant_id.metadata = {"url": "/providers/Microsoft.ResourceHealth/events"} + + @distributed_trace + def list_by_single_resource( + self, resource_uri: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Event"]: + """Lists current service health events for given resource. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Currently the API support not nested and one nesting level resource types : + /subscriptions/{subscriptionId}/resourceGroups/{resource-group-name}/providers/{resource-provider-name}/{resource-type}/{resource-name} + and + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resource-provider-name}/{parentResourceType}/{parentResourceName}/{resourceType}/{resourceName}. + Required. + :type resource_uri: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Event or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.Events] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_single_resource_request( + resource_uri=resource_uri, + filter=filter, + api_version=api_version, + template_url=self.list_by_single_resource.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("Events", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_single_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.ResourceHealth/events"} diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_impacted_resources_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_impacted_resources_operations.py new file mode 100644 index 000000000000..aea7fa067b56 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_impacted_resources_operations.py @@ -0,0 +1,384 @@ +# 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, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._impacted_resources_operations import ( + build_get_by_tenant_id_request, + build_get_request, + build_list_by_subscription_id_and_event_id_request, + build_list_by_tenant_id_and_event_id_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ImpactedResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resourcehealth.v2023_10_01_preview.aio.ResourceHealthMgmtClient`'s + :attr:`impacted_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_subscription_id_and_event_id( + self, event_tracking_id: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.EventImpactedResource"]: + """Lists impacted resources in the subscription by an event. + + :param event_tracking_id: Event Id which uniquely identifies ServiceHealth event. Required. + :type event_tracking_id: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EventImpactedResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventImpactedResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.EventImpactedResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_id_and_event_id_request( + event_tracking_id=event_tracking_id, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_subscription_id_and_event_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("EventImpactedResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_subscription_id_and_event_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/impactedResources" + } + + @distributed_trace_async + async def get( + self, event_tracking_id: str, impacted_resource_name: str, **kwargs: Any + ) -> _models.EventImpactedResource: + """Gets the specific impacted resource in the subscription by an event. + + :param event_tracking_id: Event Id which uniquely identifies ServiceHealth event. Required. + :type event_tracking_id: str + :param impacted_resource_name: Name of the Impacted Resource. Required. + :type impacted_resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventImpactedResource or the result of cls(response) + :rtype: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventImpactedResource + :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._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.EventImpactedResource] = kwargs.pop("cls", None) + + request = build_get_request( + event_tracking_id=event_tracking_id, + impacted_resource_name=impacted_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EventImpactedResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/impactedResources/{impactedResourceName}" + } + + @distributed_trace + def list_by_tenant_id_and_event_id( + self, event_tracking_id: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.EventImpactedResource"]: + """Lists impacted resources in the tenant by an event. + + :param event_tracking_id: Event Id which uniquely identifies ServiceHealth event. Required. + :type event_tracking_id: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EventImpactedResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventImpactedResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.EventImpactedResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_tenant_id_and_event_id_request( + event_tracking_id=event_tracking_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_tenant_id_and_event_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("EventImpactedResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_tenant_id_and_event_id.metadata = { + "url": "/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/impactedResources" + } + + @distributed_trace_async + async def get_by_tenant_id( + self, event_tracking_id: str, impacted_resource_name: str, **kwargs: Any + ) -> _models.EventImpactedResource: + """Gets the specific impacted resource in the tenant by an event. + + :param event_tracking_id: Event Id which uniquely identifies ServiceHealth event. Required. + :type event_tracking_id: str + :param impacted_resource_name: Name of the Impacted Resource. Required. + :type impacted_resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventImpactedResource or the result of cls(response) + :rtype: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventImpactedResource + :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._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.EventImpactedResource] = kwargs.pop("cls", None) + + request = build_get_by_tenant_id_request( + event_tracking_id=event_tracking_id, + impacted_resource_name=impacted_resource_name, + api_version=api_version, + template_url=self.get_by_tenant_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EventImpactedResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_tenant_id.metadata = { + "url": "/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/impactedResources/{impactedResourceName}" + } diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_metadata_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_metadata_operations.py new file mode 100644 index 000000000000..4b0fcc4852fc --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_metadata_operations.py @@ -0,0 +1,196 @@ +# 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, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._metadata_operations import build_get_entity_request, build_list_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class MetadataOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resourcehealth.v2023_10_01_preview.aio.ResourceHealthMgmtClient`'s + :attr:`metadata` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.MetadataEntity"]: + """Gets the list of metadata entities. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MetadataEntity or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.MetadataEntity] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.MetadataEntityListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("MetadataEntityListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.ResourceHealth/metadata"} + + @distributed_trace_async + async def get_entity(self, name: str, **kwargs: Any) -> _models.MetadataEntity: + """Gets the list of metadata entities. + + :param name: Name of metadata entity. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MetadataEntity or the result of cls(response) + :rtype: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.MetadataEntity + :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._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.MetadataEntity] = kwargs.pop("cls", None) + + request = build_get_entity_request( + name=name, + api_version=api_version, + template_url=self.get_entity.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MetadataEntity", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_entity.metadata = {"url": "/providers/Microsoft.ResourceHealth/metadata/{name}"} diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_operations.py new file mode 100644 index 000000000000..a1929078f254 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_operations.py @@ -0,0 +1,107 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resourcehealth.v2023_10_01_preview.aio.ResourceHealthMgmtClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def list(self, **kwargs: Any) -> _models.OperationListResult: + """Lists available operations for the resourcehealth resource provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationListResult or the result of cls(response) + :rtype: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.OperationListResult + :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._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {"url": "/providers/Microsoft.ResourceHealth/operations"} diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_patch.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_security_advisory_impacted_resources_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_security_advisory_impacted_resources_operations.py new file mode 100644 index 000000000000..d026ba6d83f1 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/aio/operations/_security_advisory_impacted_resources_operations.py @@ -0,0 +1,250 @@ +# 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, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._security_advisory_impacted_resources_operations import ( + build_list_by_subscription_id_and_event_id_request, + build_list_by_tenant_id_and_event_id_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SecurityAdvisoryImpactedResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resourcehealth.v2023_10_01_preview.aio.ResourceHealthMgmtClient`'s + :attr:`security_advisory_impacted_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_subscription_id_and_event_id( + self, event_tracking_id: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.EventImpactedResource"]: + """Lists impacted resources in the subscription by an event (Security Advisory). + + :param event_tracking_id: Event Id which uniquely identifies ServiceHealth event. Required. + :type event_tracking_id: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EventImpactedResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventImpactedResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.EventImpactedResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_id_and_event_id_request( + event_tracking_id=event_tracking_id, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_subscription_id_and_event_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("EventImpactedResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_subscription_id_and_event_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/listSecurityAdvisoryImpactedResources" + } + + @distributed_trace + def list_by_tenant_id_and_event_id( + self, event_tracking_id: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.EventImpactedResource"]: + """Lists impacted resources in the tenant by an event (Security Advisory). + + :param event_tracking_id: Event Id which uniquely identifies ServiceHealth event. Required. + :type event_tracking_id: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EventImpactedResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventImpactedResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.EventImpactedResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_tenant_id_and_event_id_request( + event_tracking_id=event_tracking_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_tenant_id_and_event_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("EventImpactedResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_tenant_id_and_event_id.metadata = { + "url": "/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/listSecurityAdvisoryImpactedResources" + } diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/models/__init__.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/models/__init__.py new file mode 100644 index 000000000000..5bc434ae6fc6 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/models/__init__.py @@ -0,0 +1,127 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import AvailabilityStatus +from ._models_py3 import AvailabilityStatusListResult +from ._models_py3 import AvailabilityStatusProperties +from ._models_py3 import AvailabilityStatusPropertiesRecentlyResolved +from ._models_py3 import EmergingIssueImpact +from ._models_py3 import EmergingIssueListResult +from ._models_py3 import EmergingIssuesGetResult +from ._models_py3 import ErrorResponse +from ._models_py3 import Event +from ._models_py3 import EventImpactedResource +from ._models_py3 import EventImpactedResourceListResult +from ._models_py3 import EventPropertiesAdditionalInformation +from ._models_py3 import EventPropertiesArticle +from ._models_py3 import EventPropertiesRecommendedActions +from ._models_py3 import EventPropertiesRecommendedActionsItem +from ._models_py3 import Events +from ._models_py3 import Faq +from ._models_py3 import Impact +from ._models_py3 import ImpactedRegion +from ._models_py3 import ImpactedResourceStatus +from ._models_py3 import ImpactedServiceRegion +from ._models_py3 import KeyValueItem +from ._models_py3 import Link +from ._models_py3 import LinkDisplayText +from ._models_py3 import MetadataEntity +from ._models_py3 import MetadataEntityListResult +from ._models_py3 import MetadataSupportedValueDetail +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import ProxyResource +from ._models_py3 import RecommendedAction +from ._models_py3 import Resource +from ._models_py3 import ServiceImpactingEvent +from ._models_py3 import ServiceImpactingEventIncidentProperties +from ._models_py3 import ServiceImpactingEventStatus +from ._models_py3 import StatusActiveEvent +from ._models_py3 import StatusBanner +from ._models_py3 import SystemData +from ._models_py3 import Update + +from ._resource_health_mgmt_client_enums import AvailabilityStateValues +from ._resource_health_mgmt_client_enums import CreatedByType +from ._resource_health_mgmt_client_enums import EventLevelValues +from ._resource_health_mgmt_client_enums import EventSourceValues +from ._resource_health_mgmt_client_enums import EventStatusValues +from ._resource_health_mgmt_client_enums import EventSubTypeValues +from ._resource_health_mgmt_client_enums import EventTypeValues +from ._resource_health_mgmt_client_enums import IssueNameParameter +from ._resource_health_mgmt_client_enums import LevelValues +from ._resource_health_mgmt_client_enums import LinkTypeValues +from ._resource_health_mgmt_client_enums import ReasonChronicityTypes +from ._resource_health_mgmt_client_enums import ReasonTypeValues +from ._resource_health_mgmt_client_enums import Scenario +from ._resource_health_mgmt_client_enums import SeverityValues +from ._resource_health_mgmt_client_enums import StageValues +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AvailabilityStatus", + "AvailabilityStatusListResult", + "AvailabilityStatusProperties", + "AvailabilityStatusPropertiesRecentlyResolved", + "EmergingIssueImpact", + "EmergingIssueListResult", + "EmergingIssuesGetResult", + "ErrorResponse", + "Event", + "EventImpactedResource", + "EventImpactedResourceListResult", + "EventPropertiesAdditionalInformation", + "EventPropertiesArticle", + "EventPropertiesRecommendedActions", + "EventPropertiesRecommendedActionsItem", + "Events", + "Faq", + "Impact", + "ImpactedRegion", + "ImpactedResourceStatus", + "ImpactedServiceRegion", + "KeyValueItem", + "Link", + "LinkDisplayText", + "MetadataEntity", + "MetadataEntityListResult", + "MetadataSupportedValueDetail", + "Operation", + "OperationDisplay", + "OperationListResult", + "ProxyResource", + "RecommendedAction", + "Resource", + "ServiceImpactingEvent", + "ServiceImpactingEventIncidentProperties", + "ServiceImpactingEventStatus", + "StatusActiveEvent", + "StatusBanner", + "SystemData", + "Update", + "AvailabilityStateValues", + "CreatedByType", + "EventLevelValues", + "EventSourceValues", + "EventStatusValues", + "EventSubTypeValues", + "EventTypeValues", + "IssueNameParameter", + "LevelValues", + "LinkTypeValues", + "ReasonChronicityTypes", + "ReasonTypeValues", + "Scenario", + "SeverityValues", + "StageValues", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/models/_models_py3.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/models/_models_py3.py new file mode 100644 index 000000000000..7fdfec5e45c0 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/models/_models_py3.py @@ -0,0 +1,2225 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +import sys +from typing import Any, List, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object + + +class AvailabilityStatus(_serialization.Model): + """availabilityStatus of a resource. + + :ivar id: Azure Resource Manager Identity for the availabilityStatuses resource. + :vartype id: str + :ivar name: current. + :vartype name: str + :ivar type: Microsoft.ResourceHealth/AvailabilityStatuses. + :vartype type: str + :ivar location: Azure Resource Manager geo location of the resource. + :vartype location: str + :ivar properties: Properties of availability state. + :vartype properties: + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.AvailabilityStatusProperties + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "AvailabilityStatusProperties"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + type: Optional[str] = None, + location: Optional[str] = None, + properties: Optional["_models.AvailabilityStatusProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Azure Resource Manager Identity for the availabilityStatuses resource. + :paramtype id: str + :keyword name: current. + :paramtype name: str + :keyword type: Microsoft.ResourceHealth/AvailabilityStatuses. + :paramtype type: str + :keyword location: Azure Resource Manager geo location of the resource. + :paramtype location: str + :keyword properties: Properties of availability state. + :paramtype properties: + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.AvailabilityStatusProperties + """ + super().__init__(**kwargs) + self.id = id + self.name = name + self.type = type + self.location = location + self.properties = properties + + +class AvailabilityStatusListResult(_serialization.Model): + """The List availabilityStatus operation response. + + All required parameters must be populated in order to send to Azure. + + :ivar value: The list of availabilityStatuses. Required. + :vartype value: list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.AvailabilityStatus] + :ivar next_link: The URI to fetch the next page of availabilityStatuses. Call ListNext() with + this URI to fetch the next page of availabilityStatuses. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[AvailabilityStatus]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.AvailabilityStatus"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The list of availabilityStatuses. Required. + :paramtype value: + list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.AvailabilityStatus] + :keyword next_link: The URI to fetch the next page of availabilityStatuses. Call ListNext() + with this URI to fetch the next page of availabilityStatuses. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AvailabilityStatusProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes + """Properties of availability state. + + :ivar availability_state: Availability status of the resource. When it is null, this + availabilityStatus object represents an availability impacting event. Known values are: + "Available", "Unavailable", "Degraded", and "Unknown". + :vartype availability_state: str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.AvailabilityStateValues + :ivar title: Title description of the availability status. + :vartype title: str + :ivar summary: Summary description of the availability status. + :vartype summary: str + :ivar detailed_status: Details of the availability status. + :vartype detailed_status: str + :ivar reason_type: When the resource's availabilityState is Unavailable, it describes where the + health impacting event was originated. Examples are planned, unplanned, user initiated or an + outage etc. + :vartype reason_type: str + :ivar context: When an event is created, it can either be triggered by a customer or the + platform of the resource and this field will illustrate that. This field is connected to the + category field in this object. + :vartype context: str + :ivar category: When a context field is set to Platform, this field will reflect if the event + was planned or unplanned. If the context field does not have a value of Platform, then this + field will be ignored. + :vartype category: str + :ivar article_id: The Article Id. + :vartype article_id: str + :ivar root_cause_attribution_time: When the resource's availabilityState is Unavailable, it + provides the Timestamp for when the health impacting event was received. + :vartype root_cause_attribution_time: ~datetime.datetime + :ivar health_event_type: In case of an availability impacting event, it describes when the + health impacting event was originated. Examples are Lifecycle, Downtime, Fault Analysis etc. + :vartype health_event_type: str + :ivar health_event_cause: In case of an availability impacting event, it describes where the + health impacting event was originated. Examples are PlatformInitiated, UserInitiated etc. + :vartype health_event_cause: str + :ivar health_event_category: In case of an availability impacting event, it describes the + category of a PlatformInitiated health impacting event. Examples are Planned, Unplanned etc. + :vartype health_event_category: str + :ivar health_event_id: It is a unique Id that identifies the event. + :vartype health_event_id: str + :ivar resolution_eta: When the resource's availabilityState is Unavailable and the reasonType + is not User Initiated, it provides the date and time for when the issue is expected to be + resolved. + :vartype resolution_eta: ~datetime.datetime + :ivar occured_time: Timestamp for when last change in health status occurred. + :vartype occured_time: ~datetime.datetime + :ivar reason_chronicity: Chronicity of the availability transition. Known values are: + "Transient" and "Persistent". + :vartype reason_chronicity: str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.ReasonChronicityTypes + :ivar reported_time: Timestamp for when the health was last checked. + :vartype reported_time: ~datetime.datetime + :ivar recently_resolved: An annotation describing a change in the availabilityState to + Available from Unavailable with a reasonType of type Unplanned. + :vartype recently_resolved: + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.AvailabilityStatusPropertiesRecentlyResolved + :ivar recommended_actions: Lists actions the user can take based on the current + availabilityState of the resource. + :vartype recommended_actions: + list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.RecommendedAction] + :ivar service_impacting_events: Lists the service impacting events that may be affecting the + health of the resource. + :vartype service_impacting_events: + list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.ServiceImpactingEvent] + """ + + _attribute_map = { + "availability_state": {"key": "availabilityState", "type": "str"}, + "title": {"key": "title", "type": "str"}, + "summary": {"key": "summary", "type": "str"}, + "detailed_status": {"key": "detailedStatus", "type": "str"}, + "reason_type": {"key": "reasonType", "type": "str"}, + "context": {"key": "context", "type": "str"}, + "category": {"key": "category", "type": "str"}, + "article_id": {"key": "articleId", "type": "str"}, + "root_cause_attribution_time": {"key": "rootCauseAttributionTime", "type": "iso-8601"}, + "health_event_type": {"key": "healthEventType", "type": "str"}, + "health_event_cause": {"key": "healthEventCause", "type": "str"}, + "health_event_category": {"key": "healthEventCategory", "type": "str"}, + "health_event_id": {"key": "healthEventId", "type": "str"}, + "resolution_eta": {"key": "resolutionETA", "type": "iso-8601"}, + "occured_time": {"key": "occuredTime", "type": "iso-8601"}, + "reason_chronicity": {"key": "reasonChronicity", "type": "str"}, + "reported_time": {"key": "reportedTime", "type": "iso-8601"}, + "recently_resolved": {"key": "recentlyResolved", "type": "AvailabilityStatusPropertiesRecentlyResolved"}, + "recommended_actions": {"key": "recommendedActions", "type": "[RecommendedAction]"}, + "service_impacting_events": {"key": "serviceImpactingEvents", "type": "[ServiceImpactingEvent]"}, + } + + def __init__( + self, + *, + availability_state: Optional[Union[str, "_models.AvailabilityStateValues"]] = None, + title: Optional[str] = None, + summary: Optional[str] = None, + detailed_status: Optional[str] = None, + reason_type: Optional[str] = None, + context: Optional[str] = None, + category: Optional[str] = None, + article_id: Optional[str] = None, + root_cause_attribution_time: Optional[datetime.datetime] = None, + health_event_type: Optional[str] = None, + health_event_cause: Optional[str] = None, + health_event_category: Optional[str] = None, + health_event_id: Optional[str] = None, + resolution_eta: Optional[datetime.datetime] = None, + occured_time: Optional[datetime.datetime] = None, + reason_chronicity: Optional[Union[str, "_models.ReasonChronicityTypes"]] = None, + reported_time: Optional[datetime.datetime] = None, + recently_resolved: Optional["_models.AvailabilityStatusPropertiesRecentlyResolved"] = None, + recommended_actions: Optional[List["_models.RecommendedAction"]] = None, + service_impacting_events: Optional[List["_models.ServiceImpactingEvent"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword availability_state: Availability status of the resource. When it is null, this + availabilityStatus object represents an availability impacting event. Known values are: + "Available", "Unavailable", "Degraded", and "Unknown". + :paramtype availability_state: str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.AvailabilityStateValues + :keyword title: Title description of the availability status. + :paramtype title: str + :keyword summary: Summary description of the availability status. + :paramtype summary: str + :keyword detailed_status: Details of the availability status. + :paramtype detailed_status: str + :keyword reason_type: When the resource's availabilityState is Unavailable, it describes where + the health impacting event was originated. Examples are planned, unplanned, user initiated or + an outage etc. + :paramtype reason_type: str + :keyword context: When an event is created, it can either be triggered by a customer or the + platform of the resource and this field will illustrate that. This field is connected to the + category field in this object. + :paramtype context: str + :keyword category: When a context field is set to Platform, this field will reflect if the + event was planned or unplanned. If the context field does not have a value of Platform, then + this field will be ignored. + :paramtype category: str + :keyword article_id: The Article Id. + :paramtype article_id: str + :keyword root_cause_attribution_time: When the resource's availabilityState is Unavailable, it + provides the Timestamp for when the health impacting event was received. + :paramtype root_cause_attribution_time: ~datetime.datetime + :keyword health_event_type: In case of an availability impacting event, it describes when the + health impacting event was originated. Examples are Lifecycle, Downtime, Fault Analysis etc. + :paramtype health_event_type: str + :keyword health_event_cause: In case of an availability impacting event, it describes where the + health impacting event was originated. Examples are PlatformInitiated, UserInitiated etc. + :paramtype health_event_cause: str + :keyword health_event_category: In case of an availability impacting event, it describes the + category of a PlatformInitiated health impacting event. Examples are Planned, Unplanned etc. + :paramtype health_event_category: str + :keyword health_event_id: It is a unique Id that identifies the event. + :paramtype health_event_id: str + :keyword resolution_eta: When the resource's availabilityState is Unavailable and the + reasonType is not User Initiated, it provides the date and time for when the issue is expected + to be resolved. + :paramtype resolution_eta: ~datetime.datetime + :keyword occured_time: Timestamp for when last change in health status occurred. + :paramtype occured_time: ~datetime.datetime + :keyword reason_chronicity: Chronicity of the availability transition. Known values are: + "Transient" and "Persistent". + :paramtype reason_chronicity: str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.ReasonChronicityTypes + :keyword reported_time: Timestamp for when the health was last checked. + :paramtype reported_time: ~datetime.datetime + :keyword recently_resolved: An annotation describing a change in the availabilityState to + Available from Unavailable with a reasonType of type Unplanned. + :paramtype recently_resolved: + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.AvailabilityStatusPropertiesRecentlyResolved + :keyword recommended_actions: Lists actions the user can take based on the current + availabilityState of the resource. + :paramtype recommended_actions: + list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.RecommendedAction] + :keyword service_impacting_events: Lists the service impacting events that may be affecting the + health of the resource. + :paramtype service_impacting_events: + list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.ServiceImpactingEvent] + """ + super().__init__(**kwargs) + self.availability_state = availability_state + self.title = title + self.summary = summary + self.detailed_status = detailed_status + self.reason_type = reason_type + self.context = context + self.category = category + self.article_id = article_id + self.root_cause_attribution_time = root_cause_attribution_time + self.health_event_type = health_event_type + self.health_event_cause = health_event_cause + self.health_event_category = health_event_category + self.health_event_id = health_event_id + self.resolution_eta = resolution_eta + self.occured_time = occured_time + self.reason_chronicity = reason_chronicity + self.reported_time = reported_time + self.recently_resolved = recently_resolved + self.recommended_actions = recommended_actions + self.service_impacting_events = service_impacting_events + + +class AvailabilityStatusPropertiesRecentlyResolved(_serialization.Model): + """An annotation describing a change in the availabilityState to Available from Unavailable with a + reasonType of type Unplanned. + + :ivar unavailable_occured_time: Timestamp for when the availabilityState changed to + Unavailable. + :vartype unavailable_occured_time: ~datetime.datetime + :ivar resolved_time: Timestamp when the availabilityState changes to Available. + :vartype resolved_time: ~datetime.datetime + :ivar unavailable_summary: Brief description of cause of the resource becoming unavailable. + :vartype unavailable_summary: str + """ + + _attribute_map = { + "unavailable_occured_time": {"key": "unavailableOccuredTime", "type": "iso-8601"}, + "resolved_time": {"key": "resolvedTime", "type": "iso-8601"}, + "unavailable_summary": {"key": "unavailableSummary", "type": "str"}, + } + + def __init__( + self, + *, + unavailable_occured_time: Optional[datetime.datetime] = None, + resolved_time: Optional[datetime.datetime] = None, + unavailable_summary: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword unavailable_occured_time: Timestamp for when the availabilityState changed to + Unavailable. + :paramtype unavailable_occured_time: ~datetime.datetime + :keyword resolved_time: Timestamp when the availabilityState changes to Available. + :paramtype resolved_time: ~datetime.datetime + :keyword unavailable_summary: Brief description of cause of the resource becoming unavailable. + :paramtype unavailable_summary: str + """ + super().__init__(**kwargs) + self.unavailable_occured_time = unavailable_occured_time + self.resolved_time = resolved_time + self.unavailable_summary = unavailable_summary + + +class EmergingIssueImpact(_serialization.Model): + """Object of the emerging issue impact on services and regions. + + :ivar id: The impacted service id. + :vartype id: str + :ivar name: The impacted service name. + :vartype name: str + :ivar regions: The list of impacted regions for corresponding emerging issues. + :vartype regions: list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.ImpactedRegion] + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "regions": {"key": "regions", "type": "[ImpactedRegion]"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + regions: Optional[List["_models.ImpactedRegion"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The impacted service id. + :paramtype id: str + :keyword name: The impacted service name. + :paramtype name: str + :keyword regions: The list of impacted regions for corresponding emerging issues. + :paramtype regions: list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.ImpactedRegion] + """ + super().__init__(**kwargs) + self.id = id + self.name = name + self.regions = regions + + +class EmergingIssueListResult(_serialization.Model): + """The list of emerging issues. + + :ivar value: The list of emerging issues. + :vartype value: + list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EmergingIssuesGetResult] + :ivar next_link: The link used to get the next page of emerging issues. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[EmergingIssuesGetResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.EmergingIssuesGetResult"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: The list of emerging issues. + :paramtype value: + list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EmergingIssuesGetResult] + :keyword next_link: The link used to get the next page of emerging issues. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class Resource(_serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = None + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have + tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + + +class EmergingIssuesGetResult(ProxyResource): + """The Get EmergingIssues operation response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.SystemData + :ivar refresh_timestamp: Timestamp for when last time refreshed for ongoing emerging issue. + :vartype refresh_timestamp: ~datetime.datetime + :ivar status_banners: The list of emerging issues of banner type. + :vartype status_banners: + list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.StatusBanner] + :ivar status_active_events: The list of emerging issues of active event type. + :vartype status_active_events: + list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.StatusActiveEvent] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "refresh_timestamp": {"key": "properties.refreshTimestamp", "type": "iso-8601"}, + "status_banners": {"key": "properties.statusBanners", "type": "[StatusBanner]"}, + "status_active_events": {"key": "properties.statusActiveEvents", "type": "[StatusActiveEvent]"}, + } + + def __init__( + self, + *, + refresh_timestamp: Optional[datetime.datetime] = None, + status_banners: Optional[List["_models.StatusBanner"]] = None, + status_active_events: Optional[List["_models.StatusActiveEvent"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword refresh_timestamp: Timestamp for when last time refreshed for ongoing emerging issue. + :paramtype refresh_timestamp: ~datetime.datetime + :keyword status_banners: The list of emerging issues of banner type. + :paramtype status_banners: + list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.StatusBanner] + :keyword status_active_events: The list of emerging issues of active event type. + :paramtype status_active_events: + list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.StatusActiveEvent] + """ + super().__init__(**kwargs) + self.refresh_timestamp = refresh_timestamp + self.status_banners = status_banners + self.status_active_events = status_active_events + + +class ErrorResponse(_serialization.Model): + """Error details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar details: The error details. + :vartype details: str + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "details": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.details = None + + +class Event(ProxyResource): # pylint: disable=too-many-instance-attributes + """Service health event. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.SystemData + :ivar event_type: Type of event. Known values are: "ServiceIssue", "PlannedMaintenance", + "HealthAdvisory", "RCA", "EmergingIssues", and "SecurityAdvisory". + :vartype event_type: str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventTypeValues + :ivar event_sub_type: Sub type of the event. Currently used to determine retirement + communications for health advisory events. "Retirement" + :vartype event_sub_type: str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventSubTypeValues + :ivar event_source: Source of event. Known values are: "ResourceHealth" and "ServiceHealth". + :vartype event_source: str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventSourceValues + :ivar status: Current status of event. Known values are: "Active" and "Resolved". + :vartype status: str or ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventStatusValues + :ivar title: Title text of event. + :vartype title: str + :ivar summary: Summary text of event. + :vartype summary: str + :ivar header: Header text of event. + :vartype header: str + :ivar level: Level of insight. Known values are: "Critical" and "Warning". + :vartype level: str or ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.LevelValues + :ivar event_level: Level of event. Known values are: "Critical", "Error", "Warning", and + "Informational". + :vartype event_level: str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventLevelValues + :ivar external_incident_id: The id of the Incident. + :vartype external_incident_id: str + :ivar reason: The reason for the Incident. + :vartype reason: str + :ivar article: Article of event. + :vartype article: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventPropertiesArticle + :ivar links: Useful links of event. + :vartype links: list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Link] + :ivar impact_start_time: It provides the Timestamp for when the health impacting event started. + :vartype impact_start_time: ~datetime.datetime + :ivar impact_mitigation_time: It provides the Timestamp for when the health impacting event + resolved. + :vartype impact_mitigation_time: ~datetime.datetime + :ivar impact: List services impacted by the service health event. + :vartype impact: list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Impact] + :ivar recommended_actions: Recommended actions of event. + :vartype recommended_actions: + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventPropertiesRecommendedActions + :ivar faqs: Frequently asked questions for the service health event. + :vartype faqs: list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Faq] + :ivar is_hir: It provides information if the event is High incident rate event or not. + :vartype is_hir: bool + :ivar enable_microsoft_support: Tells if we want to enable or disable Microsoft Support for + this event. + :vartype enable_microsoft_support: bool + :ivar description: Contains the communication message for the event, that could include + summary, root cause and other details. + :vartype description: str + :ivar platform_initiated: Is true if the event is platform initiated. + :vartype platform_initiated: bool + :ivar enable_chat_with_us: Tells if we want to enable or disable Microsoft Support for this + event. + :vartype enable_chat_with_us: bool + :ivar priority: Priority level of the event. Has value from 0 to 23. 0 is the highest priority. + Service issue events have higher priority followed by planned maintenance and health advisory. + Critical events have higher priority followed by error, warning and informational. Furthermore, + active events have higher priority than resolved. + :vartype priority: int + :ivar last_update_time: It provides the Timestamp for when the health impacting event was last + updated. + :vartype last_update_time: ~datetime.datetime + :ivar hir_stage: Stage for HIR Document. + :vartype hir_stage: str + :ivar additional_information: Additional information. + :vartype additional_information: + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventPropertiesAdditionalInformation + :ivar duration: duration in seconds. + :vartype duration: int + :ivar impact_type: The type of the impact. + :vartype impact_type: str + :ivar maintenance_id: Unique identifier for planned maintenance event. + :vartype maintenance_id: str + :ivar maintenance_type: The type of planned maintenance event. + :vartype maintenance_type: str + :ivar arg_query: Azure Resource Graph query to fetch the affected resources from their existing + Azure Resource Graph locations. + :vartype arg_query: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "event_type": {"key": "properties.eventType", "type": "str"}, + "event_sub_type": {"key": "properties.eventSubType", "type": "str"}, + "event_source": {"key": "properties.eventSource", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "title": {"key": "properties.title", "type": "str"}, + "summary": {"key": "properties.summary", "type": "str"}, + "header": {"key": "properties.header", "type": "str"}, + "level": {"key": "properties.level", "type": "str"}, + "event_level": {"key": "properties.eventLevel", "type": "str"}, + "external_incident_id": {"key": "properties.externalIncidentId", "type": "str"}, + "reason": {"key": "properties.reason", "type": "str"}, + "article": {"key": "properties.article", "type": "EventPropertiesArticle"}, + "links": {"key": "properties.links", "type": "[Link]"}, + "impact_start_time": {"key": "properties.impactStartTime", "type": "iso-8601"}, + "impact_mitigation_time": {"key": "properties.impactMitigationTime", "type": "iso-8601"}, + "impact": {"key": "properties.impact", "type": "[Impact]"}, + "recommended_actions": {"key": "properties.recommendedActions", "type": "EventPropertiesRecommendedActions"}, + "faqs": {"key": "properties.faqs", "type": "[Faq]"}, + "is_hir": {"key": "properties.isHIR", "type": "bool"}, + "enable_microsoft_support": {"key": "properties.enableMicrosoftSupport", "type": "bool"}, + "description": {"key": "properties.description", "type": "str"}, + "platform_initiated": {"key": "properties.platformInitiated", "type": "bool"}, + "enable_chat_with_us": {"key": "properties.enableChatWithUs", "type": "bool"}, + "priority": {"key": "properties.priority", "type": "int"}, + "last_update_time": {"key": "properties.lastUpdateTime", "type": "iso-8601"}, + "hir_stage": {"key": "properties.hirStage", "type": "str"}, + "additional_information": { + "key": "properties.additionalInformation", + "type": "EventPropertiesAdditionalInformation", + }, + "duration": {"key": "properties.duration", "type": "int"}, + "impact_type": {"key": "properties.impactType", "type": "str"}, + "maintenance_id": {"key": "properties.maintenanceId", "type": "str"}, + "maintenance_type": {"key": "properties.maintenanceType", "type": "str"}, + "arg_query": {"key": "properties.argQuery", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals + self, + *, + event_type: Optional[Union[str, "_models.EventTypeValues"]] = None, + event_sub_type: Optional[Union[str, "_models.EventSubTypeValues"]] = None, + event_source: Optional[Union[str, "_models.EventSourceValues"]] = None, + status: Optional[Union[str, "_models.EventStatusValues"]] = None, + title: Optional[str] = None, + summary: Optional[str] = None, + header: Optional[str] = None, + level: Optional[Union[str, "_models.LevelValues"]] = None, + event_level: Optional[Union[str, "_models.EventLevelValues"]] = None, + external_incident_id: Optional[str] = None, + reason: Optional[str] = None, + article: Optional["_models.EventPropertiesArticle"] = None, + links: Optional[List["_models.Link"]] = None, + impact_start_time: Optional[datetime.datetime] = None, + impact_mitigation_time: Optional[datetime.datetime] = None, + impact: Optional[List["_models.Impact"]] = None, + recommended_actions: Optional["_models.EventPropertiesRecommendedActions"] = None, + faqs: Optional[List["_models.Faq"]] = None, + is_hir: Optional[bool] = None, + enable_microsoft_support: Optional[bool] = None, + description: Optional[str] = None, + platform_initiated: Optional[bool] = None, + enable_chat_with_us: Optional[bool] = None, + priority: Optional[int] = None, + last_update_time: Optional[datetime.datetime] = None, + hir_stage: Optional[str] = None, + additional_information: Optional["_models.EventPropertiesAdditionalInformation"] = None, + duration: Optional[int] = None, + impact_type: Optional[str] = None, + maintenance_id: Optional[str] = None, + maintenance_type: Optional[str] = None, + arg_query: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword event_type: Type of event. Known values are: "ServiceIssue", "PlannedMaintenance", + "HealthAdvisory", "RCA", "EmergingIssues", and "SecurityAdvisory". + :paramtype event_type: str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventTypeValues + :keyword event_sub_type: Sub type of the event. Currently used to determine retirement + communications for health advisory events. "Retirement" + :paramtype event_sub_type: str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventSubTypeValues + :keyword event_source: Source of event. Known values are: "ResourceHealth" and "ServiceHealth". + :paramtype event_source: str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventSourceValues + :keyword status: Current status of event. Known values are: "Active" and "Resolved". + :paramtype status: str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventStatusValues + :keyword title: Title text of event. + :paramtype title: str + :keyword summary: Summary text of event. + :paramtype summary: str + :keyword header: Header text of event. + :paramtype header: str + :keyword level: Level of insight. Known values are: "Critical" and "Warning". + :paramtype level: str or ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.LevelValues + :keyword event_level: Level of event. Known values are: "Critical", "Error", "Warning", and + "Informational". + :paramtype event_level: str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventLevelValues + :keyword external_incident_id: The id of the Incident. + :paramtype external_incident_id: str + :keyword reason: The reason for the Incident. + :paramtype reason: str + :keyword article: Article of event. + :paramtype article: + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventPropertiesArticle + :keyword links: Useful links of event. + :paramtype links: list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Link] + :keyword impact_start_time: It provides the Timestamp for when the health impacting event + started. + :paramtype impact_start_time: ~datetime.datetime + :keyword impact_mitigation_time: It provides the Timestamp for when the health impacting event + resolved. + :paramtype impact_mitigation_time: ~datetime.datetime + :keyword impact: List services impacted by the service health event. + :paramtype impact: list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Impact] + :keyword recommended_actions: Recommended actions of event. + :paramtype recommended_actions: + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventPropertiesRecommendedActions + :keyword faqs: Frequently asked questions for the service health event. + :paramtype faqs: list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Faq] + :keyword is_hir: It provides information if the event is High incident rate event or not. + :paramtype is_hir: bool + :keyword enable_microsoft_support: Tells if we want to enable or disable Microsoft Support for + this event. + :paramtype enable_microsoft_support: bool + :keyword description: Contains the communication message for the event, that could include + summary, root cause and other details. + :paramtype description: str + :keyword platform_initiated: Is true if the event is platform initiated. + :paramtype platform_initiated: bool + :keyword enable_chat_with_us: Tells if we want to enable or disable Microsoft Support for this + event. + :paramtype enable_chat_with_us: bool + :keyword priority: Priority level of the event. Has value from 0 to 23. 0 is the highest + priority. Service issue events have higher priority followed by planned maintenance and health + advisory. Critical events have higher priority followed by error, warning and informational. + Furthermore, active events have higher priority than resolved. + :paramtype priority: int + :keyword last_update_time: It provides the Timestamp for when the health impacting event was + last updated. + :paramtype last_update_time: ~datetime.datetime + :keyword hir_stage: Stage for HIR Document. + :paramtype hir_stage: str + :keyword additional_information: Additional information. + :paramtype additional_information: + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventPropertiesAdditionalInformation + :keyword duration: duration in seconds. + :paramtype duration: int + :keyword impact_type: The type of the impact. + :paramtype impact_type: str + :keyword maintenance_id: Unique identifier for planned maintenance event. + :paramtype maintenance_id: str + :keyword maintenance_type: The type of planned maintenance event. + :paramtype maintenance_type: str + :keyword arg_query: Azure Resource Graph query to fetch the affected resources from their + existing Azure Resource Graph locations. + :paramtype arg_query: str + """ + super().__init__(**kwargs) + self.event_type = event_type + self.event_sub_type = event_sub_type + self.event_source = event_source + self.status = status + self.title = title + self.summary = summary + self.header = header + self.level = level + self.event_level = event_level + self.external_incident_id = external_incident_id + self.reason = reason + self.article = article + self.links = links + self.impact_start_time = impact_start_time + self.impact_mitigation_time = impact_mitigation_time + self.impact = impact + self.recommended_actions = recommended_actions + self.faqs = faqs + self.is_hir = is_hir + self.enable_microsoft_support = enable_microsoft_support + self.description = description + self.platform_initiated = platform_initiated + self.enable_chat_with_us = enable_chat_with_us + self.priority = priority + self.last_update_time = last_update_time + self.hir_stage = hir_stage + self.additional_information = additional_information + self.duration = duration + self.impact_type = impact_type + self.maintenance_id = maintenance_id + self.maintenance_type = maintenance_type + self.arg_query = arg_query + + +class EventImpactedResource(ProxyResource): # pylint: disable=too-many-instance-attributes + """Impacted resource for an event. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.SystemData + :ivar target_resource_type: Resource type within Microsoft cloud. + :vartype target_resource_type: str + :ivar target_resource_id: Identity for resource within Microsoft cloud. + :vartype target_resource_id: str + :ivar target_region: Impacted resource region name. + :vartype target_region: str + :ivar resource_name: Resource name of the impacted resource. + :vartype resource_name: str + :ivar resource_group: Resource group name of the impacted resource. + :vartype resource_group: str + :ivar status: Status of the impacted resource. + :vartype status: str + :ivar maintenance_start_time: Start time of maintenance for the impacted resource. + :vartype maintenance_start_time: str + :ivar maintenance_end_time: End time of maintenance for the impacted resource. + :vartype maintenance_end_time: str + :ivar info: Additional information. + :vartype info: list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.KeyValueItem] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "target_resource_type": {"readonly": True}, + "target_resource_id": {"readonly": True}, + "target_region": {"readonly": True}, + "resource_name": {"readonly": True}, + "resource_group": {"readonly": True}, + "status": {"readonly": True}, + "maintenance_start_time": {"readonly": True}, + "maintenance_end_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "target_resource_type": {"key": "properties.targetResourceType", "type": "str"}, + "target_resource_id": {"key": "properties.targetResourceId", "type": "str"}, + "target_region": {"key": "properties.targetRegion", "type": "str"}, + "resource_name": {"key": "properties.resourceName", "type": "str"}, + "resource_group": {"key": "properties.resourceGroup", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "maintenance_start_time": {"key": "properties.maintenanceStartTime", "type": "str"}, + "maintenance_end_time": {"key": "properties.maintenanceEndTime", "type": "str"}, + "info": {"key": "properties.info", "type": "[KeyValueItem]"}, + } + + def __init__(self, *, info: Optional[List["_models.KeyValueItem"]] = None, **kwargs: Any) -> None: + """ + :keyword info: Additional information. + :paramtype info: list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.KeyValueItem] + """ + super().__init__(**kwargs) + self.target_resource_type = None + self.target_resource_id = None + self.target_region = None + self.resource_name = None + self.resource_group = None + self.status = None + self.maintenance_start_time = None + self.maintenance_end_time = None + self.info = info + + +class EventImpactedResourceListResult(_serialization.Model): + """The List of eventImpactedResources operation response. + + All required parameters must be populated in order to send to Azure. + + :ivar value: The list of eventImpactedResources. Required. + :vartype value: + list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventImpactedResource] + :ivar next_link: The URI to fetch the next page of events. Call ListNext() with this URI to + fetch the next page of impacted resource. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[EventImpactedResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.EventImpactedResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The list of eventImpactedResources. Required. + :paramtype value: + list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventImpactedResource] + :keyword next_link: The URI to fetch the next page of events. Call ListNext() with this URI to + fetch the next page of impacted resource. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class EventPropertiesAdditionalInformation(_serialization.Model): + """Additional information. + + :ivar message: Additional information Message. + :vartype message: str + """ + + _attribute_map = { + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, *, message: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword message: Additional information Message. + :paramtype message: str + """ + super().__init__(**kwargs) + self.message = message + + +class EventPropertiesArticle(_serialization.Model): + """Article of event. + + :ivar article_content: Article content of event. + :vartype article_content: str + :ivar article_id: Article Id. + :vartype article_id: str + :ivar parameters: It provides a map of parameter name and value. + :vartype parameters: JSON + """ + + _attribute_map = { + "article_content": {"key": "articleContent", "type": "str"}, + "article_id": {"key": "articleId", "type": "str"}, + "parameters": {"key": "parameters", "type": "object"}, + } + + def __init__( + self, + *, + article_content: Optional[str] = None, + article_id: Optional[str] = None, + parameters: Optional[JSON] = None, + **kwargs: Any + ) -> None: + """ + :keyword article_content: Article content of event. + :paramtype article_content: str + :keyword article_id: Article Id. + :paramtype article_id: str + :keyword parameters: It provides a map of parameter name and value. + :paramtype parameters: JSON + """ + super().__init__(**kwargs) + self.article_content = article_content + self.article_id = article_id + self.parameters = parameters + + +class EventPropertiesRecommendedActions(_serialization.Model): + """Recommended actions of event. + + :ivar message: Recommended action title for the service health event. + :vartype message: str + :ivar actions: Recommended actions for the service health event. + :vartype actions: + list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventPropertiesRecommendedActionsItem] + :ivar locale_code: Recommended action locale for the service health event. + :vartype locale_code: str + """ + + _attribute_map = { + "message": {"key": "message", "type": "str"}, + "actions": {"key": "actions", "type": "[EventPropertiesRecommendedActionsItem]"}, + "locale_code": {"key": "localeCode", "type": "str"}, + } + + def __init__( + self, + *, + message: Optional[str] = None, + actions: Optional[List["_models.EventPropertiesRecommendedActionsItem"]] = None, + locale_code: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword message: Recommended action title for the service health event. + :paramtype message: str + :keyword actions: Recommended actions for the service health event. + :paramtype actions: + list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventPropertiesRecommendedActionsItem] + :keyword locale_code: Recommended action locale for the service health event. + :paramtype locale_code: str + """ + super().__init__(**kwargs) + self.message = message + self.actions = actions + self.locale_code = locale_code + + +class EventPropertiesRecommendedActionsItem(_serialization.Model): + """Recommended action for the service health event. + + :ivar group_id: Recommended action group Id for the service health event. + :vartype group_id: int + :ivar action_text: Recommended action text. + :vartype action_text: str + """ + + _attribute_map = { + "group_id": {"key": "groupId", "type": "int"}, + "action_text": {"key": "actionText", "type": "str"}, + } + + def __init__(self, *, group_id: Optional[int] = None, action_text: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword group_id: Recommended action group Id for the service health event. + :paramtype group_id: int + :keyword action_text: Recommended action text. + :paramtype action_text: str + """ + super().__init__(**kwargs) + self.group_id = group_id + self.action_text = action_text + + +class Events(_serialization.Model): + """The List events operation response. + + All required parameters must be populated in order to send to Azure. + + :ivar value: The list of event. Required. + :vartype value: list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Event] + :ivar next_link: The URI to fetch the next page of events. Call ListNext() with this URI to + fetch the next page of events. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Event]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.Event"], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: The list of event. Required. + :paramtype value: list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Event] + :keyword next_link: The URI to fetch the next page of events. Call ListNext() with this URI to + fetch the next page of events. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class Faq(_serialization.Model): + """Frequently asked question for the service health event. + + :ivar question: FAQ question for the service health event. + :vartype question: str + :ivar answer: FAQ answer for the service health event. + :vartype answer: str + :ivar locale_code: FAQ locale for the service health event. + :vartype locale_code: str + """ + + _attribute_map = { + "question": {"key": "question", "type": "str"}, + "answer": {"key": "answer", "type": "str"}, + "locale_code": {"key": "localeCode", "type": "str"}, + } + + def __init__( + self, + *, + question: Optional[str] = None, + answer: Optional[str] = None, + locale_code: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword question: FAQ question for the service health event. + :paramtype question: str + :keyword answer: FAQ answer for the service health event. + :paramtype answer: str + :keyword locale_code: FAQ locale for the service health event. + :paramtype locale_code: str + """ + super().__init__(**kwargs) + self.question = question + self.answer = answer + self.locale_code = locale_code + + +class Impact(_serialization.Model): + """Azure service impacted by the service health event. + + :ivar impacted_service: Impacted service name. + :vartype impacted_service: str + :ivar impacted_regions: List regions impacted by the service health event. + :vartype impacted_regions: + list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.ImpactedServiceRegion] + """ + + _attribute_map = { + "impacted_service": {"key": "impactedService", "type": "str"}, + "impacted_regions": {"key": "impactedRegions", "type": "[ImpactedServiceRegion]"}, + } + + def __init__( + self, + *, + impacted_service: Optional[str] = None, + impacted_regions: Optional[List["_models.ImpactedServiceRegion"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword impacted_service: Impacted service name. + :paramtype impacted_service: str + :keyword impacted_regions: List regions impacted by the service health event. + :paramtype impacted_regions: + list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.ImpactedServiceRegion] + """ + super().__init__(**kwargs) + self.impacted_service = impacted_service + self.impacted_regions = impacted_regions + + +class ImpactedRegion(_serialization.Model): + """Object of impacted region. + + :ivar id: The impacted region id. + :vartype id: str + :ivar name: The impacted region name. + :vartype name: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The impacted region id. + :paramtype id: str + :keyword name: The impacted region name. + :paramtype name: str + """ + super().__init__(**kwargs) + self.id = id + self.name = name + + +class ImpactedResourceStatus(ProxyResource): + """impactedResource with health status. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.SystemData + :ivar availability_state: Impacted resource status of the resource. Known values are: + "Available", "Unavailable", "Degraded", and "Unknown". + :vartype availability_state: str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.AvailabilityStateValues + :ivar title: Title description of the impacted resource status. + :vartype title: str + :ivar summary: Summary description of the impacted resource status. + :vartype summary: str + :ivar reason_type: When the resource's availabilityState is Unavailable, it describes where the + health impacting event was originated. Known values are: "Unplanned", "Planned", and + "UserInitiated". + :vartype reason_type: str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.ReasonTypeValues + :ivar occurred_time: Timestamp for when last change in health status occurred. + :vartype occurred_time: ~datetime.datetime + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "availability_state": {"key": "properties.availabilityState", "type": "str"}, + "title": {"key": "properties.title", "type": "str"}, + "summary": {"key": "properties.summary", "type": "str"}, + "reason_type": {"key": "properties.reasonType", "type": "str"}, + "occurred_time": {"key": "properties.occurredTime", "type": "iso-8601"}, + } + + def __init__( + self, + *, + availability_state: Optional[Union[str, "_models.AvailabilityStateValues"]] = None, + title: Optional[str] = None, + summary: Optional[str] = None, + reason_type: Optional[Union[str, "_models.ReasonTypeValues"]] = None, + occurred_time: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword availability_state: Impacted resource status of the resource. Known values are: + "Available", "Unavailable", "Degraded", and "Unknown". + :paramtype availability_state: str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.AvailabilityStateValues + :keyword title: Title description of the impacted resource status. + :paramtype title: str + :keyword summary: Summary description of the impacted resource status. + :paramtype summary: str + :keyword reason_type: When the resource's availabilityState is Unavailable, it describes where + the health impacting event was originated. Known values are: "Unplanned", "Planned", and + "UserInitiated". + :paramtype reason_type: str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.ReasonTypeValues + :keyword occurred_time: Timestamp for when last change in health status occurred. + :paramtype occurred_time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.availability_state = availability_state + self.title = title + self.summary = summary + self.reason_type = reason_type + self.occurred_time = occurred_time + + +class ImpactedServiceRegion(_serialization.Model): + """Azure region impacted by the service health event. + + :ivar impacted_region: Impacted region name. + :vartype impacted_region: str + :ivar status: Current status of event in the region. Known values are: "Active" and "Resolved". + :vartype status: str or ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventStatusValues + :ivar impacted_subscriptions: List subscription impacted by the service health event. + :vartype impacted_subscriptions: list[str] + :ivar impacted_tenants: List tenant impacted by the service health event. + :vartype impacted_tenants: list[str] + :ivar last_update_time: It provides the Timestamp for when the last update for the service + health event. + :vartype last_update_time: ~datetime.datetime + :ivar updates: List of updates for given service health event. + :vartype updates: list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Update] + """ + + _attribute_map = { + "impacted_region": {"key": "impactedRegion", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "impacted_subscriptions": {"key": "impactedSubscriptions", "type": "[str]"}, + "impacted_tenants": {"key": "impactedTenants", "type": "[str]"}, + "last_update_time": {"key": "lastUpdateTime", "type": "iso-8601"}, + "updates": {"key": "updates", "type": "[Update]"}, + } + + def __init__( + self, + *, + impacted_region: Optional[str] = None, + status: Optional[Union[str, "_models.EventStatusValues"]] = None, + impacted_subscriptions: Optional[List[str]] = None, + impacted_tenants: Optional[List[str]] = None, + last_update_time: Optional[datetime.datetime] = None, + updates: Optional[List["_models.Update"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword impacted_region: Impacted region name. + :paramtype impacted_region: str + :keyword status: Current status of event in the region. Known values are: "Active" and + "Resolved". + :paramtype status: str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventStatusValues + :keyword impacted_subscriptions: List subscription impacted by the service health event. + :paramtype impacted_subscriptions: list[str] + :keyword impacted_tenants: List tenant impacted by the service health event. + :paramtype impacted_tenants: list[str] + :keyword last_update_time: It provides the Timestamp for when the last update for the service + health event. + :paramtype last_update_time: ~datetime.datetime + :keyword updates: List of updates for given service health event. + :paramtype updates: list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Update] + """ + super().__init__(**kwargs) + self.impacted_region = impacted_region + self.status = status + self.impacted_subscriptions = impacted_subscriptions + self.impacted_tenants = impacted_tenants + self.last_update_time = last_update_time + self.updates = updates + + +class KeyValueItem(_serialization.Model): + """Key value tuple. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar key: Key of tuple. + :vartype key: str + :ivar value: Value of tuple. + :vartype value: str + """ + + _validation = { + "key": {"readonly": True}, + "value": {"readonly": True}, + } + + _attribute_map = { + "key": {"key": "key", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.key = None + self.value = None + + +class Link(_serialization.Model): + """Useful links for service health event. + + :ivar type: Type of link. Known values are: "Button" and "Hyperlink". + :vartype type: str or ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.LinkTypeValues + :ivar display_text: Display text of link. + :vartype display_text: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.LinkDisplayText + :ivar extension_name: It provides the name of portal extension to produce link for given + service health event. + :vartype extension_name: str + :ivar blade_name: It provides the name of portal extension blade to produce link for given + service health event. + :vartype blade_name: str + :ivar parameters: It provides a map of parameter name and value for portal extension blade to + produce lik for given service health event. + :vartype parameters: JSON + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "display_text": {"key": "displayText", "type": "LinkDisplayText"}, + "extension_name": {"key": "extensionName", "type": "str"}, + "blade_name": {"key": "bladeName", "type": "str"}, + "parameters": {"key": "parameters", "type": "object"}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.LinkTypeValues"]] = None, + display_text: Optional["_models.LinkDisplayText"] = None, + extension_name: Optional[str] = None, + blade_name: Optional[str] = None, + parameters: Optional[JSON] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: Type of link. Known values are: "Button" and "Hyperlink". + :paramtype type: str or ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.LinkTypeValues + :keyword display_text: Display text of link. + :paramtype display_text: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.LinkDisplayText + :keyword extension_name: It provides the name of portal extension to produce link for given + service health event. + :paramtype extension_name: str + :keyword blade_name: It provides the name of portal extension blade to produce link for given + service health event. + :paramtype blade_name: str + :keyword parameters: It provides a map of parameter name and value for portal extension blade + to produce lik for given service health event. + :paramtype parameters: JSON + """ + super().__init__(**kwargs) + self.type = type + self.display_text = display_text + self.extension_name = extension_name + self.blade_name = blade_name + self.parameters = parameters + + +class LinkDisplayText(_serialization.Model): + """Display text of link. + + :ivar value: Display text of link. + :vartype value: str + :ivar localized_value: Localized display text of link. + :vartype localized_value: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, + } + + def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: Display text of link. + :paramtype value: str + :keyword localized_value: Localized display text of link. + :paramtype localized_value: str + """ + super().__init__(**kwargs) + self.value = value + self.localized_value = localized_value + + +class MetadataEntity(ProxyResource): + """The metadata entity contract. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.SystemData + :ivar display_name: The display name. + :vartype display_name: str + :ivar depends_on: The list of keys on which this entity depends on. + :vartype depends_on: list[str] + :ivar applicable_scenarios: The list of scenarios applicable to this metadata entity. + :vartype applicable_scenarios: list[str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Scenario] + :ivar supported_values: The list of supported values. + :vartype supported_values: + list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.MetadataSupportedValueDetail] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "depends_on": {"key": "properties.dependsOn", "type": "[str]"}, + "applicable_scenarios": {"key": "properties.applicableScenarios", "type": "[str]"}, + "supported_values": {"key": "properties.supportedValues", "type": "[MetadataSupportedValueDetail]"}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + depends_on: Optional[List[str]] = None, + applicable_scenarios: Optional[List[Union[str, "_models.Scenario"]]] = None, + supported_values: Optional[List["_models.MetadataSupportedValueDetail"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword display_name: The display name. + :paramtype display_name: str + :keyword depends_on: The list of keys on which this entity depends on. + :paramtype depends_on: list[str] + :keyword applicable_scenarios: The list of scenarios applicable to this metadata entity. + :paramtype applicable_scenarios: list[str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Scenario] + :keyword supported_values: The list of supported values. + :paramtype supported_values: + list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.MetadataSupportedValueDetail] + """ + super().__init__(**kwargs) + self.display_name = display_name + self.depends_on = depends_on + self.applicable_scenarios = applicable_scenarios + self.supported_values = supported_values + + +class MetadataEntityListResult(_serialization.Model): + """The list of metadata entities. + + :ivar value: The list of metadata entities. + :vartype value: list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.MetadataEntity] + :ivar next_link: The link used to get the next page of metadata. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[MetadataEntity]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.MetadataEntity"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The list of metadata entities. + :paramtype value: list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.MetadataEntity] + :keyword next_link: The link used to get the next page of metadata. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class MetadataSupportedValueDetail(_serialization.Model): + """The metadata supported value detail. + + :ivar id: The id. + :vartype id: str + :ivar display_name: The display name. + :vartype display_name: str + :ivar resource_types: The list of associated resource types. + :vartype resource_types: list[str] + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "resource_types": {"key": "resourceTypes", "type": "[str]"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + display_name: Optional[str] = None, + resource_types: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The id. + :paramtype id: str + :keyword display_name: The display name. + :paramtype display_name: str + :keyword resource_types: The list of associated resource types. + :paramtype resource_types: list[str] + """ + super().__init__(**kwargs) + self.id = id + self.display_name = display_name + self.resource_types = resource_types + + +class Operation(_serialization.Model): + """Operation available in the Microsoft.ResourceHealth resource provider. + + :ivar name: Name of the operation. + :vartype name: str + :ivar display: Properties of the operation. + :vartype display: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.OperationDisplay + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + } + + def __init__( + self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any + ) -> None: + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword display: Properties of the operation. + :paramtype display: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.OperationDisplay + """ + super().__init__(**kwargs) + self.name = name + self.display = display + + +class OperationDisplay(_serialization.Model): + """Properties of the operation. + + :ivar provider: Provider name. + :vartype provider: str + :ivar resource: Resource name. + :vartype resource: str + :ivar operation: Operation name. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str + """ + + _attribute_map = { + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword provider: Provider name. + :paramtype provider: str + :keyword resource: Resource name. + :paramtype resource: str + :keyword operation: Operation name. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ + super().__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class OperationListResult(_serialization.Model): + """Lists the operations response. + + All required parameters must be populated in order to send to Azure. + + :ivar value: List of operations available in the Microsoft.ResourceHealth resource provider. + Required. + :vartype value: list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Operation] + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Operation]"}, + } + + def __init__(self, *, value: List["_models.Operation"], **kwargs: Any) -> None: + """ + :keyword value: List of operations available in the Microsoft.ResourceHealth resource provider. + Required. + :paramtype value: list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Operation] + """ + super().__init__(**kwargs) + self.value = value + + +class RecommendedAction(_serialization.Model): + """Lists actions the user can take based on the current availabilityState of the resource. + + :ivar action: Recommended action. + :vartype action: str + :ivar action_url: Link to the action. + :vartype action_url: str + :ivar action_url_comment: the comment for the Action. + :vartype action_url_comment: str + :ivar action_url_text: Substring of action, it describes which text should host the action URL. + :vartype action_url_text: str + """ + + _attribute_map = { + "action": {"key": "action", "type": "str"}, + "action_url": {"key": "actionUrl", "type": "str"}, + "action_url_comment": {"key": "_ActionUrl\\.Comment", "type": "str"}, + "action_url_text": {"key": "actionUrlText", "type": "str"}, + } + + def __init__( + self, + *, + action: Optional[str] = None, + action_url: Optional[str] = None, + action_url_comment: Optional[str] = None, + action_url_text: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword action: Recommended action. + :paramtype action: str + :keyword action_url: Link to the action. + :paramtype action_url: str + :keyword action_url_comment: the comment for the Action. + :paramtype action_url_comment: str + :keyword action_url_text: Substring of action, it describes which text should host the action + URL. + :paramtype action_url_text: str + """ + super().__init__(**kwargs) + self.action = action + self.action_url = action_url + self.action_url_comment = action_url_comment + self.action_url_text = action_url_text + + +class ServiceImpactingEvent(_serialization.Model): + """Lists the service impacting events that may be affecting the health of the resource. + + :ivar event_start_time: Timestamp for when the event started. + :vartype event_start_time: ~datetime.datetime + :ivar event_status_last_modified_time: Timestamp for when event was submitted/detected. + :vartype event_status_last_modified_time: ~datetime.datetime + :ivar correlation_id: Correlation id for the event. + :vartype correlation_id: str + :ivar status: Status of the service impacting event. + :vartype status: + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.ServiceImpactingEventStatus + :ivar incident_properties: Properties of the service impacting event. + :vartype incident_properties: + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.ServiceImpactingEventIncidentProperties + """ + + _attribute_map = { + "event_start_time": {"key": "eventStartTime", "type": "iso-8601"}, + "event_status_last_modified_time": {"key": "eventStatusLastModifiedTime", "type": "iso-8601"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "status": {"key": "status", "type": "ServiceImpactingEventStatus"}, + "incident_properties": {"key": "incidentProperties", "type": "ServiceImpactingEventIncidentProperties"}, + } + + def __init__( + self, + *, + event_start_time: Optional[datetime.datetime] = None, + event_status_last_modified_time: Optional[datetime.datetime] = None, + correlation_id: Optional[str] = None, + status: Optional["_models.ServiceImpactingEventStatus"] = None, + incident_properties: Optional["_models.ServiceImpactingEventIncidentProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword event_start_time: Timestamp for when the event started. + :paramtype event_start_time: ~datetime.datetime + :keyword event_status_last_modified_time: Timestamp for when event was submitted/detected. + :paramtype event_status_last_modified_time: ~datetime.datetime + :keyword correlation_id: Correlation id for the event. + :paramtype correlation_id: str + :keyword status: Status of the service impacting event. + :paramtype status: + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.ServiceImpactingEventStatus + :keyword incident_properties: Properties of the service impacting event. + :paramtype incident_properties: + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.ServiceImpactingEventIncidentProperties + """ + super().__init__(**kwargs) + self.event_start_time = event_start_time + self.event_status_last_modified_time = event_status_last_modified_time + self.correlation_id = correlation_id + self.status = status + self.incident_properties = incident_properties + + +class ServiceImpactingEventIncidentProperties(_serialization.Model): + """Properties of the service impacting event. + + :ivar title: Title of the incident. + :vartype title: str + :ivar service: Service impacted by the event. + :vartype service: str + :ivar region: Region impacted by the event. + :vartype region: str + :ivar incident_type: Type of Event. + :vartype incident_type: str + """ + + _attribute_map = { + "title": {"key": "title", "type": "str"}, + "service": {"key": "service", "type": "str"}, + "region": {"key": "region", "type": "str"}, + "incident_type": {"key": "incidentType", "type": "str"}, + } + + def __init__( + self, + *, + title: Optional[str] = None, + service: Optional[str] = None, + region: Optional[str] = None, + incident_type: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword title: Title of the incident. + :paramtype title: str + :keyword service: Service impacted by the event. + :paramtype service: str + :keyword region: Region impacted by the event. + :paramtype region: str + :keyword incident_type: Type of Event. + :paramtype incident_type: str + """ + super().__init__(**kwargs) + self.title = title + self.service = service + self.region = region + self.incident_type = incident_type + + +class ServiceImpactingEventStatus(_serialization.Model): + """Status of the service impacting event. + + :ivar value: Current status of the event. + :vartype value: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "str"}, + } + + def __init__(self, *, value: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: Current status of the event. + :paramtype value: str + """ + super().__init__(**kwargs) + self.value = value + + +class StatusActiveEvent(_serialization.Model): + """Active event type of emerging issue. + + :ivar title: The active event title. + :vartype title: str + :ivar description: The details of active event. + :vartype description: str + :ivar tracking_id: The tracking id of this active event. + :vartype tracking_id: str + :ivar start_time: The impact start time on this active event. + :vartype start_time: ~datetime.datetime + :ivar cloud: The cloud type of this active event. + :vartype cloud: str + :ivar severity: The severity level of this active event. Known values are: "Information", + "Warning", and "Error". + :vartype severity: str or ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.SeverityValues + :ivar stage: The stage of this active event. Known values are: "Active", "Resolve", and + "Archived". + :vartype stage: str or ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.StageValues + :ivar published: The boolean value of this active event if published or not. + :vartype published: bool + :ivar last_modified_time: The last time modified on this banner. + :vartype last_modified_time: ~datetime.datetime + :ivar impacts: The list of emerging issues impacts. + :vartype impacts: + list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EmergingIssueImpact] + """ + + _attribute_map = { + "title": {"key": "title", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "tracking_id": {"key": "trackingId", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "cloud": {"key": "cloud", "type": "str"}, + "severity": {"key": "severity", "type": "str"}, + "stage": {"key": "stage", "type": "str"}, + "published": {"key": "published", "type": "bool"}, + "last_modified_time": {"key": "lastModifiedTime", "type": "iso-8601"}, + "impacts": {"key": "impacts", "type": "[EmergingIssueImpact]"}, + } + + def __init__( + self, + *, + title: Optional[str] = None, + description: Optional[str] = None, + tracking_id: Optional[str] = None, + start_time: Optional[datetime.datetime] = None, + cloud: Optional[str] = None, + severity: Optional[Union[str, "_models.SeverityValues"]] = None, + stage: Optional[Union[str, "_models.StageValues"]] = None, + published: Optional[bool] = None, + last_modified_time: Optional[datetime.datetime] = None, + impacts: Optional[List["_models.EmergingIssueImpact"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword title: The active event title. + :paramtype title: str + :keyword description: The details of active event. + :paramtype description: str + :keyword tracking_id: The tracking id of this active event. + :paramtype tracking_id: str + :keyword start_time: The impact start time on this active event. + :paramtype start_time: ~datetime.datetime + :keyword cloud: The cloud type of this active event. + :paramtype cloud: str + :keyword severity: The severity level of this active event. Known values are: "Information", + "Warning", and "Error". + :paramtype severity: str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.SeverityValues + :keyword stage: The stage of this active event. Known values are: "Active", "Resolve", and + "Archived". + :paramtype stage: str or ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.StageValues + :keyword published: The boolean value of this active event if published or not. + :paramtype published: bool + :keyword last_modified_time: The last time modified on this banner. + :paramtype last_modified_time: ~datetime.datetime + :keyword impacts: The list of emerging issues impacts. + :paramtype impacts: + list[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EmergingIssueImpact] + """ + super().__init__(**kwargs) + self.title = title + self.description = description + self.tracking_id = tracking_id + self.start_time = start_time + self.cloud = cloud + self.severity = severity + self.stage = stage + self.published = published + self.last_modified_time = last_modified_time + self.impacts = impacts + + +class StatusBanner(_serialization.Model): + """Banner type of emerging issue. + + :ivar title: The banner title. + :vartype title: str + :ivar message: The details of banner. + :vartype message: str + :ivar cloud: The cloud type of this banner. + :vartype cloud: str + :ivar last_modified_time: The last time modified on this banner. + :vartype last_modified_time: ~datetime.datetime + """ + + _attribute_map = { + "title": {"key": "title", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "cloud": {"key": "cloud", "type": "str"}, + "last_modified_time": {"key": "lastModifiedTime", "type": "iso-8601"}, + } + + def __init__( + self, + *, + title: Optional[str] = None, + message: Optional[str] = None, + cloud: Optional[str] = None, + last_modified_time: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword title: The banner title. + :paramtype title: str + :keyword message: The details of banner. + :paramtype message: str + :keyword cloud: The cloud type of this banner. + :paramtype cloud: str + :keyword last_modified_time: The last time modified on this banner. + :paramtype last_modified_time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.title = title + self.message = message + self.cloud = cloud + self.last_modified_time = last_modified_time + + +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class Update(_serialization.Model): + """Update for service health event. + + :ivar summary: Summary text for the given update for the service health event. + :vartype summary: str + :ivar update_date_time: It provides the Timestamp for the given update for the service health + event. + :vartype update_date_time: ~datetime.datetime + """ + + _attribute_map = { + "summary": {"key": "summary", "type": "str"}, + "update_date_time": {"key": "updateDateTime", "type": "iso-8601"}, + } + + def __init__( + self, *, summary: Optional[str] = None, update_date_time: Optional[datetime.datetime] = None, **kwargs: Any + ) -> None: + """ + :keyword summary: Summary text for the given update for the service health event. + :paramtype summary: str + :keyword update_date_time: It provides the Timestamp for the given update for the service + health event. + :paramtype update_date_time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.summary = summary + self.update_date_time = update_date_time diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/models/_patch.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/models/_resource_health_mgmt_client_enums.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/models/_resource_health_mgmt_client_enums.py new file mode 100644 index 000000000000..4891064e086c --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/models/_resource_health_mgmt_client_enums.py @@ -0,0 +1,129 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AvailabilityStateValues(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Impacted resource status of the resource.""" + + AVAILABLE = "Available" + UNAVAILABLE = "Unavailable" + DEGRADED = "Degraded" + UNKNOWN = "Unknown" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class EventLevelValues(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Level of event.""" + + CRITICAL = "Critical" + ERROR = "Error" + WARNING = "Warning" + INFORMATIONAL = "Informational" + + +class EventSourceValues(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Source of event.""" + + RESOURCE_HEALTH = "ResourceHealth" + SERVICE_HEALTH = "ServiceHealth" + + +class EventStatusValues(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current status of event.""" + + ACTIVE = "Active" + RESOLVED = "Resolved" + + +class EventSubTypeValues(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Sub type of the event. Currently used to determine retirement communications for health + advisory events. + """ + + RETIREMENT = "Retirement" + + +class EventTypeValues(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of event.""" + + SERVICE_ISSUE = "ServiceIssue" + PLANNED_MAINTENANCE = "PlannedMaintenance" + HEALTH_ADVISORY = "HealthAdvisory" + RCA = "RCA" + EMERGING_ISSUES = "EmergingIssues" + SECURITY_ADVISORY = "SecurityAdvisory" + + +class IssueNameParameter(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """IssueNameParameter.""" + + DEFAULT = "default" + + +class LevelValues(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Level of insight.""" + + CRITICAL = "Critical" + WARNING = "Warning" + + +class LinkTypeValues(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of link.""" + + BUTTON = "Button" + HYPERLINK = "Hyperlink" + + +class ReasonChronicityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Chronicity of the availability transition.""" + + TRANSIENT = "Transient" + PERSISTENT = "Persistent" + + +class ReasonTypeValues(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """When the resource's availabilityState is Unavailable, it describes where the health impacting + event was originated. + """ + + UNPLANNED = "Unplanned" + PLANNED = "Planned" + USER_INITIATED = "UserInitiated" + + +class Scenario(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Scenario.""" + + ALERTS = "Alerts" + + +class SeverityValues(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The severity level of this active event.""" + + INFORMATION = "Information" + WARNING = "Warning" + ERROR = "Error" + + +class StageValues(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The stage of this active event.""" + + ACTIVE = "Active" + RESOLVE = "Resolve" + ARCHIVED = "Archived" diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/__init__.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/__init__.py new file mode 100644 index 000000000000..5ef1b5084a40 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/__init__.py @@ -0,0 +1,37 @@ +# 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 ._availability_statuses_operations import AvailabilityStatusesOperations +from ._operations import Operations +from ._metadata_operations import MetadataOperations +from ._impacted_resources_operations import ImpactedResourcesOperations +from ._security_advisory_impacted_resources_operations import SecurityAdvisoryImpactedResourcesOperations +from ._events_operations import EventsOperations +from ._event_operations import EventOperations +from ._child_availability_statuses_operations import ChildAvailabilityStatusesOperations +from ._child_resources_operations import ChildResourcesOperations +from ._emerging_issues_operations import EmergingIssuesOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AvailabilityStatusesOperations", + "Operations", + "MetadataOperations", + "ImpactedResourcesOperations", + "SecurityAdvisoryImpactedResourcesOperations", + "EventsOperations", + "EventOperations", + "ChildAvailabilityStatusesOperations", + "ChildResourcesOperations", + "EmergingIssuesOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_availability_statuses_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_availability_statuses_operations.py new file mode 100644 index 000000000000..e509f0ce621e --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_availability_statuses_operations.py @@ -0,0 +1,564 @@ +# 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, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_subscription_id_request( + subscription_id: str, *, filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/availabilityStatuses" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ResourceHealth/availabilityStatuses", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_by_resource_request( + resource_uri: str, *, filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.ResourceHealth/availabilityStatuses/current") + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_uri: str, *, filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.ResourceHealth/availabilityStatuses") + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class AvailabilityStatusesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resourcehealth.v2023_10_01_preview.ResourceHealthMgmtClient`'s + :attr:`availability_statuses` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_subscription_id( + self, filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.AvailabilityStatus"]: + """Lists the current availability status for all the resources in the subscription. + + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :param expand: Setting $expand=recommendedactions in url query expands the recommendedactions + in the response. Default value is None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AvailabilityStatus or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.AvailabilityStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + filter=filter, + expand=expand, + api_version=api_version, + template_url=self.list_by_subscription_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AvailabilityStatusListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/availabilityStatuses" + } + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.AvailabilityStatus"]: + """Lists the current availability status for all the resources in the resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :param expand: Setting $expand=recommendedactions in url query expands the recommendedactions + in the response. Default value is None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AvailabilityStatus or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.AvailabilityStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + expand=expand, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AvailabilityStatusListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ResourceHealth/availabilityStatuses" + } + + @distributed_trace + def get_by_resource( + self, resource_uri: str, filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any + ) -> _models.AvailabilityStatus: + """Gets current availability status for a single resource. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Currently the API support not nested and one nesting level resource types : + /subscriptions/{subscriptionId}/resourceGroups/{resource-group-name}/providers/{resource-provider-name}/{resource-type}/{resource-name} + and + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resource-provider-name}/{parentResourceType}/{parentResourceName}/{resourceType}/{resourceName}. + Required. + :type resource_uri: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :param expand: Setting $expand=recommendedactions in url query expands the recommendedactions + in the response. Default value is None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AvailabilityStatus or the result of cls(response) + :rtype: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.AvailabilityStatus + :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._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.AvailabilityStatus] = kwargs.pop("cls", None) + + request = build_get_by_resource_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + api_version=api_version, + template_url=self.get_by_resource.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AvailabilityStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.ResourceHealth/availabilityStatuses/current"} + + @distributed_trace + def list( + self, resource_uri: str, filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.AvailabilityStatus"]: + """Lists all historical availability transitions and impacting events for a single resource. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Currently the API support not nested and one nesting level resource types : + /subscriptions/{subscriptionId}/resourceGroups/{resource-group-name}/providers/{resource-provider-name}/{resource-type}/{resource-name} + and + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resource-provider-name}/{parentResourceType}/{parentResourceName}/{resourceType}/{resourceName}. + Required. + :type resource_uri: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :param expand: Setting $expand=recommendedactions in url query expands the recommendedactions + in the response. Default value is None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AvailabilityStatus or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.AvailabilityStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AvailabilityStatusListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.ResourceHealth/availabilityStatuses"} diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_child_availability_statuses_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_child_availability_statuses_operations.py new file mode 100644 index 000000000000..ed883d83274b --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_child_availability_statuses_operations.py @@ -0,0 +1,294 @@ +# 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, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_by_resource_request( + resource_uri: str, *, filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/{resourceUri}/providers/Microsoft.ResourceHealth/childAvailabilityStatuses/current" + ) + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_uri: str, *, filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.ResourceHealth/childAvailabilityStatuses") + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ChildAvailabilityStatusesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resourcehealth.v2023_10_01_preview.ResourceHealthMgmtClient`'s + :attr:`child_availability_statuses` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def get_by_resource( + self, resource_uri: str, filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any + ) -> _models.AvailabilityStatus: + """Gets current availability status for a single resource. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Currently the API only support one nesting level resource types : + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resource-provider-name}/{parentResourceType}/{parentResourceName}/{resourceType}/{resourceName}. + Required. + :type resource_uri: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :param expand: Setting $expand=recommendedactions in url query expands the recommendedactions + in the response. Default value is None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AvailabilityStatus or the result of cls(response) + :rtype: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.AvailabilityStatus + :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._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.AvailabilityStatus] = kwargs.pop("cls", None) + + request = build_get_by_resource_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + api_version=api_version, + template_url=self.get_by_resource.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AvailabilityStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_resource.metadata = { + "url": "/{resourceUri}/providers/Microsoft.ResourceHealth/childAvailabilityStatuses/current" + } + + @distributed_trace + def list( + self, resource_uri: str, filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.AvailabilityStatus"]: + """Lists the historical availability statuses for a single child resource. Use the nextLink + property in the response to get the next page of availability status. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Currently the API only support one nesting level resource types : + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resource-provider-name}/{parentResourceType}/{parentResourceName}/{resourceType}/{resourceName}. + Required. + :type resource_uri: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :param expand: Setting $expand=recommendedactions in url query expands the recommendedactions + in the response. Default value is None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AvailabilityStatus or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.AvailabilityStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AvailabilityStatusListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.ResourceHealth/childAvailabilityStatuses"} diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_child_resources_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_child_resources_operations.py new file mode 100644 index 000000000000..59fb9487d752 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_child_resources_operations.py @@ -0,0 +1,188 @@ +# 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, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_uri: str, *, filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.ResourceHealth/childResources") + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ChildResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resourcehealth.v2023_10_01_preview.ResourceHealthMgmtClient`'s + :attr:`child_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, resource_uri: str, filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.AvailabilityStatus"]: + """Lists the all the children and its current health status for a parent resource. Use the + nextLink property in the response to get the next page of children current health. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Currently the API only support not nested parent resource type: + /subscriptions/{subscriptionId}/resourceGroups/{resource-group-name}/providers/{resource-provider-name}/{resource-type}/{resource-name}. + Required. + :type resource_uri: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :param expand: Setting $expand=recommendedactions in url query expands the recommendedactions + in the response. Default value is None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AvailabilityStatus or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.AvailabilityStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.AvailabilityStatusListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AvailabilityStatusListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.ResourceHealth/childResources"} diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_emerging_issues_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_emerging_issues_operations.py new file mode 100644 index 000000000000..486a2fe14c8a --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_emerging_issues_operations.py @@ -0,0 +1,243 @@ +# 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, Iterable, Optional, TypeVar, Union +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ResourceHealth/emergingIssues") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(issue_name: Union[str, _models.IssueNameParameter], **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ResourceHealth/emergingIssues/{issueName}") + path_format_arguments = { + "issueName": _SERIALIZER.url("issue_name", issue_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class EmergingIssuesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resourcehealth.v2023_10_01_preview.ResourceHealthMgmtClient`'s + :attr:`emerging_issues` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.EmergingIssuesGetResult"]: + """Lists Azure services' emerging issues. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EmergingIssuesGetResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EmergingIssuesGetResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.EmergingIssueListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("EmergingIssueListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.ResourceHealth/emergingIssues"} + + @distributed_trace + def get(self, issue_name: Union[str, _models.IssueNameParameter], **kwargs: Any) -> _models.EmergingIssuesGetResult: + """Gets Azure services' emerging issues. + + :param issue_name: The name of the emerging issue. "default" Required. + :type issue_name: str or + ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.IssueNameParameter + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EmergingIssuesGetResult or the result of cls(response) + :rtype: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EmergingIssuesGetResult + :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._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.EmergingIssuesGetResult] = kwargs.pop("cls", None) + + request = build_get_request( + issue_name=issue_name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EmergingIssuesGetResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/providers/Microsoft.ResourceHealth/emergingIssues/{issueName}"} diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_event_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_event_operations.py new file mode 100644 index 000000000000..39285c29f6c2 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_event_operations.py @@ -0,0 +1,451 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_by_subscription_id_and_tracking_id_request( + event_tracking_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + query_start_time: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/events/{eventTrackingId}" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "eventTrackingId": _SERIALIZER.url("event_tracking_id", event_tracking_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if query_start_time is not None: + _params["queryStartTime"] = _SERIALIZER.query("query_start_time", query_start_time, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_fetch_details_by_subscription_id_and_tracking_id_request( + event_tracking_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/fetchEventDetails", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "eventTrackingId": _SERIALIZER.url("event_tracking_id", event_tracking_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_by_tenant_id_and_tracking_id_request( + event_tracking_id: str, *, filter: Optional[str] = None, query_start_time: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ResourceHealth/events/{eventTrackingId}") + path_format_arguments = { + "eventTrackingId": _SERIALIZER.url("event_tracking_id", event_tracking_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if query_start_time is not None: + _params["queryStartTime"] = _SERIALIZER.query("query_start_time", query_start_time, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_fetch_details_by_tenant_id_and_tracking_id_request(event_tracking_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/fetchEventDetails") + path_format_arguments = { + "eventTrackingId": _SERIALIZER.url("event_tracking_id", event_tracking_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class EventOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resourcehealth.v2023_10_01_preview.ResourceHealthMgmtClient`'s + :attr:`event` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def get_by_subscription_id_and_tracking_id( + self, + event_tracking_id: str, + filter: Optional[str] = None, + query_start_time: Optional[str] = None, + **kwargs: Any + ) -> _models.Event: + """Service health event in the subscription by event tracking id. + + :param event_tracking_id: Event Id which uniquely identifies ServiceHealth event. Required. + :type event_tracking_id: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :param query_start_time: Specifies from when to return events, based on the lastUpdateTime + property. For example, queryStartTime = 7/24/2020 OR queryStartTime=7%2F24%2F2020. Default + value is None. + :type query_start_time: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Event or the result of cls(response) + :rtype: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Event + :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._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.Event] = kwargs.pop("cls", None) + + request = build_get_by_subscription_id_and_tracking_id_request( + event_tracking_id=event_tracking_id, + subscription_id=self._config.subscription_id, + filter=filter, + query_start_time=query_start_time, + api_version=api_version, + template_url=self.get_by_subscription_id_and_tracking_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Event", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_subscription_id_and_tracking_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/events/{eventTrackingId}" + } + + @distributed_trace + def fetch_details_by_subscription_id_and_tracking_id(self, event_tracking_id: str, **kwargs: Any) -> _models.Event: + """Service health event details in the subscription by event tracking id. This can be used to + fetch sensitive properties for Security Advisory events. + + :param event_tracking_id: Event Id which uniquely identifies ServiceHealth event. Required. + :type event_tracking_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Event or the result of cls(response) + :rtype: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Event + :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._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.Event] = kwargs.pop("cls", None) + + request = build_fetch_details_by_subscription_id_and_tracking_id_request( + event_tracking_id=event_tracking_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.fetch_details_by_subscription_id_and_tracking_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Event", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + fetch_details_by_subscription_id_and_tracking_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/fetchEventDetails" + } + + @distributed_trace + def get_by_tenant_id_and_tracking_id( + self, + event_tracking_id: str, + filter: Optional[str] = None, + query_start_time: Optional[str] = None, + **kwargs: Any + ) -> _models.Event: + """Service health event in the tenant by event tracking id. + + :param event_tracking_id: Event Id which uniquely identifies ServiceHealth event. Required. + :type event_tracking_id: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :param query_start_time: Specifies from when to return events, based on the lastUpdateTime + property. For example, queryStartTime = 7/24/2020 OR queryStartTime=7%2F24%2F2020. Default + value is None. + :type query_start_time: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Event or the result of cls(response) + :rtype: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Event + :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._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.Event] = kwargs.pop("cls", None) + + request = build_get_by_tenant_id_and_tracking_id_request( + event_tracking_id=event_tracking_id, + filter=filter, + query_start_time=query_start_time, + api_version=api_version, + template_url=self.get_by_tenant_id_and_tracking_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Event", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_tenant_id_and_tracking_id.metadata = {"url": "/providers/Microsoft.ResourceHealth/events/{eventTrackingId}"} + + @distributed_trace + def fetch_details_by_tenant_id_and_tracking_id(self, event_tracking_id: str, **kwargs: Any) -> _models.Event: + """Service health event details in the tenant by event tracking id. This can be used to fetch + sensitive properties for Security Advisory events. + + :param event_tracking_id: Event Id which uniquely identifies ServiceHealth event. Required. + :type event_tracking_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Event or the result of cls(response) + :rtype: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Event + :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._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.Event] = kwargs.pop("cls", None) + + request = build_fetch_details_by_tenant_id_and_tracking_id_request( + event_tracking_id=event_tracking_id, + api_version=api_version, + template_url=self.fetch_details_by_tenant_id_and_tracking_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Event", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + fetch_details_by_tenant_id_and_tracking_id.metadata = { + "url": "/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/fetchEventDetails" + } diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_events_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_events_operations.py new file mode 100644 index 000000000000..a9a954bb06ca --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_events_operations.py @@ -0,0 +1,431 @@ +# 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, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_subscription_id_request( + subscription_id: str, *, filter: Optional[str] = None, query_start_time: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/events") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if query_start_time is not None: + _params["queryStartTime"] = _SERIALIZER.query("query_start_time", query_start_time, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_tenant_id_request( + *, filter: Optional[str] = None, query_start_time: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ResourceHealth/events") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if query_start_time is not None: + _params["queryStartTime"] = _SERIALIZER.query("query_start_time", query_start_time, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_single_resource_request( + resource_uri: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.ResourceHealth/events") + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class EventsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resourcehealth.v2023_10_01_preview.ResourceHealthMgmtClient`'s + :attr:`events` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_subscription_id( + self, filter: Optional[str] = None, query_start_time: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Event"]: + """Lists service health events in the subscription. + + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :param query_start_time: Specifies from when to return events, based on the lastUpdateTime + property. For example, queryStartTime = 7/24/2020 OR queryStartTime=7%2F24%2F2020. Default + value is None. + :type query_start_time: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Event or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.Events] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + filter=filter, + query_start_time=query_start_time, + api_version=api_version, + template_url=self.list_by_subscription_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("Events", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/events" + } + + @distributed_trace + def list_by_tenant_id( + self, filter: Optional[str] = None, query_start_time: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Event"]: + """Lists current service health events in the tenant. + + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :param query_start_time: Specifies from when to return events, based on the lastUpdateTime + property. For example, queryStartTime = 7/24/2020 OR queryStartTime=7%2F24%2F2020. Default + value is None. + :type query_start_time: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Event or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.Events] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_tenant_id_request( + filter=filter, + query_start_time=query_start_time, + api_version=api_version, + template_url=self.list_by_tenant_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("Events", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_tenant_id.metadata = {"url": "/providers/Microsoft.ResourceHealth/events"} + + @distributed_trace + def list_by_single_resource( + self, resource_uri: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Event"]: + """Lists current service health events for given resource. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Currently the API support not nested and one nesting level resource types : + /subscriptions/{subscriptionId}/resourceGroups/{resource-group-name}/providers/{resource-provider-name}/{resource-type}/{resource-name} + and + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resource-provider-name}/{parentResourceType}/{parentResourceName}/{resourceType}/{resourceName}. + Required. + :type resource_uri: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Event or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.Event] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.Events] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_single_resource_request( + resource_uri=resource_uri, + filter=filter, + api_version=api_version, + template_url=self.list_by_single_resource.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("Events", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_single_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.ResourceHealth/events"} diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_impacted_resources_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_impacted_resources_operations.py new file mode 100644 index 000000000000..3fd88c4ac157 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_impacted_resources_operations.py @@ -0,0 +1,502 @@ +# 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, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_subscription_id_and_event_id_request( + event_tracking_id: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/impactedResources", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "eventTrackingId": _SERIALIZER.url("event_tracking_id", event_tracking_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + event_tracking_id: str, impacted_resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/impactedResources/{impactedResourceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "eventTrackingId": _SERIALIZER.url("event_tracking_id", event_tracking_id, "str"), + "impactedResourceName": _SERIALIZER.url( + "impacted_resource_name", impacted_resource_name, "str", pattern=r"^[^*#&+:<>%?]+$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_tenant_id_and_event_id_request( + event_tracking_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/impactedResources") + path_format_arguments = { + "eventTrackingId": _SERIALIZER.url("event_tracking_id", event_tracking_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_by_tenant_id_request(event_tracking_id: str, impacted_resource_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/impactedResources/{impactedResourceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "eventTrackingId": _SERIALIZER.url("event_tracking_id", event_tracking_id, "str"), + "impactedResourceName": _SERIALIZER.url( + "impacted_resource_name", impacted_resource_name, "str", pattern=r"^[^*#&+:<>%?]+$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ImpactedResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resourcehealth.v2023_10_01_preview.ResourceHealthMgmtClient`'s + :attr:`impacted_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_subscription_id_and_event_id( + self, event_tracking_id: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.EventImpactedResource"]: + """Lists impacted resources in the subscription by an event. + + :param event_tracking_id: Event Id which uniquely identifies ServiceHealth event. Required. + :type event_tracking_id: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EventImpactedResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventImpactedResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.EventImpactedResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_id_and_event_id_request( + event_tracking_id=event_tracking_id, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_subscription_id_and_event_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("EventImpactedResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_subscription_id_and_event_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/impactedResources" + } + + @distributed_trace + def get(self, event_tracking_id: str, impacted_resource_name: str, **kwargs: Any) -> _models.EventImpactedResource: + """Gets the specific impacted resource in the subscription by an event. + + :param event_tracking_id: Event Id which uniquely identifies ServiceHealth event. Required. + :type event_tracking_id: str + :param impacted_resource_name: Name of the Impacted Resource. Required. + :type impacted_resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventImpactedResource or the result of cls(response) + :rtype: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventImpactedResource + :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._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.EventImpactedResource] = kwargs.pop("cls", None) + + request = build_get_request( + event_tracking_id=event_tracking_id, + impacted_resource_name=impacted_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EventImpactedResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/impactedResources/{impactedResourceName}" + } + + @distributed_trace + def list_by_tenant_id_and_event_id( + self, event_tracking_id: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.EventImpactedResource"]: + """Lists impacted resources in the tenant by an event. + + :param event_tracking_id: Event Id which uniquely identifies ServiceHealth event. Required. + :type event_tracking_id: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EventImpactedResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventImpactedResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.EventImpactedResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_tenant_id_and_event_id_request( + event_tracking_id=event_tracking_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_tenant_id_and_event_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("EventImpactedResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_tenant_id_and_event_id.metadata = { + "url": "/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/impactedResources" + } + + @distributed_trace + def get_by_tenant_id( + self, event_tracking_id: str, impacted_resource_name: str, **kwargs: Any + ) -> _models.EventImpactedResource: + """Gets the specific impacted resource in the tenant by an event. + + :param event_tracking_id: Event Id which uniquely identifies ServiceHealth event. Required. + :type event_tracking_id: str + :param impacted_resource_name: Name of the Impacted Resource. Required. + :type impacted_resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventImpactedResource or the result of cls(response) + :rtype: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventImpactedResource + :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._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.EventImpactedResource] = kwargs.pop("cls", None) + + request = build_get_by_tenant_id_request( + event_tracking_id=event_tracking_id, + impacted_resource_name=impacted_resource_name, + api_version=api_version, + template_url=self.get_by_tenant_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EventImpactedResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_tenant_id.metadata = { + "url": "/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/impactedResources/{impactedResourceName}" + } diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_metadata_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_metadata_operations.py new file mode 100644 index 000000000000..1fea23941f7e --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_metadata_operations.py @@ -0,0 +1,241 @@ +# 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, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ResourceHealth/metadata") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_entity_request(name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ResourceHealth/metadata/{name}") + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class MetadataOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resourcehealth.v2023_10_01_preview.ResourceHealthMgmtClient`'s + :attr:`metadata` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.MetadataEntity"]: + """Gets the list of metadata entities. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MetadataEntity or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.MetadataEntity] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.MetadataEntityListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("MetadataEntityListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.ResourceHealth/metadata"} + + @distributed_trace + def get_entity(self, name: str, **kwargs: Any) -> _models.MetadataEntity: + """Gets the list of metadata entities. + + :param name: Name of metadata entity. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MetadataEntity or the result of cls(response) + :rtype: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.MetadataEntity + :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._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.MetadataEntity] = kwargs.pop("cls", None) + + request = build_get_entity_request( + name=name, + api_version=api_version, + template_url=self.get_entity.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MetadataEntity", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_entity.metadata = {"url": "/providers/Microsoft.ResourceHealth/metadata/{name}"} diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_operations.py new file mode 100644 index 000000000000..f36991c23047 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_operations.py @@ -0,0 +1,129 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ResourceHealth/operations") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resourcehealth.v2023_10_01_preview.ResourceHealthMgmtClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, **kwargs: Any) -> _models.OperationListResult: + """Lists available operations for the resourcehealth resource provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationListResult or the result of cls(response) + :rtype: ~azure.mgmt.resourcehealth.v2023_10_01_preview.models.OperationListResult + :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._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {"url": "/providers/Microsoft.ResourceHealth/operations"} diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_patch.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_security_advisory_impacted_resources_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_security_advisory_impacted_resources_operations.py new file mode 100644 index 000000000000..4ab4534b638f --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/operations/_security_advisory_impacted_resources_operations.py @@ -0,0 +1,313 @@ +# 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, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_subscription_id_and_event_id_request( + event_tracking_id: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/listSecurityAdvisoryImpactedResources", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "eventTrackingId": _SERIALIZER.url("event_tracking_id", event_tracking_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_tenant_id_and_event_id_request( + event_tracking_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/listSecurityAdvisoryImpactedResources", + ) # pylint: disable=line-too-long + path_format_arguments = { + "eventTrackingId": _SERIALIZER.url("event_tracking_id", event_tracking_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class SecurityAdvisoryImpactedResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resourcehealth.v2023_10_01_preview.ResourceHealthMgmtClient`'s + :attr:`security_advisory_impacted_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_subscription_id_and_event_id( + self, event_tracking_id: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.EventImpactedResource"]: + """Lists impacted resources in the subscription by an event (Security Advisory). + + :param event_tracking_id: Event Id which uniquely identifies ServiceHealth event. Required. + :type event_tracking_id: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EventImpactedResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventImpactedResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.EventImpactedResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_id_and_event_id_request( + event_tracking_id=event_tracking_id, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_subscription_id_and_event_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("EventImpactedResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_subscription_id_and_event_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/listSecurityAdvisoryImpactedResources" + } + + @distributed_trace + def list_by_tenant_id_and_event_id( + self, event_tracking_id: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.EventImpactedResource"]: + """Lists impacted resources in the tenant by an event (Security Advisory). + + :param event_tracking_id: Event Id which uniquely identifies ServiceHealth event. Required. + :type event_tracking_id: str + :param filter: The filter to apply on the operation. For more information please see + https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN. Default value + is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EventImpactedResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resourcehealth.v2023_10_01_preview.models.EventImpactedResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.EventImpactedResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_tenant_id_and_event_id_request( + event_tracking_id=event_tracking_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_tenant_id_and_event_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("EventImpactedResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_tenant_id_and_event_id.metadata = { + "url": "/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/listSecurityAdvisoryImpactedResources" + } diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/py.typed b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2023_10_01_preview/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file