diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/_meta.json b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/_meta.json index 4acb590471e5..54b6f0c5a473 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/_meta.json +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/_meta.json @@ -1,11 +1,11 @@ { - "commit": "e37a57df67daaa82f9c3758fc450bc8655812a08", + "commit": "6186df37ec307c6451c03d53cb5801f20357a626", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest": "3.9.2", "use": [ - "@autorest/python@6.2.7", + "@autorest/python@6.5.0", "@autorest/modelerfour@4.24.3" ], - "autorest_command": "autorest specification/alertsmanagement/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.2.7 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/alertsmanagement/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.5.0 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/alertsmanagement/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_alerts_management_client.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_alerts_management_client.py index e896dc0a388c..dc9c4bb23fd4 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_alerts_management_client.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_alerts_management_client.py @@ -17,6 +17,7 @@ from ._serialization import Deserializer, Serializer from .operations import ( AlertProcessingRulesOperations, + AlertRuleRecommendationsOperations, AlertsOperations, Operations, PrometheusRuleGroupsOperations, @@ -31,9 +32,6 @@ class AlertsManagementClient: # pylint: disable=client-accepts-api-version-keyword """AlertsManagement Client. - :ivar alert_processing_rules: AlertProcessingRulesOperations operations - :vartype alert_processing_rules: - azure.mgmt.alertsmanagement.operations.AlertProcessingRulesOperations :ivar prometheus_rule_groups: PrometheusRuleGroupsOperations operations :vartype prometheus_rule_groups: azure.mgmt.alertsmanagement.operations.PrometheusRuleGroupsOperations @@ -43,8 +41,16 @@ class AlertsManagementClient: # pylint: disable=client-accepts-api-version-keyw :vartype alerts: azure.mgmt.alertsmanagement.operations.AlertsOperations :ivar smart_groups: SmartGroupsOperations operations :vartype smart_groups: azure.mgmt.alertsmanagement.operations.SmartGroupsOperations + :ivar alert_rule_recommendations: AlertRuleRecommendationsOperations operations + :vartype alert_rule_recommendations: + azure.mgmt.alertsmanagement.operations.AlertRuleRecommendationsOperations + :ivar alert_processing_rules: AlertProcessingRulesOperations operations + :vartype alert_processing_rules: + azure.mgmt.alertsmanagement.operations.AlertProcessingRulesOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential + :param target_type: The recommendations target type. Required. + :type target_type: str :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". @@ -54,28 +60,32 @@ class AlertsManagementClient: # pylint: disable=client-accepts-api-version-keyw def __init__( self, credential: "TokenCredential", + target_type: str, subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AlertsManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs + credential=credential, target_type=target_type, subscription_id=subscription_id, **kwargs ) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.alert_processing_rules = AlertProcessingRulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) self.prometheus_rule_groups = PrometheusRuleGroupsOperations( self._client, self._config, self._serialize, self._deserialize ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) self.smart_groups = SmartGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.alert_rule_recommendations = AlertRuleRecommendationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.alert_processing_rules = AlertProcessingRulesOperations( + 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. @@ -106,5 +116,5 @@ def __enter__(self) -> "AlertsManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details) -> None: + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_configuration.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_configuration.py index c5cebde237ea..ee9cf120b177 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_configuration.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_configuration.py @@ -27,18 +27,23 @@ class AlertsManagementClientConfiguration(Configuration): # pylint: disable=too :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential + :param target_type: The recommendations target type. Required. + :type target_type: str :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + def __init__(self, credential: "TokenCredential", target_type: str, subscription_id: str, **kwargs: Any) -> None: super(AlertsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") + if target_type is None: + raise ValueError("Parameter 'target_type' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential + self.target_type = target_type self.subscription_id = subscription_id self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-alertsmanagement/{}".format(VERSION)) diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_serialization.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_serialization.py index 2c170e28dbca..842ae727fbbc 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_serialization.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_serialization.py @@ -38,7 +38,22 @@ import re import sys import codecs -from typing import Optional, Union, AnyStr, IO, Mapping +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + TypeVar, + MutableMapping, + Type, + List, + Mapping, +) try: from urllib import quote # type: ignore @@ -48,12 +63,14 @@ import isodate # type: ignore -from typing import Dict, Any, cast - from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback +from azure.core.serialization import NULL as AzureCoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") +ModelType = TypeVar("ModelType", bound="Model") +JSON = MutableMapping[str, Any] + class RawDeserializer: @@ -277,8 +294,8 @@ class Model(object): _attribute_map: Dict[str, Dict[str, Any]] = {} _validation: Dict[str, Dict[str, Any]] = {} - def __init__(self, **kwargs): - self.additional_properties = {} + def __init__(self, **kwargs: Any) -> None: + self.additional_properties: Dict[str, Any] = {} for k in kwargs: if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) @@ -287,25 +304,25 @@ def __init__(self, **kwargs): else: setattr(self, k, kwargs[k]) - def __eq__(self, other): + def __eq__(self, other: Any) -> bool: """Compare objects by comparing all attributes.""" if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ return False - def __ne__(self, other): + def __ne__(self, other: Any) -> bool: """Compare objects by comparing all attributes.""" return not self.__eq__(other) - def __str__(self): + def __str__(self) -> str: return str(self.__dict__) @classmethod - def enable_additional_properties_sending(cls): + def enable_additional_properties_sending(cls) -> None: cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} @classmethod - def is_xml_model(cls): + def is_xml_model(cls) -> bool: try: cls._xml_map # type: ignore except AttributeError: @@ -322,7 +339,7 @@ def _create_xml_node(cls): return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - def serialize(self, keep_readonly=False, **kwargs): + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: """Return the JSON that would be sent to azure from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -336,8 +353,13 @@ def serialize(self, keep_readonly=False, **kwargs): serializer = Serializer(self._infer_class_models()) return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) - def as_dict(self, keep_readonly=True, key_transformer=attribute_transformer, **kwargs): - """Return a dict that can be JSONify using json.dump. + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. Advanced usage might optionally use a callback as parameter: @@ -384,7 +406,7 @@ def _infer_class_models(cls): return client_models @classmethod - def deserialize(cls, data, content_type=None): + def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: """Parse a str using the RestAPI syntax and return a model. :param str data: A str using RestAPI structure. JSON by default. @@ -396,7 +418,12 @@ def deserialize(cls, data, content_type=None): return deserializer(cls.__name__, data, content_type=content_type) @classmethod - def from_dict(cls, data, key_extractors=None, content_type=None): + def from_dict( + cls: Type[ModelType], + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> ModelType: """Parse a dict using given key extractor return a model. By default consider key @@ -409,8 +436,8 @@ def from_dict(cls, data, key_extractors=None, content_type=None): :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( - [ + deserializer.key_extractors = ( # type: ignore + [ # type: ignore attribute_key_case_insensitive_extractor, rest_key_case_insensitive_extractor, last_rest_key_case_insensitive_extractor, @@ -518,7 +545,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes=None): + def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -534,7 +561,7 @@ def __init__(self, classes=None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies = dict(classes) if classes else {} + self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -602,7 +629,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if xml_desc.get("attr", False): if xml_ns: ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) serialized.set(xml_name, new_attr) # type: ignore continue if xml_desc.get("text", False): @@ -626,8 +653,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore - unflattened = {k: new_attr} - new_attr = unflattened + new_attr = {k: new_attr} _new_attr = new_attr _serialized = serialized @@ -656,8 +682,8 @@ def body(self, data, data_type, **kwargs): """ # Just in case this is a dict - internal_data_type = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type, None) + internal_data_type_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, None) try: is_xml_model_serialization = kwargs["is_xml"] except KeyError: @@ -777,6 +803,8 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: + if data is AzureCoreNull: + return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -1161,7 +1189,8 @@ def rest_key_extractor(attr, attr_desc, data): working_data = data while "." in key: - dict_keys = _FLATTEN.split(key) + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(List[str], _FLATTEN.split(key)) if len(dict_keys) == 1: key = _decode_attribute_map_key(dict_keys[0]) break @@ -1242,7 +1271,7 @@ def _extract_name_from_internal_type(internal_type): xml_name = internal_type_xml_map.get("name", internal_type.__name__) xml_ns = internal_type_xml_map.get("ns", None) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) return xml_name @@ -1266,7 +1295,7 @@ def xml_key_extractor(attr, attr_desc, data): # Integrate namespace if necessary xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) # If it's an attribute, that's simple if xml_desc.get("attr", False): @@ -1332,7 +1361,7 @@ class Deserializer(object): valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes=None): + def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1352,7 +1381,7 @@ def __init__(self, classes=None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies = dict(classes) if classes else {} + self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1471,7 +1500,7 @@ def _classify_target(self, target, data): Once classification has been determined, initialize object. :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deseralize. + :param str/dict data: The response data to deserialize. """ if target is None: return None, None @@ -1486,7 +1515,7 @@ def _classify_target(self, target, data): target = target._classify(data, self.dependencies) except AttributeError: pass # Target is not a Model, no classify - return target, target.__class__.__name__ + return target, target.__class__.__name__ # type: ignore def failsafe_deserialize(self, target_obj, data, content_type=None): """Ignores any errors encountered in deserialization, @@ -1496,7 +1525,7 @@ def failsafe_deserialize(self, target_obj, data, content_type=None): a deserialization error. :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deseralize. + :param str/dict data: The response data to deserialize. :param str content_type: Swagger "produces" if available. """ try: diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_vendor.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_vendor.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_version.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_version.py index 2eda20789583..e5754a47ce68 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_version.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0b2" +VERSION = "1.0.0b1" diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/_alerts_management_client.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/_alerts_management_client.py index 3848d1701f82..8546224d0c50 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/_alerts_management_client.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/_alerts_management_client.py @@ -17,6 +17,7 @@ from ._configuration import AlertsManagementClientConfiguration from .operations import ( AlertProcessingRulesOperations, + AlertRuleRecommendationsOperations, AlertsOperations, Operations, PrometheusRuleGroupsOperations, @@ -31,9 +32,6 @@ class AlertsManagementClient: # pylint: disable=client-accepts-api-version-keyword """AlertsManagement Client. - :ivar alert_processing_rules: AlertProcessingRulesOperations operations - :vartype alert_processing_rules: - azure.mgmt.alertsmanagement.aio.operations.AlertProcessingRulesOperations :ivar prometheus_rule_groups: PrometheusRuleGroupsOperations operations :vartype prometheus_rule_groups: azure.mgmt.alertsmanagement.aio.operations.PrometheusRuleGroupsOperations @@ -43,8 +41,16 @@ class AlertsManagementClient: # pylint: disable=client-accepts-api-version-keyw :vartype alerts: azure.mgmt.alertsmanagement.aio.operations.AlertsOperations :ivar smart_groups: SmartGroupsOperations operations :vartype smart_groups: azure.mgmt.alertsmanagement.aio.operations.SmartGroupsOperations + :ivar alert_rule_recommendations: AlertRuleRecommendationsOperations operations + :vartype alert_rule_recommendations: + azure.mgmt.alertsmanagement.aio.operations.AlertRuleRecommendationsOperations + :ivar alert_processing_rules: AlertProcessingRulesOperations operations + :vartype alert_processing_rules: + azure.mgmt.alertsmanagement.aio.operations.AlertProcessingRulesOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param target_type: The recommendations target type. Required. + :type target_type: str :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". @@ -54,28 +60,32 @@ class AlertsManagementClient: # pylint: disable=client-accepts-api-version-keyw def __init__( self, credential: "AsyncTokenCredential", + target_type: str, subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AlertsManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs + credential=credential, target_type=target_type, subscription_id=subscription_id, **kwargs ) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.alert_processing_rules = AlertProcessingRulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) self.prometheus_rule_groups = PrometheusRuleGroupsOperations( self._client, self._config, self._serialize, self._deserialize ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) self.smart_groups = SmartGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.alert_rule_recommendations = AlertRuleRecommendationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.alert_processing_rules = AlertProcessingRulesOperations( + 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. @@ -106,5 +116,5 @@ async def __aenter__(self) -> "AlertsManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/_configuration.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/_configuration.py index 4295ad594068..13d6362b0470 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/_configuration.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/_configuration.py @@ -27,18 +27,25 @@ class AlertsManagementClientConfiguration(Configuration): # pylint: disable=too :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param target_type: The recommendations target type. Required. + :type target_type: str :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + def __init__( + self, credential: "AsyncTokenCredential", target_type: str, subscription_id: str, **kwargs: Any + ) -> None: super(AlertsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") + if target_type is None: + raise ValueError("Parameter 'target_type' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential + self.target_type = target_type self.subscription_id = subscription_id self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-alertsmanagement/{}".format(VERSION)) diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/__init__.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/__init__.py index c8dd1e48dcf0..bab3e18425ab 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/__init__.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/__init__.py @@ -6,22 +6,24 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._alert_processing_rules_operations import AlertProcessingRulesOperations from ._prometheus_rule_groups_operations import PrometheusRuleGroupsOperations from ._operations import Operations from ._alerts_operations import AlertsOperations from ._smart_groups_operations import SmartGroupsOperations +from ._alert_rule_recommendations_operations import AlertRuleRecommendationsOperations +from ._alert_processing_rules_operations import AlertProcessingRulesOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ - "AlertProcessingRulesOperations", "PrometheusRuleGroupsOperations", "Operations", "AlertsOperations", "SmartGroupsOperations", + "AlertRuleRecommendationsOperations", + "AlertProcessingRulesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_alert_processing_rules_operations.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_alert_processing_rules_operations.py index 4ffa545dcedd..b7d6e25d2039 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_alert_processing_rules_operations.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_alert_processing_rules_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -37,10 +37,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -77,7 +73,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AlertPro _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) cls: ClsType[_models.AlertProcessingRulesList] = kwargs.pop("cls", None) error_map = { @@ -118,14 +114,15 @@ async def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated3, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -153,7 +150,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) cls: ClsType[_models.AlertProcessingRulesList] = kwargs.pop("cls", None) error_map = { @@ -195,14 +192,15 @@ async def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated3, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -240,7 +238,7 @@ async def get_by_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) cls: ClsType[_models.AlertProcessingRule] = kwargs.pop("cls", None) request = build_get_by_name_request( @@ -255,15 +253,16 @@ async def get_by_name( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated3, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -351,8 +350,8 @@ async def create_or_update( :param alert_processing_rule_name: The name of the alert processing rule that needs to be created/updated. Required. :type alert_processing_rule_name: str - :param alert_processing_rule: Alert processing rule to be created/updated. Is either a model - type or a IO type. Required. + :param alert_processing_rule: Alert processing rule to be created/updated. Is either a + AlertProcessingRule type or a IO type. Required. :type alert_processing_rule: ~azure.mgmt.alertsmanagement.models.AlertProcessingRule or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -373,14 +372,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AlertProcessingRule] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(alert_processing_rule, (IO, bytes)): + if isinstance(alert_processing_rule, (IOBase, bytes)): _content = alert_processing_rule else: _json = self._serialize.body(alert_processing_rule, "AlertProcessingRule") @@ -400,15 +399,16 @@ async def create_or_update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated3, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -458,7 +458,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -473,15 +473,16 @@ async def delete( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated3, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -566,8 +567,8 @@ async def update( :type resource_group_name: str :param alert_processing_rule_name: The name that needs to be updated. Required. :type alert_processing_rule_name: str - :param alert_processing_rule_patch: Parameters supplied to the operation. Is either a model - type or a IO type. Required. + :param alert_processing_rule_patch: Parameters supplied to the operation. Is either a + PatchObject type or a IO type. Required. :type alert_processing_rule_patch: ~azure.mgmt.alertsmanagement.models.PatchObject or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -588,14 +589,14 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AlertProcessingRule] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(alert_processing_rule_patch, (IO, bytes)): + if isinstance(alert_processing_rule_patch, (IOBase, bytes)): _content = alert_processing_rule_patch else: _json = self._serialize.body(alert_processing_rule_patch, "PatchObject") @@ -615,15 +616,16 @@ async def update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated3, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_alert_rule_recommendations_operations.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_alert_rule_recommendations_operations.py new file mode 100644 index 000000000000..7dd3a938509e --- /dev/null +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_alert_rule_recommendations_operations.py @@ -0,0 +1,206 @@ +# 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 + +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._alert_rule_recommendations_operations import ( + build_list_by_resource_request, + build_list_by_target_type_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AlertRuleRecommendationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.alertsmanagement.aio.AlertsManagementClient`'s + :attr:`alert_rule_recommendations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_resource( + self, resource_uri: str, **kwargs: Any + ) -> AsyncIterable["_models.AlertRuleRecommendationResource"]: + """Retrieve alert rule recommendations for a resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AlertRuleRecommendationResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.alertsmanagement.models.AlertRuleRecommendationResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01-preview")) + cls: ClsType[_models.AlertRuleRecommendationsListResponse] = 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_request( + resource_uri=resource_uri, + api_version=api_version, + template_url=self.list_by_resource.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AlertRuleRecommendationsListResponse", 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.metadata = {"url": "/{resourceUri}/providers/Microsoft.AlertsManagement/alertRuleRecommendations"} + + @distributed_trace + def list_by_target_type(self, **kwargs: Any) -> AsyncIterable["_models.AlertRuleRecommendationResource"]: + """Retrieve alert rule recommendations for a target type. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AlertRuleRecommendationResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.alertsmanagement.models.AlertRuleRecommendationResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01-preview")) + cls: ClsType[_models.AlertRuleRecommendationsListResponse] = 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_target_type_request( + subscription_id=self._config.subscription_id, + target_type=self._config.target_type, + api_version=api_version, + template_url=self.list_by_target_type.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AlertRuleRecommendationsListResponse", 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_target_type.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alertRuleRecommendations" + } diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_alerts_operations.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_alerts_operations.py index 4e3955d1a17e..35199bbe5d74 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_alerts_operations.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_alerts_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -37,10 +37,6 @@ build_meta_data_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -87,9 +83,7 @@ async def meta_data(self, identifier: Union[str, _models.Identifier], **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) cls: ClsType[_models.AlertsMetaData] = kwargs.pop("cls", None) request = build_meta_data_request( @@ -102,15 +96,16 @@ async def meta_data(self, identifier: Union[str, _models.Identifier], **kwargs: request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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.ErrorResponseAutoGenerated2, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AlertsMetaData", pipeline_response) @@ -219,9 +214,7 @@ def get_all( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) cls: ClsType[_models.AlertsList] = kwargs.pop("cls", None) error_map = { @@ -279,14 +272,15 @@ async def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -319,9 +313,7 @@ async def get_by_id(self, alert_id: str, **kwargs: Any) -> _models.Alert: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) cls: ClsType[_models.Alert] = kwargs.pop("cls", None) request = build_get_by_id_request( @@ -335,15 +327,16 @@ async def get_by_id(self, alert_id: str, **kwargs: Any) -> _models.Alert: request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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.ErrorResponseAutoGenerated2, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("Alert", pipeline_response) @@ -428,7 +421,7 @@ async def change_state( :param new_state: New state of the alert. Known values are: "New", "Acknowledged", and "Closed". Required. :type new_state: str or ~azure.mgmt.alertsmanagement.models.AlertState - :param comment: reason of change alert state. Is either a model type or a IO type. Default + :param comment: reason of change alert state. Is either a Comments type or a IO type. Default value is None. :type comment: ~azure.mgmt.alertsmanagement.models.Comments or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -450,16 +443,14 @@ async def change_state( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Alert] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(comment, (IO, bytes)): + if isinstance(comment, (IOBase, bytes)): _content = comment else: if comment is not None: @@ -482,15 +473,16 @@ async def change_state( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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.ErrorResponseAutoGenerated2, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("Alert", pipeline_response) @@ -527,9 +519,7 @@ async def get_history(self, alert_id: str, **kwargs: Any) -> _models.AlertModifi _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) cls: ClsType[_models.AlertModification] = kwargs.pop("cls", None) request = build_get_history_request( @@ -543,15 +533,16 @@ async def get_history(self, alert_id: str, **kwargs: Any) -> _models.AlertModifi request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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.ErrorResponseAutoGenerated2, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AlertModification", pipeline_response) @@ -645,9 +636,7 @@ async def get_summary( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) cls: ClsType[_models.AlertsSummary] = kwargs.pop("cls", None) request = build_get_summary_request( @@ -672,15 +661,16 @@ async def get_summary( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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.ErrorResponseAutoGenerated2, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AlertsSummary", pipeline_response) diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_operations.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_operations.py index 16de0c077489..092b4380b8ae 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_operations.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -29,10 +28,6 @@ from ..._vendor import _convert_request from ...operations._operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,9 +63,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) cls: ClsType[_models.OperationsList] = kwargs.pop("cls", None) error_map = { @@ -110,14 +103,15 @@ async def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_prometheus_rule_groups_operations.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_prometheus_rule_groups_operations.py index a63d6eb5c371..fc283081a983 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_prometheus_rule_groups_operations.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_prometheus_rule_groups_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -37,10 +37,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -66,7 +62,7 @@ def __init__(self, *args, **kwargs) -> None: @distributed_trace def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.PrometheusRuleGroupResource"]: - """Retrieve Prometheus rule group definitions in a subscription. + """Retrieve Prometheus all rule group definitions in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrometheusRuleGroupResource or the result of @@ -78,9 +74,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Promethe _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-22-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-07-22-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) cls: ClsType[_models.PrometheusRuleGroupResourceCollection] = kwargs.pop("cls", None) error_map = { @@ -121,14 +115,15 @@ async def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -158,9 +153,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-22-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-07-22-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) cls: ClsType[_models.PrometheusRuleGroupResourceCollection] = kwargs.pop("cls", None) error_map = { @@ -202,14 +195,15 @@ async def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -247,9 +241,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-22-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-07-22-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) cls: ClsType[_models.PrometheusRuleGroupResource] = kwargs.pop("cls", None) request = build_get_request( @@ -264,15 +256,16 @@ async def get( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("PrometheusRuleGroupResource", pipeline_response) @@ -357,8 +350,8 @@ async def create_or_update( :type resource_group_name: str :param rule_group_name: The name of the rule group. Required. :type rule_group_name: str - :param parameters: The parameters of the rule group to create or update. Is either a model type - or a IO type. Required. + :param parameters: The parameters of the rule group to create or update. Is either a + PrometheusRuleGroupResource type or a IO type. Required. :type parameters: ~azure.mgmt.alertsmanagement.models.PrometheusRuleGroupResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -379,16 +372,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-22-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-07-22-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrometheusRuleGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "PrometheusRuleGroupResource") @@ -408,15 +399,16 @@ async def create_or_update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -439,7 +431,7 @@ async def update( self, resource_group_name: str, rule_group_name: str, - parameters: _models.PrometheusRuleGroupResourcePatch, + parameters: _models.PrometheusRuleGroupResourcePatchParameters, *, content_type: str = "application/json", **kwargs: Any @@ -452,7 +444,8 @@ async def update( :param rule_group_name: The name of the rule group. Required. :type rule_group_name: str :param parameters: The parameters of the rule group to update. Required. - :type parameters: ~azure.mgmt.alertsmanagement.models.PrometheusRuleGroupResourcePatch + :type parameters: + ~azure.mgmt.alertsmanagement.models.PrometheusRuleGroupResourcePatchParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -495,7 +488,7 @@ async def update( self, resource_group_name: str, rule_group_name: str, - parameters: Union[_models.PrometheusRuleGroupResourcePatch, IO], + parameters: Union[_models.PrometheusRuleGroupResourcePatchParameters, IO], **kwargs: Any ) -> _models.PrometheusRuleGroupResource: """Update an Prometheus rule group definition. @@ -505,9 +498,10 @@ async def update( :type resource_group_name: str :param rule_group_name: The name of the rule group. Required. :type rule_group_name: str - :param parameters: The parameters of the rule group to update. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.alertsmanagement.models.PrometheusRuleGroupResourcePatch or IO + :param parameters: The parameters of the rule group to update. Is either a + PrometheusRuleGroupResourcePatchParameters type or a IO type. Required. + :type parameters: + ~azure.mgmt.alertsmanagement.models.PrometheusRuleGroupResourcePatchParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str @@ -527,19 +521,17 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-22-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-07-22-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrometheusRuleGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "PrometheusRuleGroupResourcePatch") + _json = self._serialize.body(parameters, "PrometheusRuleGroupResourcePatchParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -556,15 +548,16 @@ async def update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("PrometheusRuleGroupResource", pipeline_response) @@ -605,9 +598,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-22-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-07-22-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -622,15 +613,16 @@ async def delete( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_smart_groups_operations.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_smart_groups_operations.py index e1efa4572337..930dc31a30cf 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_smart_groups_operations.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_smart_groups_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -35,10 +34,6 @@ build_get_history_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -130,9 +125,7 @@ def get_all( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) cls: ClsType[_models.SmartGroupsList] = kwargs.pop("cls", None) error_map = { @@ -184,14 +177,15 @@ async def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated3, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -224,9 +218,7 @@ async def get_by_id(self, smart_group_id: str, **kwargs: Any) -> _models.SmartGr _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) cls: ClsType[_models.SmartGroup] = kwargs.pop("cls", None) request = build_get_by_id_request( @@ -240,15 +232,16 @@ async def get_by_id(self, smart_group_id: str, **kwargs: Any) -> _models.SmartGr request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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.ErrorResponseAutoGenerated3, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -292,9 +285,7 @@ async def change_state( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) cls: ClsType[_models.SmartGroup] = kwargs.pop("cls", None) request = build_change_state_request( @@ -309,15 +300,16 @@ async def change_state( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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.ErrorResponseAutoGenerated3, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -357,9 +349,7 @@ async def get_history(self, smart_group_id: str, **kwargs: Any) -> _models.Smart _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) cls: ClsType[_models.SmartGroupModification] = kwargs.pop("cls", None) request = build_get_history_request( @@ -373,15 +363,16 @@ async def get_history(self, smart_group_id: str, **kwargs: Any) -> _models.Smart request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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.ErrorResponseAutoGenerated3, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("SmartGroupModification", pipeline_response) diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/__init__.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/__init__.py index 1bea22079797..431e24480771 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/__init__.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/__init__.py @@ -17,6 +17,8 @@ from ._models_py3 import AlertProcessingRuleProperties from ._models_py3 import AlertProcessingRulesList from ._models_py3 import AlertProperties +from ._models_py3 import AlertRuleRecommendationResource +from ._models_py3 import AlertRuleRecommendationsListResponse from ._models_py3 import AlertsList from ._models_py3 import AlertsMetaData from ._models_py3 import AlertsMetaDataProperties @@ -25,6 +27,8 @@ from ._models_py3 import AlertsSummaryGroupItem from ._models_py3 import Comments from ._models_py3 import Condition +from ._models_py3 import CorrelateAlerts +from ._models_py3 import CorrelateBy from ._models_py3 import DailyRecurrence from ._models_py3 import ErrorAdditionalInfo from ._models_py3 import ErrorDetail @@ -48,13 +52,14 @@ from ._models_py3 import PrometheusRuleGroupAction from ._models_py3 import PrometheusRuleGroupResource from ._models_py3 import PrometheusRuleGroupResourceCollection -from ._models_py3 import PrometheusRuleGroupResourcePatch -from ._models_py3 import PrometheusRuleGroupResourcePatchProperties +from ._models_py3 import PrometheusRuleGroupResourcePatchParameters from ._models_py3 import PrometheusRuleResolveConfiguration +from ._models_py3 import ProxyResource from ._models_py3 import Recurrence from ._models_py3 import RemoveAllActionGroups from ._models_py3 import Resource from ._models_py3 import ResourceAutoGenerated +from ._models_py3 import RuleArmTemplate from ._models_py3 import Schedule from ._models_py3 import SmartGroup from ._models_py3 import SmartGroupAggregatedProperty @@ -76,8 +81,10 @@ from ._alerts_management_client_enums import Field from ._alerts_management_client_enums import Identifier from ._alerts_management_client_enums import MetadataIdentifier +from ._alerts_management_client_enums import MetricAlertsDisplayUnit from ._alerts_management_client_enums import MonitorCondition from ._alerts_management_client_enums import MonitorService +from ._alerts_management_client_enums import NotificationsForCorrelatedAlerts from ._alerts_management_client_enums import Operator from ._alerts_management_client_enums import RecurrenceType from ._alerts_management_client_enums import Severity @@ -103,6 +110,8 @@ "AlertProcessingRuleProperties", "AlertProcessingRulesList", "AlertProperties", + "AlertRuleRecommendationResource", + "AlertRuleRecommendationsListResponse", "AlertsList", "AlertsMetaData", "AlertsMetaDataProperties", @@ -111,6 +120,8 @@ "AlertsSummaryGroupItem", "Comments", "Condition", + "CorrelateAlerts", + "CorrelateBy", "DailyRecurrence", "ErrorAdditionalInfo", "ErrorDetail", @@ -134,13 +145,14 @@ "PrometheusRuleGroupAction", "PrometheusRuleGroupResource", "PrometheusRuleGroupResourceCollection", - "PrometheusRuleGroupResourcePatch", - "PrometheusRuleGroupResourcePatchProperties", + "PrometheusRuleGroupResourcePatchParameters", "PrometheusRuleResolveConfiguration", + "ProxyResource", "Recurrence", "RemoveAllActionGroups", "Resource", "ResourceAutoGenerated", + "RuleArmTemplate", "Schedule", "SmartGroup", "SmartGroupAggregatedProperty", @@ -161,8 +173,10 @@ "Field", "Identifier", "MetadataIdentifier", + "MetricAlertsDisplayUnit", "MonitorCondition", "MonitorService", + "NotificationsForCorrelatedAlerts", "Operator", "RecurrenceType", "Severity", diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/_alerts_management_client_enums.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/_alerts_management_client_enums.py index 845acc76887f..7affac4ceda8 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/_alerts_management_client_enums.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/_alerts_management_client_enums.py @@ -15,6 +15,7 @@ class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): ADD_ACTION_GROUPS = "AddActionGroups" REMOVE_ALL_ACTION_GROUPS = "RemoveAllActionGroups" + CORRELATE_ALERTS = "CorrelateAlerts" class AlertModificationEvent(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -114,6 +115,47 @@ class MetadataIdentifier(str, Enum, metaclass=CaseInsensitiveEnumMeta): MONITOR_SERVICE_LIST = "MonitorServiceList" +class MetricAlertsDisplayUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The unit to display for a metric alert rule.""" + + NONE = "None" + PERCENTAGE = "Percentage" + BYTES = "Bytes" + KILOBYTES = "Kilobytes" + MEGABYTES = "Megabytes" + GIGABYTES = "Gigabytes" + TERABYTES = "Terabytes" + PETABYTES = "Petabytes" + BYTES_PER_DAY = "BytesPerDay" + BYTES_PER_HOUR = "BytesPerHour" + BYTES_PER_MINUTE = "BytesPerMinute" + BYTES_PER_SECOND = "BytesPerSecond" + KILOBYTES_PER_SECOND = "KilobytesPerSecond" + MEGABYTES_PER_SECOND = "MegabytesPerSecond" + GIGABYTES_PER_SECOND = "GigabytesPerSecond" + TERABYTES_PER_SECOND = "TerabytesPerSecond" + PETABYTES_PER_SECOND = "PetabytesPerSecond" + COUNT = "Count" + THOUSAND = "Thousand" + MILLION = "Million" + BILLION = "Billion" + TRILLION = "Trillion" + MICRO_SECONDS = "MicroSeconds" + MILLI_SECONDS = "MilliSeconds" + SECONDS = "Seconds" + MINUTES = "Minutes" + HOURS = "Hours" + DAYS = "Days" + COUNT_PER_DAY = "CountPerDay" + COUNT_PER_HOUR = "CountPerHour" + COUNT_PER_MINUTE = "CountPerMinute" + COUNT_PER_SECOND = "CountPerSecond" + THOUSAND_PER_SECOND = "ThousandPerSecond" + MILLION_PER_SECOND = "MillionPerSecond" + BILLION_PER_SECOND = "BillionPerSecond" + TRILLION_PER_SECOND = "TrillionPerSecond" + + class MonitorCondition(str, Enum, metaclass=CaseInsensitiveEnumMeta): """MonitorCondition.""" @@ -140,6 +182,13 @@ class MonitorService(str, Enum, metaclass=CaseInsensitiveEnumMeta): ZABBIX = "Zabbix" +class NotificationsForCorrelatedAlerts(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates how to handle child alerts notifications.""" + + NOTIFY_ALWAYS = "NotifyAlways" + SUPPRESS_ALWAYS = "SuppressAlways" + + class Operator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Operator for a given condition.""" diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/_models_py3.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/_models_py3.py index de87aaa590fe..1615d2ee4359 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/_models_py3.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/_models_py3.py @@ -8,25 +8,32 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, TYPE_CHECKING, Union +import sys +from typing import Any, Dict, 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 Action(_serialization.Model): """Action to be applied. You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AddActionGroups, RemoveAllActionGroups + AddActionGroups, CorrelateAlerts, RemoveAllActionGroups All required parameters must be populated in order to send to Azure. - :ivar action_type: Action that should be applied. Required. Known values are: "AddActionGroups" - and "RemoveAllActionGroups". + :ivar action_type: Action that should be applied. Required. Known values are: + "AddActionGroups", "RemoveAllActionGroups", and "CorrelateAlerts". :vartype action_type: str or ~azure.mgmt.alertsmanagement.models.ActionType """ @@ -39,10 +46,14 @@ class Action(_serialization.Model): } _subtype_map = { - "action_type": {"AddActionGroups": "AddActionGroups", "RemoveAllActionGroups": "RemoveAllActionGroups"} + "action_type": { + "AddActionGroups": "AddActionGroups", + "CorrelateAlerts": "CorrelateAlerts", + "RemoveAllActionGroups": "RemoveAllActionGroups", + } } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.action_type: Optional[str] = None @@ -59,7 +70,7 @@ class ActionStatus(_serialization.Model): "is_suppressed": {"key": "isSuppressed", "type": "bool"}, } - def __init__(self, *, is_suppressed: Optional[bool] = None, **kwargs): + def __init__(self, *, is_suppressed: Optional[bool] = None, **kwargs: Any) -> None: """ :keyword is_suppressed: Value indicating whether alert is suppressed. :paramtype is_suppressed: bool @@ -73,8 +84,8 @@ class AddActionGroups(Action): All required parameters must be populated in order to send to Azure. - :ivar action_type: Action that should be applied. Required. Known values are: "AddActionGroups" - and "RemoveAllActionGroups". + :ivar action_type: Action that should be applied. Required. Known values are: + "AddActionGroups", "RemoveAllActionGroups", and "CorrelateAlerts". :vartype action_type: str or ~azure.mgmt.alertsmanagement.models.ActionType :ivar action_group_ids: List of action group Ids to add to alert processing rule. Required. :vartype action_group_ids: list[str] @@ -90,7 +101,7 @@ class AddActionGroups(Action): "action_group_ids": {"key": "actionGroupIds", "type": "[str]"}, } - def __init__(self, *, action_group_ids: List[str], **kwargs): + def __init__(self, *, action_group_ids: List[str], **kwargs: Any) -> None: """ :keyword action_group_ids: List of action group Ids to add to alert processing rule. Required. :paramtype action_group_ids: list[str] @@ -100,7 +111,7 @@ def __init__(self, *, action_group_ids: List[str], **kwargs): self.action_group_ids = action_group_ids -class Resource(_serialization.Model): +class ResourceAutoGenerated(_serialization.Model): """An azure resource object. Variables are only populated by the server, and will be ignored when sending a request. @@ -125,7 +136,7 @@ class Resource(_serialization.Model): "name": {"key": "name", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None @@ -133,7 +144,7 @@ def __init__(self, **kwargs): self.name = None -class Alert(Resource): +class Alert(ResourceAutoGenerated): """An alert created in alert management service. Variables are only populated by the server, and will be ignored when sending a request. @@ -161,7 +172,7 @@ class Alert(Resource): "properties": {"key": "properties", "type": "AlertProperties"}, } - def __init__(self, *, properties: Optional["_models.AlertProperties"] = None, **kwargs): + def __init__(self, *, properties: Optional["_models.AlertProperties"] = None, **kwargs: Any) -> None: """ :keyword properties: Alert property bag. :paramtype properties: ~azure.mgmt.alertsmanagement.models.AlertProperties @@ -170,7 +181,7 @@ def __init__(self, *, properties: Optional["_models.AlertProperties"] = None, ** self.properties = properties -class AlertModification(Resource): +class AlertModification(ResourceAutoGenerated): """Alert Modification details. Variables are only populated by the server, and will be ignored when sending a request. @@ -198,7 +209,7 @@ class AlertModification(Resource): "properties": {"key": "properties", "type": "AlertModificationProperties"}, } - def __init__(self, *, properties: Optional["_models.AlertModificationProperties"] = None, **kwargs): + def __init__(self, *, properties: Optional["_models.AlertModificationProperties"] = None, **kwargs: Any) -> None: """ :keyword properties: Properties of the alert modification item. :paramtype properties: ~azure.mgmt.alertsmanagement.models.AlertModificationProperties @@ -248,8 +259,8 @@ def __init__( modified_by: Optional[str] = None, comments: Optional[str] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword modification_event: Reason for the modification. Known values are: "AlertCreated", "StateChange", "MonitorConditionChange", "SeverityChange", "ActionRuleTriggered", @@ -299,7 +310,7 @@ class AlertModificationProperties(_serialization.Model): "modifications": {"key": "modifications", "type": "[AlertModificationItem]"}, } - def __init__(self, *, modifications: Optional[List["_models.AlertModificationItem"]] = None, **kwargs): + def __init__(self, *, modifications: Optional[List["_models.AlertModificationItem"]] = None, **kwargs: Any) -> None: """ :keyword modifications: Modification details. :paramtype modifications: list[~azure.mgmt.alertsmanagement.models.AlertModificationItem] @@ -309,7 +320,7 @@ def __init__(self, *, modifications: Optional[List["_models.AlertModificationIte self.modifications = modifications -class ManagedResource(Resource): +class ManagedResource(ResourceAutoGenerated): """An azure managed resource object. Variables are only populated by the server, and will be ignored when sending a request. @@ -343,7 +354,7 @@ class ManagedResource(Resource): "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -402,8 +413,8 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, properties: Optional["_models.AlertProcessingRuleProperties"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -418,7 +429,8 @@ def __init__( class AlertProcessingRuleProperties(_serialization.Model): - """Alert processing rule properties defining scopes, conditions and scheduling logic for alert processing rule. + """Alert processing rule properties defining scopes, conditions and scheduling logic for alert + processing rule. All required parameters must be populated in order to send to Azure. @@ -459,8 +471,8 @@ def __init__( schedule: Optional["_models.Schedule"] = None, description: Optional[str] = None, enabled: bool = True, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword scopes: Scopes on which alert processing rule will apply. Required. :paramtype scopes: list[str] @@ -499,8 +511,12 @@ class AlertProcessingRulesList(_serialization.Model): } def __init__( - self, *, next_link: Optional[str] = None, value: Optional[List["_models.AlertProcessingRule"]] = None, **kwargs - ): + self, + *, + next_link: Optional[str] = None, + value: Optional[List["_models.AlertProcessingRule"]] = None, + **kwargs: Any + ) -> None: """ :keyword next_link: URL to fetch the next set of alert processing rules. :paramtype next_link: str @@ -537,7 +553,7 @@ class AlertProperties(_serialization.Model): "egress_config": {"key": "egressConfig", "type": "object"}, } - def __init__(self, *, essentials: Optional["_models.Essentials"] = None, **kwargs): + def __init__(self, *, essentials: Optional["_models.Essentials"] = None, **kwargs: Any) -> None: """ :keyword essentials: This object contains consistent fields across different monitor services. :paramtype essentials: ~azure.mgmt.alertsmanagement.models.Essentials @@ -548,6 +564,189 @@ def __init__(self, *, essentials: Optional["_models.Essentials"] = None, **kwarg self.egress_config = None +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.alertsmanagement.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.alertsmanagement.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 AlertRuleRecommendationResource(ProxyResource): + """A single alert rule recommendation resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :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.alertsmanagement.models.SystemData + :ivar alert_rule_type: The recommendation alert rule type. Required. + :vartype alert_rule_type: str + :ivar display_information: A dictionary that provides the display information for an alert rule + recommendation. Required. + :vartype display_information: dict[str, str] + :ivar rule_arm_template: A complete ARM template to deploy the alert rules. Required. + :vartype rule_arm_template: ~azure.mgmt.alertsmanagement.models.RuleArmTemplate + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "alert_rule_type": {"required": True}, + "display_information": {"required": True}, + "rule_arm_template": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "alert_rule_type": {"key": "properties.alertRuleType", "type": "str"}, + "display_information": {"key": "properties.displayInformation", "type": "{str}"}, + "rule_arm_template": {"key": "properties.ruleArmTemplate", "type": "RuleArmTemplate"}, + } + + def __init__( + self, + *, + alert_rule_type: str, + display_information: Dict[str, str], + rule_arm_template: "_models.RuleArmTemplate", + **kwargs: Any + ) -> None: + """ + :keyword alert_rule_type: The recommendation alert rule type. Required. + :paramtype alert_rule_type: str + :keyword display_information: A dictionary that provides the display information for an alert + rule recommendation. Required. + :paramtype display_information: dict[str, str] + :keyword rule_arm_template: A complete ARM template to deploy the alert rules. Required. + :paramtype rule_arm_template: ~azure.mgmt.alertsmanagement.models.RuleArmTemplate + """ + super().__init__(**kwargs) + self.alert_rule_type = alert_rule_type + self.display_information = display_information + self.rule_arm_template = rule_arm_template + + +class AlertRuleRecommendationsListResponse(_serialization.Model): + """List of alert rule recommendations. + + All required parameters must be populated in order to send to Azure. + + :ivar value: the values for the alert rule recommendations. Required. + :vartype value: list[~azure.mgmt.alertsmanagement.models.AlertRuleRecommendationResource] + :ivar next_link: URL to fetch the next set of recommendations. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[AlertRuleRecommendationResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.AlertRuleRecommendationResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: the values for the alert rule recommendations. Required. + :paramtype value: list[~azure.mgmt.alertsmanagement.models.AlertRuleRecommendationResource] + :keyword next_link: URL to fetch the next set of recommendations. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + class AlertsList(_serialization.Model): """List the alerts. @@ -562,7 +761,9 @@ class AlertsList(_serialization.Model): "value": {"key": "value", "type": "[Alert]"}, } - def __init__(self, *, next_link: Optional[str] = None, value: Optional[List["_models.Alert"]] = None, **kwargs): + def __init__( + self, *, next_link: Optional[str] = None, value: Optional[List["_models.Alert"]] = None, **kwargs: Any + ) -> None: """ :keyword next_link: URL to fetch the next set of alerts. :paramtype next_link: str @@ -585,7 +786,7 @@ class AlertsMetaData(_serialization.Model): "properties": {"key": "properties", "type": "AlertsMetaDataProperties"}, } - def __init__(self, *, properties: Optional["_models.AlertsMetaDataProperties"] = None, **kwargs): + def __init__(self, *, properties: Optional["_models.AlertsMetaDataProperties"] = None, **kwargs: Any) -> None: """ :keyword properties: alert meta data property bag. :paramtype properties: ~azure.mgmt.alertsmanagement.models.AlertsMetaDataProperties @@ -617,13 +818,13 @@ class AlertsMetaDataProperties(_serialization.Model): _subtype_map = {"metadata_identifier": {"MonitorServiceList": "MonitorServiceList"}} - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.metadata_identifier: Optional[str] = None -class AlertsSummary(Resource): +class AlertsSummary(ResourceAutoGenerated): """Summary of alerts based on the input filters and 'groupby' parameters. Variables are only populated by the server, and will be ignored when sending a request. @@ -651,7 +852,7 @@ class AlertsSummary(Resource): "properties": {"key": "properties", "type": "AlertsSummaryGroup"}, } - def __init__(self, *, properties: Optional["_models.AlertsSummaryGroup"] = None, **kwargs): + def __init__(self, *, properties: Optional["_models.AlertsSummaryGroup"] = None, **kwargs: Any) -> None: """ :keyword properties: Group the result set. :paramtype properties: ~azure.mgmt.alertsmanagement.models.AlertsSummaryGroup @@ -687,8 +888,8 @@ def __init__( smart_groups_count: Optional[int] = None, groupedby: Optional[str] = None, values: Optional[List["_models.AlertsSummaryGroupItem"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword total: Total count of the result set. :paramtype total: int @@ -733,8 +934,8 @@ def __init__( count: Optional[int] = None, groupedby: Optional[str] = None, values: Optional[List["_models.AlertsSummaryGroupItem"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Value of the aggregated field. :paramtype name: str @@ -763,7 +964,7 @@ class Comments(_serialization.Model): "comments": {"key": "comments", "type": "str"}, } - def __init__(self, *, comments: Optional[str] = None, **kwargs): + def __init__(self, *, comments: Optional[str] = None, **kwargs: Any) -> None: """ :keyword comments: :paramtype comments: str @@ -798,8 +999,8 @@ def __init__( field: Optional[Union[str, "_models.Field"]] = None, operator: Optional[Union[str, "_models.Operator"]] = None, values: Optional[List[str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword field: Field for a given condition. Known values are: "Severity", "MonitorService", "MonitorCondition", "SignalType", "TargetResourceType", "TargetResource", @@ -817,6 +1018,92 @@ def __init__( self.values = values +class CorrelateAlerts(Action): + """Add logic for alerts correlation. + + All required parameters must be populated in order to send to Azure. + + :ivar action_type: Action that should be applied. Required. Known values are: + "AddActionGroups", "RemoveAllActionGroups", and "CorrelateAlerts". + :vartype action_type: str or ~azure.mgmt.alertsmanagement.models.ActionType + :ivar correlate_by: The list of conditions for the alerts correlations. Required. + :vartype correlate_by: list[~azure.mgmt.alertsmanagement.models.CorrelateBy] + :ivar correlation_interval: The required duration (in ISO8601 format) for the alerts + correlation. Required. + :vartype correlation_interval: str + :ivar priority: The priority of this correlation. Required. + :vartype priority: int + :ivar notifications_for_correlated_alerts: Indicates how to handle child alerts notifications. + Known values are: "NotifyAlways" and "SuppressAlways". + :vartype notifications_for_correlated_alerts: str or + ~azure.mgmt.alertsmanagement.models.NotificationsForCorrelatedAlerts + """ + + _validation = { + "action_type": {"required": True}, + "correlate_by": {"required": True}, + "correlation_interval": {"required": True}, + "priority": {"required": True}, + } + + _attribute_map = { + "action_type": {"key": "actionType", "type": "str"}, + "correlate_by": {"key": "correlateBy", "type": "[CorrelateBy]"}, + "correlation_interval": {"key": "correlationInterval", "type": "str"}, + "priority": {"key": "priority", "type": "int"}, + "notifications_for_correlated_alerts": {"key": "notificationsForCorrelatedAlerts", "type": "str"}, + } + + def __init__( + self, + *, + correlate_by: List["_models.CorrelateBy"], + correlation_interval: str, + priority: int, + notifications_for_correlated_alerts: Union[str, "_models.NotificationsForCorrelatedAlerts"] = "SuppressAlways", + **kwargs: Any + ) -> None: + """ + :keyword correlate_by: The list of conditions for the alerts correlations. Required. + :paramtype correlate_by: list[~azure.mgmt.alertsmanagement.models.CorrelateBy] + :keyword correlation_interval: The required duration (in ISO8601 format) for the alerts + correlation. Required. + :paramtype correlation_interval: str + :keyword priority: The priority of this correlation. Required. + :paramtype priority: int + :keyword notifications_for_correlated_alerts: Indicates how to handle child alerts + notifications. Known values are: "NotifyAlways" and "SuppressAlways". + :paramtype notifications_for_correlated_alerts: str or + ~azure.mgmt.alertsmanagement.models.NotificationsForCorrelatedAlerts + """ + super().__init__(**kwargs) + self.action_type: str = "CorrelateAlerts" + self.correlate_by = correlate_by + self.correlation_interval = correlation_interval + self.priority = priority + self.notifications_for_correlated_alerts = notifications_for_correlated_alerts + + +class CorrelateBy(_serialization.Model): + """The logic for the correlation. + + :ivar field: The JPath of the property that the alerts should be correlated by. + :vartype field: str + """ + + _attribute_map = { + "field": {"key": "field", "type": "str"}, + } + + def __init__(self, *, field: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword field: The JPath of the property that the alerts should be correlated by. + :paramtype field: str + """ + super().__init__(**kwargs) + self.field = field + + class Recurrence(_serialization.Model): """Recurrence object. @@ -848,7 +1135,7 @@ class Recurrence(_serialization.Model): "recurrence_type": {"Daily": "DailyRecurrence", "Monthly": "MonthlyRecurrence", "Weekly": "WeeklyRecurrence"} } - def __init__(self, *, start_time: Optional[str] = None, end_time: Optional[str] = None, **kwargs): + def __init__(self, *, start_time: Optional[str] = None, end_time: Optional[str] = None, **kwargs: Any) -> None: """ :keyword start_time: Start time for recurrence. :paramtype start_time: str @@ -885,7 +1172,7 @@ class DailyRecurrence(Recurrence): "end_time": {"key": "endTime", "type": "str"}, } - def __init__(self, *, start_time: Optional[str] = None, end_time: Optional[str] = None, **kwargs): + def __init__(self, *, start_time: Optional[str] = None, end_time: Optional[str] = None, **kwargs: Any) -> None: """ :keyword start_time: Start time for recurrence. :paramtype start_time: str @@ -917,7 +1204,7 @@ class ErrorAdditionalInfo(_serialization.Model): "info": {"key": "info", "type": "object"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type = None @@ -957,7 +1244,7 @@ class ErrorDetail(_serialization.Model): "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None @@ -968,40 +1255,41 @@ def __init__(self, **kwargs): class ErrorResponse(_serialization.Model): - """An error response from the service. + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). - :ivar error: Details of error response. - :vartype error: ~azure.mgmt.alertsmanagement.models.ErrorResponseBody + :ivar error: The error object. + :vartype error: ~azure.mgmt.alertsmanagement.models.ErrorDetail """ _attribute_map = { - "error": {"key": "error", "type": "ErrorResponseBody"}, + "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs): + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ - :keyword error: Details of error response. - :paramtype error: ~azure.mgmt.alertsmanagement.models.ErrorResponseBody + :keyword error: The error object. + :paramtype error: ~azure.mgmt.alertsmanagement.models.ErrorDetail """ super().__init__(**kwargs) self.error = error class ErrorResponseAutoGenerated(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). + """An error response from the service. - :ivar error: The error object. - :vartype error: ~azure.mgmt.alertsmanagement.models.ErrorDetail + :ivar error: Details of error response. + :vartype error: ~azure.mgmt.alertsmanagement.models.ErrorResponseBody """ _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, + "error": {"key": "error", "type": "ErrorResponseBody"}, } - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs): + def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs: Any) -> None: """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.alertsmanagement.models.ErrorDetail + :keyword error: Details of error response. + :paramtype error: ~azure.mgmt.alertsmanagement.models.ErrorResponseBody """ super().__init__(**kwargs) self.error = error @@ -1018,7 +1306,7 @@ class ErrorResponseAutoGenerated2(_serialization.Model): "error": {"key": "error", "type": "ErrorResponseBodyAutoGenerated"}, } - def __init__(self, *, error: Optional["_models.ErrorResponseBodyAutoGenerated"] = None, **kwargs): + def __init__(self, *, error: Optional["_models.ErrorResponseBodyAutoGenerated"] = None, **kwargs: Any) -> None: """ :keyword error: Details of error response. :paramtype error: ~azure.mgmt.alertsmanagement.models.ErrorResponseBodyAutoGenerated @@ -1038,7 +1326,7 @@ class ErrorResponseAutoGenerated3(_serialization.Model): "error": {"key": "error", "type": "ErrorResponseBodyAutoGenerated2"}, } - def __init__(self, *, error: Optional["_models.ErrorResponseBodyAutoGenerated2"] = None, **kwargs): + def __init__(self, *, error: Optional["_models.ErrorResponseBodyAutoGenerated2"] = None, **kwargs: Any) -> None: """ :keyword error: Details of error response. :paramtype error: ~azure.mgmt.alertsmanagement.models.ErrorResponseBodyAutoGenerated2 @@ -1074,8 +1362,8 @@ def __init__( message: Optional[str] = None, target: Optional[str] = None, details: Optional[List["_models.ErrorResponseBody"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword code: Error code, intended to be consumed programmatically. :paramtype code: str @@ -1120,8 +1408,8 @@ def __init__( message: Optional[str] = None, target: Optional[str] = None, details: Optional[List["_models.ErrorResponseBodyAutoGenerated"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword code: Error code, intended to be consumed programmatically. :paramtype code: str @@ -1166,8 +1454,8 @@ def __init__( message: Optional[str] = None, target: Optional[str] = None, details: Optional[List["_models.ErrorResponseBodyAutoGenerated2"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword code: Error code, intended to be consumed programmatically. :paramtype code: str @@ -1291,8 +1579,8 @@ def __init__( target_resource_type: Optional[str] = None, action_status: Optional["_models.ActionStatus"] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword target_resource: Target ARM resource, on which alert got created. :paramtype target_resource: str @@ -1346,7 +1634,7 @@ class MonitorServiceDetails(_serialization.Model): "display_name": {"key": "displayName", "type": "str"}, } - def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = None, **kwargs): + def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = None, **kwargs: Any) -> None: """ :keyword name: Monitor service name. :paramtype name: str @@ -1380,7 +1668,7 @@ class MonitorServiceList(AlertsMetaDataProperties): "data": {"key": "data", "type": "[MonitorServiceDetails]"}, } - def __init__(self, *, data: List["_models.MonitorServiceDetails"], **kwargs): + def __init__(self, *, data: List["_models.MonitorServiceDetails"], **kwargs: Any) -> None: """ :keyword data: Array of operations. Required. :paramtype data: list[~azure.mgmt.alertsmanagement.models.MonitorServiceDetails] @@ -1419,8 +1707,13 @@ class MonthlyRecurrence(Recurrence): } def __init__( - self, *, days_of_month: List[int], start_time: Optional[str] = None, end_time: Optional[str] = None, **kwargs - ): + self, + *, + days_of_month: List[int], + start_time: Optional[str] = None, + end_time: Optional[str] = None, + **kwargs: Any + ) -> None: """ :keyword start_time: Start time for recurrence. :paramtype start_time: str @@ -1457,8 +1750,8 @@ def __init__( name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Name of the operation. :paramtype name: str @@ -1500,8 +1793,8 @@ def __init__( resource: Optional[str] = None, operation: Optional[str] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword provider: Provider name. :paramtype provider: str @@ -1539,7 +1832,7 @@ class OperationsList(_serialization.Model): "value": {"key": "value", "type": "[Operation]"}, } - def __init__(self, *, value: List["_models.Operation"], next_link: Optional[str] = None, **kwargs): + def __init__(self, *, value: List["_models.Operation"], next_link: Optional[str] = None, **kwargs: Any) -> None: """ :keyword next_link: URL to fetch the next set of alerts. :paramtype next_link: str @@ -1565,7 +1858,7 @@ class PatchObject(_serialization.Model): "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: Optional[bool] = None, **kwargs): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: Optional[bool] = None, **kwargs: Any) -> None: """ :keyword tags: Tags to be updated. :paramtype tags: dict[str, str] @@ -1578,31 +1871,35 @@ def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: Optional[b class PrometheusRule(_serialization.Model): - """PrometheusRule. + """An Azure Prometheus alerting or recording rule. All required parameters must be populated in order to send to Azure. - :ivar record: the name of the recording rule. + :ivar record: Recorded metrics name. :vartype record: str - :ivar alert: the name of the alert rule. + :ivar alert: Alert rule name. :vartype alert: str - :ivar enabled: the flag that indicates whether the Prometheus rule is enabled. + :ivar enabled: Enable/disable rule. :vartype enabled: bool - :ivar expression: the expression to run for the rule. Required. + :ivar expression: The PromQL expression to evaluate. + https://prometheus.io/docs/prometheus/latest/querying/basics/. Evaluated periodically as given + by 'interval', and the result recorded as a new set of time series with the metric name as + given by 'record'. Required. :vartype expression: str - :ivar severity: the severity of the alerts fired by the rule. Only relevant for alerts. - :vartype severity: int - :ivar for_property: the amount of time alert must be active before firing. Only relevant for - alerts. - :vartype for_property: str - :ivar labels: labels for rule group. Only relevant for alerts. + :ivar labels: Labels to add or overwrite before storing the result. :vartype labels: dict[str, str] - :ivar annotations: annotations for rule group. Only relevant for alerts. + :ivar severity: The severity of the alerts fired by the rule. Must be between 0 and 4. + :vartype severity: int + :ivar for_property: The amount of time alert must be active before firing. + :vartype for_property: ~datetime.timedelta + :ivar annotations: The annotations clause specifies a set of informational labels that can be + used to store longer additional information such as alert descriptions or runbook links. The + annotation values can be templated. :vartype annotations: dict[str, str] - :ivar actions: The array of actions that are performed when the alert rule becomes active, and - when an alert condition is resolved. Only relevant for alerts. + :ivar actions: Actions that are performed when the alert rule becomes active, and when an alert + condition is resolved. :vartype actions: list[~azure.mgmt.alertsmanagement.models.PrometheusRuleGroupAction] - :ivar resolve_configuration: defines the configuration for resolving fired alerts. Only + :ivar resolve_configuration: Defines the configuration for resolving fired alerts. Only relevant for alerts. :vartype resolve_configuration: ~azure.mgmt.alertsmanagement.models.PrometheusRuleResolveConfiguration @@ -1617,9 +1914,9 @@ class PrometheusRule(_serialization.Model): "alert": {"key": "alert", "type": "str"}, "enabled": {"key": "enabled", "type": "bool"}, "expression": {"key": "expression", "type": "str"}, - "severity": {"key": "severity", "type": "int"}, - "for_property": {"key": "for", "type": "str"}, "labels": {"key": "labels", "type": "{str}"}, + "severity": {"key": "severity", "type": "int"}, + "for_property": {"key": "for", "type": "duration"}, "annotations": {"key": "annotations", "type": "{str}"}, "actions": {"key": "actions", "type": "[PrometheusRuleGroupAction]"}, "resolve_configuration": {"key": "resolveConfiguration", "type": "PrometheusRuleResolveConfiguration"}, @@ -1632,36 +1929,40 @@ def __init__( record: Optional[str] = None, alert: Optional[str] = None, enabled: Optional[bool] = None, - severity: Optional[int] = None, - for_property: Optional[str] = None, labels: Optional[Dict[str, str]] = None, + severity: Optional[int] = None, + for_property: Optional[datetime.timedelta] = None, annotations: Optional[Dict[str, str]] = None, actions: Optional[List["_models.PrometheusRuleGroupAction"]] = None, resolve_configuration: Optional["_models.PrometheusRuleResolveConfiguration"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ - :keyword record: the name of the recording rule. + :keyword record: Recorded metrics name. :paramtype record: str - :keyword alert: the name of the alert rule. + :keyword alert: Alert rule name. :paramtype alert: str - :keyword enabled: the flag that indicates whether the Prometheus rule is enabled. + :keyword enabled: Enable/disable rule. :paramtype enabled: bool - :keyword expression: the expression to run for the rule. Required. + :keyword expression: The PromQL expression to evaluate. + https://prometheus.io/docs/prometheus/latest/querying/basics/. Evaluated periodically as given + by 'interval', and the result recorded as a new set of time series with the metric name as + given by 'record'. Required. :paramtype expression: str - :keyword severity: the severity of the alerts fired by the rule. Only relevant for alerts. - :paramtype severity: int - :keyword for_property: the amount of time alert must be active before firing. Only relevant for - alerts. - :paramtype for_property: str - :keyword labels: labels for rule group. Only relevant for alerts. + :keyword labels: Labels to add or overwrite before storing the result. :paramtype labels: dict[str, str] - :keyword annotations: annotations for rule group. Only relevant for alerts. + :keyword severity: The severity of the alerts fired by the rule. Must be between 0 and 4. + :paramtype severity: int + :keyword for_property: The amount of time alert must be active before firing. + :paramtype for_property: ~datetime.timedelta + :keyword annotations: The annotations clause specifies a set of informational labels that can + be used to store longer additional information such as alert descriptions or runbook links. The + annotation values can be templated. :paramtype annotations: dict[str, str] - :keyword actions: The array of actions that are performed when the alert rule becomes active, - and when an alert condition is resolved. Only relevant for alerts. + :keyword actions: Actions that are performed when the alert rule becomes active, and when an + alert condition is resolved. :paramtype actions: list[~azure.mgmt.alertsmanagement.models.PrometheusRuleGroupAction] - :keyword resolve_configuration: defines the configuration for resolving fired alerts. Only + :keyword resolve_configuration: Defines the configuration for resolving fired alerts. Only relevant for alerts. :paramtype resolve_configuration: ~azure.mgmt.alertsmanagement.models.PrometheusRuleResolveConfiguration @@ -1671,9 +1972,9 @@ def __init__( self.alert = alert self.enabled = enabled self.expression = expression + self.labels = labels self.severity = severity self.for_property = for_property - self.labels = labels self.annotations = annotations self.actions = actions self.resolve_configuration = resolve_configuration @@ -1694,8 +1995,12 @@ class PrometheusRuleGroupAction(_serialization.Model): } def __init__( - self, *, action_group_id: Optional[str] = None, action_properties: Optional[Dict[str, str]] = None, **kwargs - ): + self, + *, + action_group_id: Optional[str] = None, + action_properties: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: """ :keyword action_group_id: The resource id of the action group to use. :paramtype action_group_id: str @@ -1707,49 +2012,9 @@ def __init__( self.action_properties = action_properties -class ResourceAutoGenerated(_serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. 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.alertsmanagement.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): - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.system_data = None - - -class TrackedResource(ResourceAutoGenerated): - """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which + has 'tags' and a 'location'. Variables are only populated by the server, and will be ignored when sending a request. @@ -1789,7 +2054,7 @@ class TrackedResource(ResourceAutoGenerated): "location": {"key": "location", "type": "str"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -1823,19 +2088,19 @@ class PrometheusRuleGroupResource(TrackedResource): # pylint: disable=too-many- :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. :vartype location: str - :ivar description: the description of the Prometheus rule group that will be included in the - alert email. + :ivar description: Rule group description. :vartype description: str - :ivar enabled: the flag that indicates whether the Prometheus rule group is enabled. + :ivar enabled: Enable/disable rule group. :vartype enabled: bool - :ivar cluster_name: the cluster name of the rule group evaluation. + :ivar cluster_name: Apply rule to data from a specific cluster. :vartype cluster_name: str - :ivar scopes: the list of resource id's that this rule group is scoped to. Required. + :ivar scopes: Target Azure Monitor workspaces resource ids. This api-version is currently + limited to creating with one scope. This may change in future. Required. :vartype scopes: list[str] - :ivar interval: the interval in which to run the Prometheus rule group represented in ISO 8601 + :ivar interval: The interval in which to run the Prometheus rule group represented in ISO 8601 duration format. Should be between 1 and 15 minutes. - :vartype interval: str - :ivar rules: defines the rules in the Prometheus rule group. Required. + :vartype interval: ~datetime.timedelta + :ivar rules: Defines the rules in the Prometheus rule group. Required. :vartype rules: list[~azure.mgmt.alertsmanagement.models.PrometheusRule] """ @@ -1860,7 +2125,7 @@ class PrometheusRuleGroupResource(TrackedResource): # pylint: disable=too-many- "enabled": {"key": "properties.enabled", "type": "bool"}, "cluster_name": {"key": "properties.clusterName", "type": "str"}, "scopes": {"key": "properties.scopes", "type": "[str]"}, - "interval": {"key": "properties.interval", "type": "str"}, + "interval": {"key": "properties.interval", "type": "duration"}, "rules": {"key": "properties.rules", "type": "[PrometheusRule]"}, } @@ -1874,27 +2139,27 @@ def __init__( description: Optional[str] = None, enabled: Optional[bool] = None, cluster_name: Optional[str] = None, - interval: Optional[str] = None, - **kwargs - ): + interval: Optional[datetime.timedelta] = None, + **kwargs: Any + ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword location: The geo-location where the resource lives. Required. :paramtype location: str - :keyword description: the description of the Prometheus rule group that will be included in the - alert email. + :keyword description: Rule group description. :paramtype description: str - :keyword enabled: the flag that indicates whether the Prometheus rule group is enabled. + :keyword enabled: Enable/disable rule group. :paramtype enabled: bool - :keyword cluster_name: the cluster name of the rule group evaluation. + :keyword cluster_name: Apply rule to data from a specific cluster. :paramtype cluster_name: str - :keyword scopes: the list of resource id's that this rule group is scoped to. Required. + :keyword scopes: Target Azure Monitor workspaces resource ids. This api-version is currently + limited to creating with one scope. This may change in future. Required. :paramtype scopes: list[str] - :keyword interval: the interval in which to run the Prometheus rule group represented in ISO + :keyword interval: The interval in which to run the Prometheus rule group represented in ISO 8601 duration format. Should be between 1 and 15 minutes. - :paramtype interval: str - :keyword rules: defines the rules in the Prometheus rule group. Required. + :paramtype interval: ~datetime.timedelta + :keyword rules: Defines the rules in the Prometheus rule group. Required. :paramtype rules: list[~azure.mgmt.alertsmanagement.models.PrometheusRule] """ super().__init__(tags=tags, location=location, **kwargs) @@ -1917,7 +2182,7 @@ class PrometheusRuleGroupResourceCollection(_serialization.Model): "value": {"key": "value", "type": "[PrometheusRuleGroupResource]"}, } - def __init__(self, *, value: Optional[List["_models.PrometheusRuleGroupResource"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.PrometheusRuleGroupResource"]] = None, **kwargs: Any) -> None: """ :keyword value: the values for the alert rule resources. :paramtype value: list[~azure.mgmt.alertsmanagement.models.PrometheusRuleGroupResource] @@ -1926,84 +2191,58 @@ def __init__(self, *, value: Optional[List["_models.PrometheusRuleGroupResource" self.value = value -class PrometheusRuleGroupResourcePatch(_serialization.Model): +class PrometheusRuleGroupResourcePatchParameters(_serialization.Model): """The Prometheus rule group resource for patch operations. :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar properties: - :vartype properties: - ~azure.mgmt.alertsmanagement.models.PrometheusRuleGroupResourcePatchProperties + :ivar enabled: the flag that indicates whether the Prometheus rule group is enabled. + :vartype enabled: bool """ _attribute_map = { "tags": {"key": "tags", "type": "{str}"}, - "properties": {"key": "properties", "type": "PrometheusRuleGroupResourcePatchProperties"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - properties: Optional["_models.PrometheusRuleGroupResourcePatchProperties"] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: Optional[bool] = None, **kwargs: Any) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword properties: - :paramtype properties: - ~azure.mgmt.alertsmanagement.models.PrometheusRuleGroupResourcePatchProperties - """ - super().__init__(**kwargs) - self.tags = tags - self.properties = properties - - -class PrometheusRuleGroupResourcePatchProperties(_serialization.Model): - """PrometheusRuleGroupResourcePatchProperties. - - :ivar enabled: the flag that indicates whether the Prometheus rule group is enabled. - :vartype enabled: bool - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, **kwargs): - """ :keyword enabled: the flag that indicates whether the Prometheus rule group is enabled. :paramtype enabled: bool """ super().__init__(**kwargs) + self.tags = tags self.enabled = enabled class PrometheusRuleResolveConfiguration(_serialization.Model): """Specifies the Prometheus alert rule configuration. - :ivar auto_resolved: the flag that indicates whether or not to auto resolve a fired alert. + :ivar auto_resolved: Enable alert auto-resolution. :vartype auto_resolved: bool - :ivar time_to_resolve: the duration a rule must evaluate as healthy before the fired alert is - automatically resolved represented in ISO 8601 duration format. Should be between 1 and 15 - minutes. - :vartype time_to_resolve: str + :ivar time_to_resolve: Alert auto-resolution timeout. + :vartype time_to_resolve: ~datetime.timedelta """ _attribute_map = { "auto_resolved": {"key": "autoResolved", "type": "bool"}, - "time_to_resolve": {"key": "timeToResolve", "type": "str"}, + "time_to_resolve": {"key": "timeToResolve", "type": "duration"}, } - def __init__(self, *, auto_resolved: Optional[bool] = None, time_to_resolve: Optional[str] = None, **kwargs): + def __init__( + self, + *, + auto_resolved: Optional[bool] = None, + time_to_resolve: Optional[datetime.timedelta] = None, + **kwargs: Any + ) -> None: """ - :keyword auto_resolved: the flag that indicates whether or not to auto resolve a fired alert. + :keyword auto_resolved: Enable alert auto-resolution. :paramtype auto_resolved: bool - :keyword time_to_resolve: the duration a rule must evaluate as healthy before the fired alert - is automatically resolved represented in ISO 8601 duration format. Should be between 1 and 15 - minutes. - :paramtype time_to_resolve: str + :keyword time_to_resolve: Alert auto-resolution timeout. + :paramtype time_to_resolve: ~datetime.timedelta """ super().__init__(**kwargs) self.auto_resolved = auto_resolved @@ -2015,8 +2254,8 @@ class RemoveAllActionGroups(Action): All required parameters must be populated in order to send to Azure. - :ivar action_type: Action that should be applied. Required. Known values are: "AddActionGroups" - and "RemoveAllActionGroups". + :ivar action_type: Action that should be applied. Required. Known values are: + "AddActionGroups", "RemoveAllActionGroups", and "CorrelateAlerts". :vartype action_type: str or ~azure.mgmt.alertsmanagement.models.ActionType """ @@ -2028,12 +2267,77 @@ class RemoveAllActionGroups(Action): "action_type": {"key": "actionType", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.action_type: str = "RemoveAllActionGroups" +class RuleArmTemplate(_serialization.Model): + """A complete ARM template to deploy the alert rules. + + All required parameters must be populated in order to send to Azure. + + :ivar schema: JSON schema reference. Required. + :vartype schema: str + :ivar content_version: A 4 number format for the version number of this template file. For + example, 1.0.0.0. Required. + :vartype content_version: str + :ivar variables: Variable definitions. Required. + :vartype variables: JSON + :ivar parameters: Input parameter definitions. Required. + :vartype parameters: JSON + :ivar resources: Alert rule resource definitions. Required. + :vartype resources: list[JSON] + """ + + _validation = { + "schema": {"required": True}, + "content_version": {"required": True, "pattern": r"(^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$)"}, + "variables": {"required": True}, + "parameters": {"required": True}, + "resources": {"required": True}, + } + + _attribute_map = { + "schema": {"key": "$schema", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, + "variables": {"key": "variables", "type": "object"}, + "parameters": {"key": "parameters", "type": "object"}, + "resources": {"key": "resources", "type": "[object]"}, + } + + def __init__( + self, + *, + schema: str, + content_version: str, + variables: JSON, + parameters: JSON, + resources: List[JSON], + **kwargs: Any + ) -> None: + """ + :keyword schema: JSON schema reference. Required. + :paramtype schema: str + :keyword content_version: A 4 number format for the version number of this template file. For + example, 1.0.0.0. Required. + :paramtype content_version: str + :keyword variables: Variable definitions. Required. + :paramtype variables: JSON + :keyword parameters: Input parameter definitions. Required. + :paramtype parameters: JSON + :keyword resources: Alert rule resource definitions. Required. + :paramtype resources: list[JSON] + """ + super().__init__(**kwargs) + self.schema = schema + self.content_version = content_version + self.variables = variables + self.parameters = parameters + self.resources = resources + + class Schedule(_serialization.Model): """Scheduling configuration for a given alert processing rule. @@ -2068,8 +2372,8 @@ def __init__( effective_until: Optional[str] = None, time_zone: Optional[str] = None, recurrences: Optional[List["_models.Recurrence"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword effective_from: Scheduling effective from time. Date-Time in ISO-8601 format without timezone suffix. @@ -2089,7 +2393,7 @@ def __init__( self.recurrences = recurrences -class SmartGroup(Resource): # pylint: disable=too-many-instance-attributes +class SmartGroup(ResourceAutoGenerated): # pylint: disable=too-many-instance-attributes """Set of related alerts grouped together smartly by AMS. Variables are only populated by the server, and will be ignored when sending a request. @@ -2180,8 +2484,8 @@ def __init__( alert_states: Optional[List["_models.SmartGroupAggregatedProperty"]] = None, alert_severities: Optional[List["_models.SmartGroupAggregatedProperty"]] = None, next_link: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword alerts_count: Total number of alerts in smart group. :paramtype alerts_count: int @@ -2239,7 +2543,7 @@ class SmartGroupAggregatedProperty(_serialization.Model): "count": {"key": "count", "type": "int"}, } - def __init__(self, *, name: Optional[str] = None, count: Optional[int] = None, **kwargs): + def __init__(self, *, name: Optional[str] = None, count: Optional[int] = None, **kwargs: Any) -> None: """ :keyword name: Name of the type. :paramtype name: str @@ -2251,7 +2555,7 @@ def __init__(self, *, name: Optional[str] = None, count: Optional[int] = None, * self.count = count -class SmartGroupModification(Resource): +class SmartGroupModification(ResourceAutoGenerated): """Alert Modification details. Variables are only populated by the server, and will be ignored when sending a request. @@ -2279,7 +2583,9 @@ class SmartGroupModification(Resource): "properties": {"key": "properties", "type": "SmartGroupModificationProperties"}, } - def __init__(self, *, properties: Optional["_models.SmartGroupModificationProperties"] = None, **kwargs): + def __init__( + self, *, properties: Optional["_models.SmartGroupModificationProperties"] = None, **kwargs: Any + ) -> None: """ :keyword properties: Properties of the smartGroup modification item. :paramtype properties: ~azure.mgmt.alertsmanagement.models.SmartGroupModificationProperties @@ -2329,8 +2635,8 @@ def __init__( modified_by: Optional[str] = None, comments: Optional[str] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword modification_event: Reason for the modification. Known values are: "SmartGroupCreated", "StateChange", "AlertAdded", and "AlertRemoved". @@ -2387,8 +2693,8 @@ def __init__( *, modifications: Optional[List["_models.SmartGroupModificationItem"]] = None, next_link: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword modifications: Modification details. :paramtype modifications: list[~azure.mgmt.alertsmanagement.models.SmartGroupModificationItem] @@ -2416,8 +2722,8 @@ class SmartGroupsList(_serialization.Model): } def __init__( - self, *, next_link: Optional[str] = None, value: Optional[List["_models.SmartGroup"]] = None, **kwargs - ): + self, *, next_link: Optional[str] = None, value: Optional[List["_models.SmartGroup"]] = None, **kwargs: Any + ) -> None: """ :keyword next_link: URL to fetch the next set of alerts. :paramtype next_link: str @@ -2466,8 +2772,8 @@ def __init__( last_modified_by: Optional[str] = None, last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword created_by: The identity that created the resource. :paramtype created_by: str @@ -2527,8 +2833,8 @@ def __init__( days_of_week: List[Union[str, "_models.DaysOfWeek"]], start_time: Optional[str] = None, end_time: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword start_time: Start time for recurrence. :paramtype start_time: str diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/__init__.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/__init__.py index c8dd1e48dcf0..bab3e18425ab 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/__init__.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/__init__.py @@ -6,22 +6,24 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._alert_processing_rules_operations import AlertProcessingRulesOperations from ._prometheus_rule_groups_operations import PrometheusRuleGroupsOperations from ._operations import Operations from ._alerts_operations import AlertsOperations from ._smart_groups_operations import SmartGroupsOperations +from ._alert_rule_recommendations_operations import AlertRuleRecommendationsOperations +from ._alert_processing_rules_operations import AlertProcessingRulesOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ - "AlertProcessingRulesOperations", "PrometheusRuleGroupsOperations", "Operations", "AlertsOperations", "SmartGroupsOperations", + "AlertRuleRecommendationsOperations", + "AlertProcessingRulesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_alert_processing_rules_operations.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_alert_processing_rules_operations.py index a9831118284f..1a86eee16e2e 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_alert_processing_rules_operations.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_alert_processing_rules_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +40,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +66,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -100,7 +96,7 @@ def build_get_by_name_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -131,7 +127,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -165,7 +161,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -196,7 +192,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -255,7 +251,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AlertProcessi _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) cls: ClsType[_models.AlertProcessingRulesList] = kwargs.pop("cls", None) error_map = { @@ -296,14 +292,15 @@ def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated3, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -330,7 +327,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) cls: ClsType[_models.AlertProcessingRulesList] = kwargs.pop("cls", None) error_map = { @@ -372,14 +369,15 @@ def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated3, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -417,7 +415,7 @@ def get_by_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) cls: ClsType[_models.AlertProcessingRule] = kwargs.pop("cls", None) request = build_get_by_name_request( @@ -432,15 +430,16 @@ def get_by_name( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated3, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -528,8 +527,8 @@ def create_or_update( :param alert_processing_rule_name: The name of the alert processing rule that needs to be created/updated. Required. :type alert_processing_rule_name: str - :param alert_processing_rule: Alert processing rule to be created/updated. Is either a model - type or a IO type. Required. + :param alert_processing_rule: Alert processing rule to be created/updated. Is either a + AlertProcessingRule type or a IO type. Required. :type alert_processing_rule: ~azure.mgmt.alertsmanagement.models.AlertProcessingRule or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -550,14 +549,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AlertProcessingRule] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(alert_processing_rule, (IO, bytes)): + if isinstance(alert_processing_rule, (IOBase, bytes)): _content = alert_processing_rule else: _json = self._serialize.body(alert_processing_rule, "AlertProcessingRule") @@ -577,15 +576,16 @@ def create_or_update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated3, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -635,7 +635,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -650,15 +650,16 @@ def delete( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated3, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -743,8 +744,8 @@ def update( :type resource_group_name: str :param alert_processing_rule_name: The name that needs to be updated. Required. :type alert_processing_rule_name: str - :param alert_processing_rule_patch: Parameters supplied to the operation. Is either a model - type or a IO type. Required. + :param alert_processing_rule_patch: Parameters supplied to the operation. Is either a + PatchObject type or a IO type. Required. :type alert_processing_rule_patch: ~azure.mgmt.alertsmanagement.models.PatchObject or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -765,14 +766,14 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-08-08"] = kwargs.pop("api_version", _params.pop("api-version", "2021-08-08")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AlertProcessingRule] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(alert_processing_rule_patch, (IO, bytes)): + if isinstance(alert_processing_rule_patch, (IOBase, bytes)): _content = alert_processing_rule_patch else: _json = self._serialize.body(alert_processing_rule_patch, "PatchObject") @@ -792,15 +793,16 @@ def update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated3, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_alert_rule_recommendations_operations.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_alert_rule_recommendations_operations.py new file mode 100644 index 000000000000..52484b4ad12d --- /dev/null +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_alert_rule_recommendations_operations.py @@ -0,0 +1,255 @@ +# 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 + +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, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_resource_request(resource_uri: 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-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.AlertsManagement/alertRuleRecommendations") + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_target_type_request(subscription_id: str, *, target_type: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alertRuleRecommendations" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["targetType"] = _SERIALIZER.query("target_type", target_type, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class AlertRuleRecommendationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.alertsmanagement.AlertsManagementClient`'s + :attr:`alert_rule_recommendations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_resource(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.AlertRuleRecommendationResource"]: + """Retrieve alert rule recommendations for a resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AlertRuleRecommendationResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.alertsmanagement.models.AlertRuleRecommendationResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01-preview")) + cls: ClsType[_models.AlertRuleRecommendationsListResponse] = 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_request( + resource_uri=resource_uri, + api_version=api_version, + template_url=self.list_by_resource.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AlertRuleRecommendationsListResponse", 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.metadata = {"url": "/{resourceUri}/providers/Microsoft.AlertsManagement/alertRuleRecommendations"} + + @distributed_trace + def list_by_target_type(self, **kwargs: Any) -> Iterable["_models.AlertRuleRecommendationResource"]: + """Retrieve alert rule recommendations for a target type. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AlertRuleRecommendationResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.alertsmanagement.models.AlertRuleRecommendationResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01-preview")) + cls: ClsType[_models.AlertRuleRecommendationsListResponse] = 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_target_type_request( + subscription_id=self._config.subscription_id, + target_type=self._config.target_type, + api_version=api_version, + template_url=self.list_by_target_type.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AlertRuleRecommendationsListResponse", 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_target_type.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alertRuleRecommendations" + } diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_alerts_operations.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_alerts_operations.py index f4835f11fa5b..fd101123a317 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_alerts_operations.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_alerts_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,9 +40,7 @@ def build_meta_data_request(*, identifier: Union[str, _models.Identifier], **kwa _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -87,9 +81,7 @@ def build_get_all_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -147,9 +139,7 @@ def build_get_by_id_request(alert_id: str, subscription_id: str, **kwargs: Any) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -178,9 +168,7 @@ def build_change_state_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -212,9 +200,7 @@ def build_get_history_request(alert_id: str, subscription_id: str, **kwargs: Any _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -257,9 +243,7 @@ def build_get_summary_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -348,9 +332,7 @@ def meta_data(self, identifier: Union[str, _models.Identifier], **kwargs: Any) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) cls: ClsType[_models.AlertsMetaData] = kwargs.pop("cls", None) request = build_meta_data_request( @@ -363,15 +345,16 @@ def meta_data(self, identifier: Union[str, _models.Identifier], **kwargs: Any) - request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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.ErrorResponseAutoGenerated2, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AlertsMetaData", pipeline_response) @@ -480,9 +463,7 @@ def get_all( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) cls: ClsType[_models.AlertsList] = kwargs.pop("cls", None) error_map = { @@ -540,14 +521,15 @@ def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -580,9 +562,7 @@ def get_by_id(self, alert_id: str, **kwargs: Any) -> _models.Alert: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) cls: ClsType[_models.Alert] = kwargs.pop("cls", None) request = build_get_by_id_request( @@ -596,15 +576,16 @@ def get_by_id(self, alert_id: str, **kwargs: Any) -> _models.Alert: request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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.ErrorResponseAutoGenerated2, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("Alert", pipeline_response) @@ -689,7 +670,7 @@ def change_state( :param new_state: New state of the alert. Known values are: "New", "Acknowledged", and "Closed". Required. :type new_state: str or ~azure.mgmt.alertsmanagement.models.AlertState - :param comment: reason of change alert state. Is either a model type or a IO type. Default + :param comment: reason of change alert state. Is either a Comments type or a IO type. Default value is None. :type comment: ~azure.mgmt.alertsmanagement.models.Comments or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -711,16 +692,14 @@ def change_state( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Alert] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(comment, (IO, bytes)): + if isinstance(comment, (IOBase, bytes)): _content = comment else: if comment is not None: @@ -743,15 +722,16 @@ def change_state( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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.ErrorResponseAutoGenerated2, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("Alert", pipeline_response) @@ -788,9 +768,7 @@ def get_history(self, alert_id: str, **kwargs: Any) -> _models.AlertModification _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) cls: ClsType[_models.AlertModification] = kwargs.pop("cls", None) request = build_get_history_request( @@ -804,15 +782,16 @@ def get_history(self, alert_id: str, **kwargs: Any) -> _models.AlertModification request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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.ErrorResponseAutoGenerated2, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AlertModification", pipeline_response) @@ -906,9 +885,7 @@ def get_summary( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) cls: ClsType[_models.AlertsSummary] = kwargs.pop("cls", None) request = build_get_summary_request( @@ -933,15 +910,16 @@ def get_summary( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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.ErrorResponseAutoGenerated2, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AlertsSummary", pipeline_response) diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_operations.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_operations.py index a607bf0f4a25..e4f77478cdcf 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_operations.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar from azure.core.exceptions import ( @@ -29,10 +28,6 @@ from .._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,9 +39,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -92,9 +85,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) cls: ClsType[_models.OperationsList] = kwargs.pop("cls", None) error_map = { @@ -134,14 +125,15 @@ def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_prometheus_rule_groups_operations.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_prometheus_rule_groups_operations.py index 02a44a95f241..492792f23a22 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_prometheus_rule_groups_operations.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_prometheus_rule_groups_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,9 +40,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-22-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-07-22-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,9 +66,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-22-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-07-22-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -106,9 +98,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-22-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-07-22-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -121,7 +111,7 @@ def build_get_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "ruleGroupName": _SERIALIZER.url("rule_group_name", rule_group_name, "str"), + "ruleGroupName": _SERIALIZER.url("rule_group_name", rule_group_name, "str", pattern=r"^[^:@/#{}%&+*<>?]+$"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore @@ -141,9 +131,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-22-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-07-22-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -157,7 +145,7 @@ def build_create_or_update_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "ruleGroupName": _SERIALIZER.url("rule_group_name", rule_group_name, "str"), + "ruleGroupName": _SERIALIZER.url("rule_group_name", rule_group_name, "str", pattern=r"^[^:@/#{}%&+*<>?]+$"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore @@ -179,9 +167,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-22-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-07-22-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -195,7 +181,7 @@ def build_update_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "ruleGroupName": _SERIALIZER.url("rule_group_name", rule_group_name, "str"), + "ruleGroupName": _SERIALIZER.url("rule_group_name", rule_group_name, "str", pattern=r"^[^:@/#{}%&+*<>?]+$"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore @@ -217,9 +203,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-22-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-07-22-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -232,7 +216,7 @@ def build_delete_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "ruleGroupName": _SERIALIZER.url("rule_group_name", rule_group_name, "str"), + "ruleGroupName": _SERIALIZER.url("rule_group_name", rule_group_name, "str", pattern=r"^[^:@/#{}%&+*<>?]+$"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore @@ -267,7 +251,7 @@ def __init__(self, *args, **kwargs): @distributed_trace def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.PrometheusRuleGroupResource"]: - """Retrieve Prometheus rule group definitions in a subscription. + """Retrieve Prometheus all rule group definitions in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrometheusRuleGroupResource or the result of @@ -279,9 +263,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.PrometheusRul _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-22-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-07-22-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) cls: ClsType[_models.PrometheusRuleGroupResourceCollection] = kwargs.pop("cls", None) error_map = { @@ -322,14 +304,15 @@ def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -359,9 +342,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-22-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-07-22-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) cls: ClsType[_models.PrometheusRuleGroupResourceCollection] = kwargs.pop("cls", None) error_map = { @@ -403,14 +384,15 @@ def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -446,9 +428,7 @@ def get(self, resource_group_name: str, rule_group_name: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-22-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-07-22-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) cls: ClsType[_models.PrometheusRuleGroupResource] = kwargs.pop("cls", None) request = build_get_request( @@ -463,15 +443,16 @@ def get(self, resource_group_name: str, rule_group_name: str, **kwargs: Any) -> request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("PrometheusRuleGroupResource", pipeline_response) @@ -556,8 +537,8 @@ def create_or_update( :type resource_group_name: str :param rule_group_name: The name of the rule group. Required. :type rule_group_name: str - :param parameters: The parameters of the rule group to create or update. Is either a model type - or a IO type. Required. + :param parameters: The parameters of the rule group to create or update. Is either a + PrometheusRuleGroupResource type or a IO type. Required. :type parameters: ~azure.mgmt.alertsmanagement.models.PrometheusRuleGroupResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -578,16 +559,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-22-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-07-22-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrometheusRuleGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "PrometheusRuleGroupResource") @@ -607,15 +586,16 @@ def create_or_update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -638,7 +618,7 @@ def update( self, resource_group_name: str, rule_group_name: str, - parameters: _models.PrometheusRuleGroupResourcePatch, + parameters: _models.PrometheusRuleGroupResourcePatchParameters, *, content_type: str = "application/json", **kwargs: Any @@ -651,7 +631,8 @@ def update( :param rule_group_name: The name of the rule group. Required. :type rule_group_name: str :param parameters: The parameters of the rule group to update. Required. - :type parameters: ~azure.mgmt.alertsmanagement.models.PrometheusRuleGroupResourcePatch + :type parameters: + ~azure.mgmt.alertsmanagement.models.PrometheusRuleGroupResourcePatchParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -694,7 +675,7 @@ def update( self, resource_group_name: str, rule_group_name: str, - parameters: Union[_models.PrometheusRuleGroupResourcePatch, IO], + parameters: Union[_models.PrometheusRuleGroupResourcePatchParameters, IO], **kwargs: Any ) -> _models.PrometheusRuleGroupResource: """Update an Prometheus rule group definition. @@ -704,9 +685,10 @@ def update( :type resource_group_name: str :param rule_group_name: The name of the rule group. Required. :type rule_group_name: str - :param parameters: The parameters of the rule group to update. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.alertsmanagement.models.PrometheusRuleGroupResourcePatch or IO + :param parameters: The parameters of the rule group to update. Is either a + PrometheusRuleGroupResourcePatchParameters type or a IO type. Required. + :type parameters: + ~azure.mgmt.alertsmanagement.models.PrometheusRuleGroupResourcePatchParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str @@ -726,19 +708,17 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-22-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-07-22-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrometheusRuleGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "PrometheusRuleGroupResourcePatch") + _json = self._serialize.body(parameters, "PrometheusRuleGroupResourcePatchParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -755,15 +735,16 @@ def update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("PrometheusRuleGroupResource", pipeline_response) @@ -804,9 +785,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-22-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-07-22-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -821,15 +800,16 @@ def delete( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_smart_groups_operations.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_smart_groups_operations.py index cdb08c4cc687..fdae58a9edc7 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_smart_groups_operations.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_smart_groups_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union from azure.core.exceptions import ( @@ -29,10 +28,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -59,9 +54,7 @@ def build_get_all_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -109,9 +102,7 @@ def build_get_by_id_request(smart_group_id: str, subscription_id: str, **kwargs: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -141,9 +132,7 @@ def build_change_state_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -172,9 +161,7 @@ def build_get_history_request(smart_group_id: str, subscription_id: str, **kwarg _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -285,9 +272,7 @@ def get_all( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) cls: ClsType[_models.SmartGroupsList] = kwargs.pop("cls", None) error_map = { @@ -339,14 +324,15 @@ def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated3, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -379,9 +365,7 @@ def get_by_id(self, smart_group_id: str, **kwargs: Any) -> _models.SmartGroup: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) cls: ClsType[_models.SmartGroup] = kwargs.pop("cls", None) request = build_get_by_id_request( @@ -395,15 +379,16 @@ def get_by_id(self, smart_group_id: str, **kwargs: Any) -> _models.SmartGroup: request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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.ErrorResponseAutoGenerated3, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -447,9 +432,7 @@ def change_state( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) cls: ClsType[_models.SmartGroup] = kwargs.pop("cls", None) request = build_change_state_request( @@ -464,15 +447,16 @@ def change_state( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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.ErrorResponseAutoGenerated3, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -512,9 +496,7 @@ def get_history(self, smart_group_id: str, **kwargs: Any) -> _models.SmartGroupM _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-05-05-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-05-05-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-05-05-preview")) cls: ClsType[_models.SmartGroupModification] = kwargs.pop("cls", None) request = build_get_history_request( @@ -528,15 +510,16 @@ def get_history(self, smart_group_id: str, **kwargs: Any) -> _models.SmartGroupM request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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.ErrorResponseAutoGenerated3, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("SmartGroupModification", pipeline_response) diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_add_action_group_all_alerts_in_subscription.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_add_action_group_all_alerts_in_subscription.py index 16c15fa80e42..adf99d932ae7 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_add_action_group_all_alerts_in_subscription.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_add_action_group_all_alerts_in_subscription.py @@ -26,6 +26,7 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), + target_type="TARGET_TYPE", subscription_id="subId1", ) @@ -53,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_Create_or_update_add_action_group_all_alerts_in_subscription.json +# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-05-01-preview/examples/AlertProcessingRules_Create_or_update_add_action_group_all_alerts_in_subscription.json if __name__ == "__main__": main() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_add_correlation.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_add_correlation.py new file mode 100644 index 000000000000..655e46a8bc4d --- /dev/null +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_add_correlation.py @@ -0,0 +1,60 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.alertsmanagement import AlertsManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-alertsmanagement +# USAGE + python alert_processing_rules_create_or_update_add_correlation.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AlertsManagementClient( + credential=DefaultAzureCredential(), + target_type="TARGET_TYPE", + subscription_id="subId1", + ) + + response = client.alert_processing_rules.create_or_update( + resource_group_name="alertscorrelationrg", + alert_processing_rule_name="CorrelateAlerts", + alert_processing_rule={ + "location": "Global", + "properties": { + "actions": [ + { + "actionType": "CorrelateAlerts", + "correlateBy": [{"field": "essentials.alertRule"}], + "correlationInterval": "00:30:00", + "notificationsForCorrelatedAlerts": "SuppressAlways", + "priority": 50, + } + ], + "description": "Correlate Alerts Example.", + "enabled": True, + "scopes": ["/subscriptions/subId1"], + }, + "tags": {}, + }, + ) + print(response) + + +# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-05-01-preview/examples/AlertProcessingRules_Create_or_update_add_correlation.json +if __name__ == "__main__": + main() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_add_two_action_groups_all_sev0_sev1_two_resource_groups.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_add_two_action_groups_all_sev0_sev1_two_resource_groups.py index 301a8f60c27c..69044abdf788 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_add_two_action_groups_all_sev0_sev1_two_resource_groups.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_add_two_action_groups_all_sev0_sev1_two_resource_groups.py @@ -26,6 +26,7 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), + target_type="TARGET_TYPE", subscription_id="subId1", ) @@ -55,6 +56,6 @@ def main(): print(response) -# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_Create_or_update_add_two_action_groups_all_Sev0_Sev1_two_resource_groups.json +# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-05-01-preview/examples/AlertProcessingRules_Create_or_update_add_two_action_groups_all_Sev0_Sev1_two_resource_groups.json if __name__ == "__main__": main() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_remove_all_action_groups_from_specific_alert_rule.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_remove_all_action_groups_from_specific_alert_rule.py index 96a81089ab2d..a1caf1b4136b 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_remove_all_action_groups_from_specific_alert_rule.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_remove_all_action_groups_from_specific_alert_rule.py @@ -26,6 +26,7 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), + target_type="TARGET_TYPE", subscription_id="subId1", ) @@ -55,6 +56,6 @@ def main(): print(response) -# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_Create_or_update_remove_all_action_groups_from_specific_alert_rule.json +# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-05-01-preview/examples/AlertProcessingRules_Create_or_update_remove_all_action_groups_from_specific_alert_rule.json if __name__ == "__main__": main() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_remove_all_action_groups_outside_business_hours.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_remove_all_action_groups_outside_business_hours.py index 732b8a5157a9..6bd9f8e2ef91 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_remove_all_action_groups_outside_business_hours.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_remove_all_action_groups_outside_business_hours.py @@ -26,6 +26,7 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), + target_type="TARGET_TYPE", subscription_id="subId1", ) @@ -53,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_Create_or_update_remove_all_action_groups_outside_business_hours.json +# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-05-01-preview/examples/AlertProcessingRules_Create_or_update_remove_all_action_groups_outside_business_hours.json if __name__ == "__main__": main() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_remove_all_action_groups_recurring_maintenance_window.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_remove_all_action_groups_recurring_maintenance_window.py index 2b2df653a6b8..36c929bbbfa9 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_remove_all_action_groups_recurring_maintenance_window.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_remove_all_action_groups_recurring_maintenance_window.py @@ -26,6 +26,7 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), + target_type="TARGET_TYPE", subscription_id="subId1", ) @@ -64,6 +65,6 @@ def main(): print(response) -# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_Create_or_update_remove_all_action_groups_recurring_maintenance_window.json +# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-05-01-preview/examples/AlertProcessingRules_Create_or_update_remove_all_action_groups_recurring_maintenance_window.json if __name__ == "__main__": main() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_remove_all_action_groups_specific_vm_oneoff_maintenance_window.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_remove_all_action_groups_specific_vm_oneoff_maintenance_window.py index 727053369ddf..cbe532ad0d99 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_remove_all_action_groups_specific_vm_oneoff_maintenance_window.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_create_or_update_remove_all_action_groups_specific_vm_oneoff_maintenance_window.py @@ -26,6 +26,7 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), + target_type="TARGET_TYPE", subscription_id="subId1", ) @@ -53,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_Create_or_update_remove_all_action_groups_specific_VM_one-off_maintenance_window.json +# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-05-01-preview/examples/AlertProcessingRules_Create_or_update_remove_all_action_groups_specific_VM_one-off_maintenance_window.json if __name__ == "__main__": main() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_delete.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_delete.py index da1035a3ed6b..06583b9abb71 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_delete.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_delete.py @@ -26,16 +26,16 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), + target_type="TARGET_TYPE", subscription_id="1e3ff1c0-771a-4119-a03b-be82a51e232d", ) - response = client.alert_processing_rules.delete( + client.alert_processing_rules.delete( resource_group_name="alertscorrelationrg", alert_processing_rule_name="DailySuppression", ) - print(response) -# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_Delete.json +# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-05-01-preview/examples/AlertProcessingRules_Delete.json if __name__ == "__main__": main() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_get_by_id.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_get_by_id.py index 6e58d707a946..73392695a21f 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_get_by_id.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_get_by_id.py @@ -26,6 +26,7 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), + target_type="TARGET_TYPE", subscription_id="1e3ff1c0-771a-4119-a03b-be82a51e232d", ) @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_GetById.json +# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-05-01-preview/examples/AlertProcessingRules_GetById.json if __name__ == "__main__": main() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_list_resource_group.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_list_resource_group.py index df87df4c57e9..8a7d09d95b22 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_list_resource_group.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_list_resource_group.py @@ -26,6 +26,7 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), + target_type="TARGET_TYPE", subscription_id="1e3ff1c0-771a-4119-a03b-be82a51e232d", ) @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_List_ResourceGroup.json +# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-05-01-preview/examples/AlertProcessingRules_List_ResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_list_subscription.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_list_subscription.py index f60030923c9a..01b80cb60fbd 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_list_subscription.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_list_subscription.py @@ -26,6 +26,7 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), + target_type="TARGET_TYPE", subscription_id="1e3ff1c0-771a-4119-a03b-be82a51e232d", ) @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_List_Subscription.json +# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-05-01-preview/examples/AlertProcessingRules_List_Subscription.json if __name__ == "__main__": main() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_patch.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_patch.py index 8e49a347b9b0..0dfa7c2ec3c6 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_patch.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_processing_rules_patch.py @@ -26,6 +26,7 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), + target_type="TARGET_TYPE", subscription_id="1e3ff1c0-771a-4119-a03b-be82a51e232d", ) @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_Patch.json +# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-05-01-preview/examples/AlertProcessingRules_Patch.json if __name__ == "__main__": main() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_rule_recommendations_get_by_resource_mac.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_rule_recommendations_get_by_resource_mac.py new file mode 100644 index 000000000000..55d9bcea7c94 --- /dev/null +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_rule_recommendations_get_by_resource_mac.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.alertsmanagement import AlertsManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-alertsmanagement +# USAGE + python alert_rule_recommendations_get_by_resource_mac.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AlertsManagementClient( + credential=DefaultAzureCredential(), + target_type="TARGET_TYPE", + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.alert_rule_recommendations.list_by_resource( + resource_uri="subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/examples/AlertRuleRecommendations_GetByResource_MAC.json +if __name__ == "__main__": + main() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_rule_recommendations_get_by_resource_vm.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_rule_recommendations_get_by_resource_vm.py new file mode 100644 index 000000000000..b3e7494047d7 --- /dev/null +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_rule_recommendations_get_by_resource_vm.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.alertsmanagement import AlertsManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-alertsmanagement +# USAGE + python alert_rule_recommendations_get_by_resource_vm.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AlertsManagementClient( + credential=DefaultAzureCredential(), + target_type="TARGET_TYPE", + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.alert_rule_recommendations.list_by_resource( + resource_uri="subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourcegroups/test/providers/Microsoft.Compute/virtualMachines/testMachineCanBeSafelyDeleted", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/examples/AlertRuleRecommendations_GetByResource_VM.json +if __name__ == "__main__": + main() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_rule_recommendations_get_by_subscription_mac.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_rule_recommendations_get_by_subscription_mac.py new file mode 100644 index 000000000000..f1dd0fd8d7a6 --- /dev/null +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_rule_recommendations_get_by_subscription_mac.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.alertsmanagement import AlertsManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-alertsmanagement +# USAGE + python alert_rule_recommendations_get_by_subscription_mac.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AlertsManagementClient( + credential=DefaultAzureCredential(), + target_type="microsoft.monitor/accounts", + subscription_id="2f00cc51-6809-498f-9ffc-48c42aff570d", + ) + + response = client.alert_rule_recommendations.list_by_target_type() + for item in response: + print(item) + + +# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/examples/AlertRuleRecommendations_GetBySubscription_MAC.json +if __name__ == "__main__": + main() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_rule_recommendations_get_by_subscription_vm.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_rule_recommendations_get_by_subscription_vm.py new file mode 100644 index 000000000000..a572caaaf943 --- /dev/null +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alert_rule_recommendations_get_by_subscription_vm.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.alertsmanagement import AlertsManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-alertsmanagement +# USAGE + python alert_rule_recommendations_get_by_subscription_vm.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AlertsManagementClient( + credential=DefaultAzureCredential(), + target_type="microsoft.compute/virtualmachines", + subscription_id="2f00cc51-6809-498f-9ffc-48c42aff570d", + ) + + response = client.alert_rule_recommendations.list_by_target_type() + for item in response: + print(item) + + +# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/examples/AlertRuleRecommendations_GetBySubscription_VM.json +if __name__ == "__main__": + main() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alerts_change_state.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alerts_change_state.py index 97ce6575b964..2e1c514991bb 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alerts_change_state.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alerts_change_state.py @@ -26,6 +26,7 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), + target_type="TARGET_TYPE", subscription_id="9e261de7-c804-4b9d-9ebf-6f50fe350a9a", ) diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alerts_get_by_id.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alerts_get_by_id.py index e4be181c404e..f9c0e2847b1b 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alerts_get_by_id.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alerts_get_by_id.py @@ -26,6 +26,7 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), + target_type="TARGET_TYPE", subscription_id="9e261de7-c804-4b9d-9ebf-6f50fe350a9a", ) diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alerts_history.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alerts_history.py index 3d11c9aa1d13..10ee1fdd9a29 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alerts_history.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alerts_history.py @@ -26,6 +26,7 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), + target_type="TARGET_TYPE", subscription_id="9e261de7-c804-4b9d-9ebf-6f50fe350a9a", ) diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alerts_list.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alerts_list.py index 1aad26234d85..6387c48cb60f 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alerts_list.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alerts_list.py @@ -26,6 +26,7 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), + target_type="TARGET_TYPE", subscription_id="1e3ff1c0-771a-4119-a03b-be82a51e232d", ) diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alerts_meta_data_monitor_service.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alerts_meta_data_monitor_service.py index 035559a1bbc3..257f8ce4ff68 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alerts_meta_data_monitor_service.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alerts_meta_data_monitor_service.py @@ -26,6 +26,7 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), + target_type="TARGET_TYPE", subscription_id="SUBSCRIPTION_ID", ) diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alerts_summary.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alerts_summary.py index 8794d5a0df8d..a57de9c7f241 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alerts_summary.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/alerts_summary.py @@ -26,6 +26,7 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), + target_type="TARGET_TYPE", subscription_id="1e3ff1c0-771a-4119-a03b-be82a51e232d", ) diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/create_or_update_prometheus_rule_group.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/create_or_update_prometheus_rule_group.py index 98dab269a300..7fdb8ae4944d 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/create_or_update_prometheus_rule_group.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/create_or_update_prometheus_rule_group.py @@ -26,16 +26,20 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), - subscription_id="14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", + target_type="TARGET_TYPE", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.prometheus_rule_groups.create_or_update( - resource_group_name="giladstest", + resource_group_name="promResourceGroup", rule_group_name="myPrometheusRuleGroup", parameters={ "location": "East US", "properties": { - "description": "This is the description of the first rule group", + "clusterName": "myClusterName", + "description": "This is the description of the following rule group", + "enabled": True, + "interval": "PT10M", "rules": [ { "expression": 'histogram_quantile(0.99, sum(rate(jobs_duration_seconds_bucket{service="billing-processing"}[5m])) by (job_type))', @@ -45,12 +49,17 @@ def main(): { "actions": [ { - "actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/giladstest/providers/microsoft.insights/notificationgroups/group2", + "actionGroupId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/myrg/providers/microsoft.insights/actiongroups/myactiongroup", "actionProperties": {"key11": "value11", "key12": "value12"}, - } + }, + { + "actionGroupId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/myrg/providers/microsoft.insights/actiongroups/myotheractiongroup", + "actionProperties": {"key21": "value21", "key22": "value22"}, + }, ], "alert": "Billing_Processing_Very_Slow", "annotations": {"annotationName1": "annotationValue1"}, + "enabled": True, "expression": "job_type:billing_jobs_duration_seconds:99p5m > 30", "for": "PT5M", "labels": {"team": "prod"}, @@ -59,7 +68,7 @@ def main(): }, ], "scopes": [ - "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/giladstest/providers/microsoft.monitor/accounts/myMonitoringAccount" + "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace" ], }, }, @@ -67,6 +76,6 @@ def main(): print(response) -# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2021-07-22-preview/examples/createOrUpdatePrometheusRuleGroup.json +# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2023-03-01/examples/createOrUpdatePrometheusRuleGroup.json if __name__ == "__main__": main() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/delete_prometheus_rule_group.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/delete_prometheus_rule_group.py index 0c233d48f753..4777b1ae996c 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/delete_prometheus_rule_group.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/delete_prometheus_rule_group.py @@ -26,16 +26,16 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), - subscription_id="14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", + target_type="TARGET_TYPE", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) - response = client.prometheus_rule_groups.delete( - resource_group_name="giladsteset", + client.prometheus_rule_groups.delete( + resource_group_name="promResourceGroup", rule_group_name="myPrometheusRuleGroup", ) - print(response) -# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2021-07-22-preview/examples/deletePrometheusRuleGroup.json +# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2023-03-01/examples/deletePrometheusRuleGroup.json if __name__ == "__main__": main() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/get_prometheus_rule_group.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/get_prometheus_rule_group.py index 41ae7fa00fe3..1f55c0757630 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/get_prometheus_rule_group.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/get_prometheus_rule_group.py @@ -26,16 +26,17 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), - subscription_id="14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", + target_type="TARGET_TYPE", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.prometheus_rule_groups.get( - resource_group_name="giladstest", + resource_group_name="promResourceGroup", rule_group_name="myPrometheusRuleGroup", ) print(response) -# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2021-07-22-preview/examples/getPrometheusRuleGroup.json +# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2023-03-01/examples/getPrometheusRuleGroup.json if __name__ == "__main__": main() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/list_prometheus_rule_groups.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/list_prometheus_rule_groups.py index f300eb020d15..3c553d78b72d 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/list_prometheus_rule_groups.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/list_prometheus_rule_groups.py @@ -26,16 +26,17 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), - subscription_id="14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", + target_type="TARGET_TYPE", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.prometheus_rule_groups.list_by_resource_group( - resource_group_name="giladstest", + resource_group_name="promResourceGroup", ) for item in response: print(item) -# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2021-07-22-preview/examples/listPrometheusRuleGroups.json +# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2023-03-01/examples/listPrometheusRuleGroups.json if __name__ == "__main__": main() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/list_subscription_prometheus_rule_groups.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/list_subscription_prometheus_rule_groups.py index e2ea7530deb2..93c50e6f0745 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/list_subscription_prometheus_rule_groups.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/list_subscription_prometheus_rule_groups.py @@ -26,7 +26,8 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), - subscription_id="14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", + target_type="TARGET_TYPE", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.prometheus_rule_groups.list_by_subscription() @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2021-07-22-preview/examples/listSubscriptionPrometheusRuleGroups.json +# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2023-03-01/examples/listSubscriptionPrometheusRuleGroups.json if __name__ == "__main__": main() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/operations_list.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/operations_list.py index 69a32c6a6873..0ccdff229f98 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/operations_list.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/operations_list.py @@ -26,6 +26,7 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), + target_type="TARGET_TYPE", subscription_id="SUBSCRIPTION_ID", ) diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/patch_prometheus_rule_group.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/patch_prometheus_rule_group.py index d5d921aa0d34..218572dbb2cb 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/patch_prometheus_rule_group.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/patch_prometheus_rule_group.py @@ -26,17 +26,18 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), - subscription_id="14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", + target_type="TARGET_TYPE", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.prometheus_rule_groups.update( - resource_group_name="giladstest", + resource_group_name="promResourceGroup", rule_group_name="myPrometheusRuleGroup", - parameters={"properties": {"enabled": False}, "tags": {"tag1": "value1"}}, + parameters={"properties": {"enabled": False}, "tags": {"tag1": "tagValueFromPatch"}}, ) print(response) -# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2021-07-22-preview/examples/patchPrometheusRuleGroup.json +# x-ms-original-file: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2023-03-01/examples/patchPrometheusRuleGroup.json if __name__ == "__main__": main() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/smart_groups_change_state.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/smart_groups_change_state.py index 7bf44c2b6487..49fb975e34ff 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/smart_groups_change_state.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/smart_groups_change_state.py @@ -26,6 +26,7 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), + target_type="TARGET_TYPE", subscription_id="dd91de05-d791-4ceb-b6dc-988682dc7d72", ) diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/smart_groups_get_by_id.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/smart_groups_get_by_id.py index 27fad7e322b3..940970336975 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/smart_groups_get_by_id.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/smart_groups_get_by_id.py @@ -26,6 +26,7 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), + target_type="TARGET_TYPE", subscription_id="9e261de7-c804-4b9d-9ebf-6f50fe350a9a", ) diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/smart_groups_history.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/smart_groups_history.py index 4fedb8a5d1e7..cc4d48b76a22 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/smart_groups_history.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/smart_groups_history.py @@ -26,6 +26,7 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), + target_type="TARGET_TYPE", subscription_id="9e261de7-c804-4b9d-9ebf-6f50fe350a9a", ) diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/smart_groups_list.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/smart_groups_list.py index 229f50a04cda..e309a120ae9a 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/smart_groups_list.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/generated_samples/smart_groups_list.py @@ -26,6 +26,7 @@ def main(): client = AlertsManagementClient( credential=DefaultAzureCredential(), + target_type="TARGET_TYPE", subscription_id="dd91de05-d791-4ceb-b6dc-988682dc7d72", )