Skip to content

Commit 8f8ec65

Browse files
authored
[Monitor Query] Update swagger (#34614)
The swagger file are updated and the code is regenerated. Signed-off-by: Paul Van Eck <[email protected]>
1 parent 4207b9f commit 8f8ec65

File tree

19 files changed

+132
-125
lines changed

19 files changed

+132
-125
lines changed

sdk/monitor/azure-monitor-query/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/monitor/azure-monitor-query",
5-
"Tag": "python/monitor/azure-monitor-query_152690fb22"
5+
"Tag": "python/monitor/azure-monitor-query_8640f7c705"
66
}

sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/_serialization.py

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]],
170170
return None
171171

172172

173-
try:
174-
basestring # type: ignore
175-
unicode_str = unicode # type: ignore
176-
except NameError:
177-
basestring = str
178-
unicode_str = str
179-
180173
_LOGGER = logging.getLogger(__name__)
181174

182175
try:
@@ -545,7 +538,7 @@ class Serializer(object):
545538
"multiple": lambda x, y: x % y != 0,
546539
}
547540

548-
def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None):
541+
def __init__(self, classes: Optional[Mapping[str, type]] = None):
549542
self.serialize_type = {
550543
"iso-8601": Serializer.serialize_iso,
551544
"rfc-1123": Serializer.serialize_rfc,
@@ -561,7 +554,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None):
561554
"[]": self.serialize_iter,
562555
"{}": self.serialize_dict,
563556
}
564-
self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {}
557+
self.dependencies: Dict[str, type] = dict(classes) if classes else {}
565558
self.key_transformer = full_restapi_key_transformer
566559
self.client_side_validation = True
567560

@@ -649,7 +642,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs):
649642
else: # That's a basic type
650643
# Integrate namespace if necessary
651644
local_node = _create_xml_node(xml_name, xml_prefix, xml_ns)
652-
local_node.text = unicode_str(new_attr)
645+
local_node.text = str(new_attr)
653646
serialized.append(local_node) # type: ignore
654647
else: # JSON
655648
for k in reversed(keys): # type: ignore
@@ -994,7 +987,7 @@ def serialize_object(self, attr, **kwargs):
994987
return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs)
995988
if obj_type is _long_type:
996989
return self.serialize_long(attr)
997-
if obj_type is unicode_str:
990+
if obj_type is str:
998991
return self.serialize_unicode(attr)
999992
if obj_type is datetime.datetime:
1000993
return self.serialize_iso(attr)
@@ -1370,7 +1363,7 @@ class Deserializer(object):
13701363

13711364
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}]?")
13721365

1373-
def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None):
1366+
def __init__(self, classes: Optional[Mapping[str, type]] = None):
13741367
self.deserialize_type = {
13751368
"iso-8601": Deserializer.deserialize_iso,
13761369
"rfc-1123": Deserializer.deserialize_rfc,
@@ -1390,7 +1383,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None):
13901383
"duration": (isodate.Duration, datetime.timedelta),
13911384
"iso-8601": (datetime.datetime),
13921385
}
1393-
self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {}
1386+
self.dependencies: Dict[str, type] = dict(classes) if classes else {}
13941387
self.key_extractors = [rest_key_extractor, xml_key_extractor]
13951388
# Additional properties only works if the "rest_key_extractor" is used to
13961389
# extract the keys. Making it to work whatever the key extractor is too much
@@ -1443,7 +1436,7 @@ def _deserialize(self, target_obj, data):
14431436

14441437
response, class_name = self._classify_target(target_obj, data)
14451438

1446-
if isinstance(response, basestring):
1439+
if isinstance(response, str):
14471440
return self.deserialize_data(data, response)
14481441
elif isinstance(response, type) and issubclass(response, Enum):
14491442
return self.deserialize_enum(data, response)
@@ -1514,14 +1507,14 @@ def _classify_target(self, target, data):
15141507
if target is None:
15151508
return None, None
15161509

1517-
if isinstance(target, basestring):
1510+
if isinstance(target, str):
15181511
try:
15191512
target = self.dependencies[target]
15201513
except KeyError:
15211514
return target, target
15221515

15231516
try:
1524-
target = target._classify(data, self.dependencies)
1517+
target = target._classify(data, self.dependencies) # type: ignore
15251518
except AttributeError:
15261519
pass # Target is not a Model, no classify
15271520
return target, target.__class__.__name__ # type: ignore
@@ -1577,7 +1570,7 @@ def _unpack_content(raw_data, content_type=None):
15771570
if hasattr(raw_data, "_content_consumed"):
15781571
return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers)
15791572

1580-
if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"):
1573+
if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"):
15811574
return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore
15821575
return raw_data
15831576

@@ -1699,7 +1692,7 @@ def deserialize_object(self, attr, **kwargs):
16991692
if isinstance(attr, ET.Element):
17001693
# Do no recurse on XML, just return the tree as-is
17011694
return attr
1702-
if isinstance(attr, basestring):
1695+
if isinstance(attr, str):
17031696
return self.deserialize_basic(attr, "str")
17041697
obj_type = type(attr)
17051698
if obj_type in self.basic_types:
@@ -1756,7 +1749,7 @@ def deserialize_basic(self, attr, data_type):
17561749
if data_type == "bool":
17571750
if attr in [True, False, 1, 0]:
17581751
return bool(attr)
1759-
elif isinstance(attr, basestring):
1752+
elif isinstance(attr, str):
17601753
if attr.lower() in ["true", "1"]:
17611754
return True
17621755
elif attr.lower() in ["false", "0"]:

sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/aio/operations/_operations.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,6 @@ async def execute(
384384
:keyword prefer: Optional. The prefer header to set server timeout, query statistics and
385385
visualization information. Default value is None.
386386
:paramtype prefer: str
387-
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
388-
Default value is None.
389-
:paramtype content_type: str
390387
:return: JSON object
391388
:rtype: JSON
392389
:raises ~azure.core.exceptions.HttpResponseError:
@@ -829,9 +826,6 @@ async def resource_execute(
829826
:keyword prefer: Optional. The prefer header to set server timeout, query statistics and
830827
visualization information. Default value is None.
831828
:paramtype prefer: str
832-
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
833-
Default value is None.
834-
:paramtype content_type: str
835829
:return: JSON object
836830
:rtype: JSON
837831
:raises ~azure.core.exceptions.HttpResponseError:
@@ -1182,9 +1176,6 @@ async def batch(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON:
11821176
11831177
:param body: The batch request body. Is either a JSON type or a IO[bytes] type. Required.
11841178
:type body: JSON or IO[bytes]
1185-
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
1186-
Default value is None.
1187-
:paramtype content_type: str
11881179
:return: JSON object
11891180
:rtype: JSON
11901181
:raises ~azure.core.exceptions.HttpResponseError:
@@ -1669,9 +1660,6 @@ async def resource_execute_xms(
16691660
:keyword prefer: Optional. The prefer header to set server timeout, query statistics and
16701661
visualization information. Default value is None.
16711662
:paramtype prefer: str
1672-
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
1673-
Default value is None.
1674-
:paramtype content_type: str
16751663
:return: JSON object
16761664
:rtype: JSON
16771665
:raises ~azure.core.exceptions.HttpResponseError:

sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/_client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ class MonitorMetricsClient: # pylint: disable=client-accepts-api-version-keywor
2929
:vartype metric_namespaces: monitor_metrics_client.operations.MetricNamespacesOperations
3030
:keyword endpoint: Service URL. Default value is "https://management.azure.com".
3131
:paramtype endpoint: str
32+
:keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this
33+
default value may result in unsupported behavior.
34+
:paramtype api_version: str
3235
"""
3336

3437
def __init__( # pylint: disable=missing-client-constructor-parameter-credential

sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/_configuration.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,16 @@ class MonitorMetricsClientConfiguration: # pylint: disable=too-many-instance-at
1818
1919
Note that all parameters used to create this instance are saved as instance
2020
attributes.
21+
22+
:keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this
23+
default value may result in unsupported behavior.
24+
:paramtype api_version: str
2125
"""
2226

2327
def __init__(self, **kwargs: Any) -> None:
28+
api_version: str = kwargs.pop("api_version", "2024-02-01")
2429

30+
self.api_version = api_version
2531
kwargs.setdefault("sdk_moniker", "monitor-query/{}".format(VERSION))
2632
self.polling_interval = kwargs.get("polling_interval", 30)
2733
self._configure(**kwargs)

sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/_serialization.py

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]],
170170
return None
171171

172172

173-
try:
174-
basestring # type: ignore
175-
unicode_str = unicode # type: ignore
176-
except NameError:
177-
basestring = str
178-
unicode_str = str
179-
180173
_LOGGER = logging.getLogger(__name__)
181174

182175
try:
@@ -545,7 +538,7 @@ class Serializer(object):
545538
"multiple": lambda x, y: x % y != 0,
546539
}
547540

548-
def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None):
541+
def __init__(self, classes: Optional[Mapping[str, type]] = None):
549542
self.serialize_type = {
550543
"iso-8601": Serializer.serialize_iso,
551544
"rfc-1123": Serializer.serialize_rfc,
@@ -561,7 +554,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None):
561554
"[]": self.serialize_iter,
562555
"{}": self.serialize_dict,
563556
}
564-
self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {}
557+
self.dependencies: Dict[str, type] = dict(classes) if classes else {}
565558
self.key_transformer = full_restapi_key_transformer
566559
self.client_side_validation = True
567560

@@ -649,7 +642,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs):
649642
else: # That's a basic type
650643
# Integrate namespace if necessary
651644
local_node = _create_xml_node(xml_name, xml_prefix, xml_ns)
652-
local_node.text = unicode_str(new_attr)
645+
local_node.text = str(new_attr)
653646
serialized.append(local_node) # type: ignore
654647
else: # JSON
655648
for k in reversed(keys): # type: ignore
@@ -994,7 +987,7 @@ def serialize_object(self, attr, **kwargs):
994987
return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs)
995988
if obj_type is _long_type:
996989
return self.serialize_long(attr)
997-
if obj_type is unicode_str:
990+
if obj_type is str:
998991
return self.serialize_unicode(attr)
999992
if obj_type is datetime.datetime:
1000993
return self.serialize_iso(attr)
@@ -1370,7 +1363,7 @@ class Deserializer(object):
13701363

13711364
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}]?")
13721365

1373-
def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None):
1366+
def __init__(self, classes: Optional[Mapping[str, type]] = None):
13741367
self.deserialize_type = {
13751368
"iso-8601": Deserializer.deserialize_iso,
13761369
"rfc-1123": Deserializer.deserialize_rfc,
@@ -1390,7 +1383,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None):
13901383
"duration": (isodate.Duration, datetime.timedelta),
13911384
"iso-8601": (datetime.datetime),
13921385
}
1393-
self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {}
1386+
self.dependencies: Dict[str, type] = dict(classes) if classes else {}
13941387
self.key_extractors = [rest_key_extractor, xml_key_extractor]
13951388
# Additional properties only works if the "rest_key_extractor" is used to
13961389
# extract the keys. Making it to work whatever the key extractor is too much
@@ -1443,7 +1436,7 @@ def _deserialize(self, target_obj, data):
14431436

14441437
response, class_name = self._classify_target(target_obj, data)
14451438

1446-
if isinstance(response, basestring):
1439+
if isinstance(response, str):
14471440
return self.deserialize_data(data, response)
14481441
elif isinstance(response, type) and issubclass(response, Enum):
14491442
return self.deserialize_enum(data, response)
@@ -1514,14 +1507,14 @@ def _classify_target(self, target, data):
15141507
if target is None:
15151508
return None, None
15161509

1517-
if isinstance(target, basestring):
1510+
if isinstance(target, str):
15181511
try:
15191512
target = self.dependencies[target]
15201513
except KeyError:
15211514
return target, target
15221515

15231516
try:
1524-
target = target._classify(data, self.dependencies)
1517+
target = target._classify(data, self.dependencies) # type: ignore
15251518
except AttributeError:
15261519
pass # Target is not a Model, no classify
15271520
return target, target.__class__.__name__ # type: ignore
@@ -1577,7 +1570,7 @@ def _unpack_content(raw_data, content_type=None):
15771570
if hasattr(raw_data, "_content_consumed"):
15781571
return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers)
15791572

1580-
if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"):
1573+
if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"):
15811574
return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore
15821575
return raw_data
15831576

@@ -1699,7 +1692,7 @@ def deserialize_object(self, attr, **kwargs):
16991692
if isinstance(attr, ET.Element):
17001693
# Do no recurse on XML, just return the tree as-is
17011694
return attr
1702-
if isinstance(attr, basestring):
1695+
if isinstance(attr, str):
17031696
return self.deserialize_basic(attr, "str")
17041697
obj_type = type(attr)
17051698
if obj_type in self.basic_types:
@@ -1756,7 +1749,7 @@ def deserialize_basic(self, attr, data_type):
17561749
if data_type == "bool":
17571750
if attr in [True, False, 1, 0]:
17581751
return bool(attr)
1759-
elif isinstance(attr, basestring):
1752+
elif isinstance(attr, str):
17601753
if attr.lower() in ["true", "1"]:
17611754
return True
17621755
elif attr.lower() in ["false", "0"]:

sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/aio/_client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ class MonitorMetricsClient: # pylint: disable=client-accepts-api-version-keywor
2929
:vartype metric_namespaces: monitor_metrics_client.aio.operations.MetricNamespacesOperations
3030
:keyword endpoint: Service URL. Default value is "https://management.azure.com".
3131
:paramtype endpoint: str
32+
:keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this
33+
default value may result in unsupported behavior.
34+
:paramtype api_version: str
3235
"""
3336

3437
def __init__( # pylint: disable=missing-client-constructor-parameter-credential

sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/aio/_configuration.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,16 @@ class MonitorMetricsClientConfiguration: # pylint: disable=too-many-instance-at
1818
1919
Note that all parameters used to create this instance are saved as instance
2020
attributes.
21+
22+
:keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this
23+
default value may result in unsupported behavior.
24+
:paramtype api_version: str
2125
"""
2226

2327
def __init__(self, **kwargs: Any) -> None:
28+
api_version: str = kwargs.pop("api_version", "2024-02-01")
2429

30+
self.api_version = api_version
2531
kwargs.setdefault("sdk_moniker", "monitor-query/{}".format(VERSION))
2632
self.polling_interval = kwargs.get("polling_interval", 30)
2733
self._configure(**kwargs)

0 commit comments

Comments
 (0)