Skip to content

Commit

Permalink
[Monitor Query] Update swagger (Azure#34614)
Browse files Browse the repository at this point in the history
The swagger file are updated and the code is regenerated.

Signed-off-by: Paul Van Eck <[email protected]>
  • Loading branch information
pvaneck authored Mar 12, 2024
1 parent 4207b9f commit 8f8ec65
Show file tree
Hide file tree
Showing 19 changed files with 132 additions and 125 deletions.
2 changes: 1 addition & 1 deletion sdk/monitor/azure-monitor-query/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "python",
"TagPrefix": "python/monitor/azure-monitor-query",
"Tag": "python/monitor/azure-monitor-query_152690fb22"
"Tag": "python/monitor/azure-monitor-query_8640f7c705"
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]],
return None


try:
basestring # type: ignore
unicode_str = unicode # type: ignore
except NameError:
basestring = str
unicode_str = str

_LOGGER = logging.getLogger(__name__)

try:
Expand Down Expand Up @@ -545,7 +538,7 @@ class Serializer(object):
"multiple": lambda x, y: x % y != 0,
}

def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None):
def __init__(self, classes: Optional[Mapping[str, type]] = None):
self.serialize_type = {
"iso-8601": Serializer.serialize_iso,
"rfc-1123": Serializer.serialize_rfc,
Expand All @@ -561,7 +554,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None):
"[]": self.serialize_iter,
"{}": self.serialize_dict,
}
self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {}
self.dependencies: Dict[str, type] = dict(classes) if classes else {}
self.key_transformer = full_restapi_key_transformer
self.client_side_validation = True

Expand Down Expand Up @@ -649,7 +642,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs):
else: # That's a basic type
# Integrate namespace if necessary
local_node = _create_xml_node(xml_name, xml_prefix, xml_ns)
local_node.text = unicode_str(new_attr)
local_node.text = str(new_attr)
serialized.append(local_node) # type: ignore
else: # JSON
for k in reversed(keys): # type: ignore
Expand Down Expand Up @@ -994,7 +987,7 @@ def serialize_object(self, attr, **kwargs):
return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs)
if obj_type is _long_type:
return self.serialize_long(attr)
if obj_type is unicode_str:
if obj_type is str:
return self.serialize_unicode(attr)
if obj_type is datetime.datetime:
return self.serialize_iso(attr)
Expand Down Expand Up @@ -1370,7 +1363,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: Optional[Mapping[str, Type[ModelType]]] = None):
def __init__(self, classes: Optional[Mapping[str, type]] = None):
self.deserialize_type = {
"iso-8601": Deserializer.deserialize_iso,
"rfc-1123": Deserializer.deserialize_rfc,
Expand All @@ -1390,7 +1383,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None):
"duration": (isodate.Duration, datetime.timedelta),
"iso-8601": (datetime.datetime),
}
self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {}
self.dependencies: Dict[str, type] = dict(classes) if classes else {}
self.key_extractors = [rest_key_extractor, xml_key_extractor]
# Additional properties only works if the "rest_key_extractor" is used to
# extract the keys. Making it to work whatever the key extractor is too much
Expand Down Expand Up @@ -1443,7 +1436,7 @@ def _deserialize(self, target_obj, data):

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

if isinstance(response, basestring):
if isinstance(response, str):
return self.deserialize_data(data, response)
elif isinstance(response, type) and issubclass(response, Enum):
return self.deserialize_enum(data, response)
Expand Down Expand Up @@ -1514,14 +1507,14 @@ def _classify_target(self, target, data):
if target is None:
return None, None

if isinstance(target, basestring):
if isinstance(target, str):
try:
target = self.dependencies[target]
except KeyError:
return target, target

try:
target = target._classify(data, self.dependencies)
target = target._classify(data, self.dependencies) # type: ignore
except AttributeError:
pass # Target is not a Model, no classify
return target, target.__class__.__name__ # type: ignore
Expand Down Expand Up @@ -1577,7 +1570,7 @@ def _unpack_content(raw_data, content_type=None):
if hasattr(raw_data, "_content_consumed"):
return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers)

if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"):
if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"):
return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore
return raw_data

Expand Down Expand Up @@ -1699,7 +1692,7 @@ def deserialize_object(self, attr, **kwargs):
if isinstance(attr, ET.Element):
# Do no recurse on XML, just return the tree as-is
return attr
if isinstance(attr, basestring):
if isinstance(attr, str):
return self.deserialize_basic(attr, "str")
obj_type = type(attr)
if obj_type in self.basic_types:
Expand Down Expand Up @@ -1756,7 +1749,7 @@ def deserialize_basic(self, attr, data_type):
if data_type == "bool":
if attr in [True, False, 1, 0]:
return bool(attr)
elif isinstance(attr, basestring):
elif isinstance(attr, str):
if attr.lower() in ["true", "1"]:
return True
elif attr.lower() in ["false", "0"]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,6 @@ async def execute(
:keyword prefer: Optional. The prefer header to set server timeout, query statistics and
visualization information. Default value is None.
:paramtype prefer: str
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:return: JSON object
:rtype: JSON
:raises ~azure.core.exceptions.HttpResponseError:
Expand Down Expand Up @@ -829,9 +826,6 @@ async def resource_execute(
:keyword prefer: Optional. The prefer header to set server timeout, query statistics and
visualization information. Default value is None.
:paramtype prefer: str
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:return: JSON object
:rtype: JSON
:raises ~azure.core.exceptions.HttpResponseError:
Expand Down Expand Up @@ -1182,9 +1176,6 @@ async def batch(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON:
:param body: The batch request body. Is either a JSON type or a IO[bytes] type. Required.
:type body: JSON or IO[bytes]
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:return: JSON object
:rtype: JSON
:raises ~azure.core.exceptions.HttpResponseError:
Expand Down Expand Up @@ -1669,9 +1660,6 @@ async def resource_execute_xms(
:keyword prefer: Optional. The prefer header to set server timeout, query statistics and
visualization information. Default value is None.
:paramtype prefer: str
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:return: JSON object
:rtype: JSON
:raises ~azure.core.exceptions.HttpResponseError:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class MonitorMetricsClient: # pylint: disable=client-accepts-api-version-keywor
:vartype metric_namespaces: monitor_metrics_client.operations.MetricNamespacesOperations
:keyword endpoint: Service URL. Default value is "https://management.azure.com".
:paramtype endpoint: str
:keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__( # pylint: disable=missing-client-constructor-parameter-credential
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@ class MonitorMetricsClientConfiguration: # pylint: disable=too-many-instance-at
Note that all parameters used to create this instance are saved as instance
attributes.
:keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""

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

self.api_version = api_version
kwargs.setdefault("sdk_moniker", "monitor-query/{}".format(VERSION))
self.polling_interval = kwargs.get("polling_interval", 30)
self._configure(**kwargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]],
return None


try:
basestring # type: ignore
unicode_str = unicode # type: ignore
except NameError:
basestring = str
unicode_str = str

_LOGGER = logging.getLogger(__name__)

try:
Expand Down Expand Up @@ -545,7 +538,7 @@ class Serializer(object):
"multiple": lambda x, y: x % y != 0,
}

def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None):
def __init__(self, classes: Optional[Mapping[str, type]] = None):
self.serialize_type = {
"iso-8601": Serializer.serialize_iso,
"rfc-1123": Serializer.serialize_rfc,
Expand All @@ -561,7 +554,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None):
"[]": self.serialize_iter,
"{}": self.serialize_dict,
}
self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {}
self.dependencies: Dict[str, type] = dict(classes) if classes else {}
self.key_transformer = full_restapi_key_transformer
self.client_side_validation = True

Expand Down Expand Up @@ -649,7 +642,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs):
else: # That's a basic type
# Integrate namespace if necessary
local_node = _create_xml_node(xml_name, xml_prefix, xml_ns)
local_node.text = unicode_str(new_attr)
local_node.text = str(new_attr)
serialized.append(local_node) # type: ignore
else: # JSON
for k in reversed(keys): # type: ignore
Expand Down Expand Up @@ -994,7 +987,7 @@ def serialize_object(self, attr, **kwargs):
return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs)
if obj_type is _long_type:
return self.serialize_long(attr)
if obj_type is unicode_str:
if obj_type is str:
return self.serialize_unicode(attr)
if obj_type is datetime.datetime:
return self.serialize_iso(attr)
Expand Down Expand Up @@ -1370,7 +1363,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: Optional[Mapping[str, Type[ModelType]]] = None):
def __init__(self, classes: Optional[Mapping[str, type]] = None):
self.deserialize_type = {
"iso-8601": Deserializer.deserialize_iso,
"rfc-1123": Deserializer.deserialize_rfc,
Expand All @@ -1390,7 +1383,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None):
"duration": (isodate.Duration, datetime.timedelta),
"iso-8601": (datetime.datetime),
}
self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {}
self.dependencies: Dict[str, type] = dict(classes) if classes else {}
self.key_extractors = [rest_key_extractor, xml_key_extractor]
# Additional properties only works if the "rest_key_extractor" is used to
# extract the keys. Making it to work whatever the key extractor is too much
Expand Down Expand Up @@ -1443,7 +1436,7 @@ def _deserialize(self, target_obj, data):

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

if isinstance(response, basestring):
if isinstance(response, str):
return self.deserialize_data(data, response)
elif isinstance(response, type) and issubclass(response, Enum):
return self.deserialize_enum(data, response)
Expand Down Expand Up @@ -1514,14 +1507,14 @@ def _classify_target(self, target, data):
if target is None:
return None, None

if isinstance(target, basestring):
if isinstance(target, str):
try:
target = self.dependencies[target]
except KeyError:
return target, target

try:
target = target._classify(data, self.dependencies)
target = target._classify(data, self.dependencies) # type: ignore
except AttributeError:
pass # Target is not a Model, no classify
return target, target.__class__.__name__ # type: ignore
Expand Down Expand Up @@ -1577,7 +1570,7 @@ def _unpack_content(raw_data, content_type=None):
if hasattr(raw_data, "_content_consumed"):
return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers)

if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"):
if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"):
return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore
return raw_data

Expand Down Expand Up @@ -1699,7 +1692,7 @@ def deserialize_object(self, attr, **kwargs):
if isinstance(attr, ET.Element):
# Do no recurse on XML, just return the tree as-is
return attr
if isinstance(attr, basestring):
if isinstance(attr, str):
return self.deserialize_basic(attr, "str")
obj_type = type(attr)
if obj_type in self.basic_types:
Expand Down Expand Up @@ -1756,7 +1749,7 @@ def deserialize_basic(self, attr, data_type):
if data_type == "bool":
if attr in [True, False, 1, 0]:
return bool(attr)
elif isinstance(attr, basestring):
elif isinstance(attr, str):
if attr.lower() in ["true", "1"]:
return True
elif attr.lower() in ["false", "0"]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class MonitorMetricsClient: # pylint: disable=client-accepts-api-version-keywor
:vartype metric_namespaces: monitor_metrics_client.aio.operations.MetricNamespacesOperations
:keyword endpoint: Service URL. Default value is "https://management.azure.com".
:paramtype endpoint: str
:keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__( # pylint: disable=missing-client-constructor-parameter-credential
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@ class MonitorMetricsClientConfiguration: # pylint: disable=too-many-instance-at
Note that all parameters used to create this instance are saved as instance
attributes.
:keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""

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

self.api_version = api_version
kwargs.setdefault("sdk_moniker", "monitor-query/{}".format(VERSION))
self.polling_interval = kwargs.get("polling_interval", 30)
self._configure(**kwargs)
Expand Down
Loading

0 comments on commit 8f8ec65

Please sign in to comment.