diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/__init__.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/__init__.py index 1f76267967cf..164f6e58b0ce 100644 --- a/azure-mgmt-monitor/azure/mgmt/monitor/models/__init__.py +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/__init__.py @@ -106,6 +106,8 @@ from .trigger_condition_py3 import TriggerCondition from .az_ns_action_group_py3 import AzNsActionGroup from .alerting_action_py3 import AlertingAction + from .metric_namespace_name_py3 import MetricNamespaceName + from .metric_namespace_py3 import MetricNamespace except (SyntaxError, ImportError): from .resource import Resource from .scale_capacity import ScaleCapacity @@ -203,6 +205,8 @@ from .trigger_condition import TriggerCondition from .az_ns_action_group import AzNsActionGroup from .alerting_action import AlertingAction + from .metric_namespace_name import MetricNamespaceName + from .metric_namespace import MetricNamespace from .autoscale_setting_resource_paged import AutoscaleSettingResourcePaged from .incident_paged import IncidentPaged from .alert_rule_resource_paged import AlertRuleResourcePaged @@ -214,6 +218,7 @@ from .metric_definition_paged import MetricDefinitionPaged from .metric_alert_resource_paged import MetricAlertResourcePaged from .log_search_rule_resource_paged import LogSearchRuleResourcePaged +from .metric_namespace_paged import MetricNamespacePaged from .monitor_management_client_enums import ( MetricStatisticType, TimeAggregationType, @@ -335,6 +340,8 @@ 'TriggerCondition', 'AzNsActionGroup', 'AlertingAction', + 'MetricNamespaceName', + 'MetricNamespace', 'AutoscaleSettingResourcePaged', 'IncidentPaged', 'AlertRuleResourcePaged', @@ -346,6 +353,7 @@ 'MetricDefinitionPaged', 'MetricAlertResourcePaged', 'LogSearchRuleResourcePaged', + 'MetricNamespacePaged', 'MetricStatisticType', 'TimeAggregationType', 'ComparisonOperationType', diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/metric_namespace.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/metric_namespace.py new file mode 100644 index 000000000000..f550b7b247d4 --- /dev/null +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/metric_namespace.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class MetricNamespace(Model): + """Metric namespace class specifies the metadata for a metric namespace. + + :param id: The ID of the metricNamespace. + :type id: str + :param type: The type of the namespace. + :type type: str + :param name: The name of the namespace. + :type name: str + :param properties: Properties which include the fully qualified namespace + name. + :type properties: ~azure.mgmt.monitor.models.MetricNamespaceName + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'MetricNamespaceName'}, + } + + def __init__(self, **kwargs): + super(MetricNamespace, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.type = kwargs.get('type', None) + self.name = kwargs.get('name', None) + self.properties = kwargs.get('properties', None) diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/metric_namespace_name.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/metric_namespace_name.py new file mode 100644 index 000000000000..504355e9d43e --- /dev/null +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/metric_namespace_name.py @@ -0,0 +1,28 @@ +# 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 msrest.serialization import Model + + +class MetricNamespaceName(Model): + """The fully qualified metric namespace name. + + :param metric_namespace_name: The metric namespace name. + :type metric_namespace_name: str + """ + + _attribute_map = { + 'metric_namespace_name': {'key': 'metricNamespaceName', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(MetricNamespaceName, self).__init__(**kwargs) + self.metric_namespace_name = kwargs.get('metric_namespace_name', None) diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/metric_namespace_name_py3.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/metric_namespace_name_py3.py new file mode 100644 index 000000000000..b4fe63755fcb --- /dev/null +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/metric_namespace_name_py3.py @@ -0,0 +1,28 @@ +# 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 msrest.serialization import Model + + +class MetricNamespaceName(Model): + """The fully qualified metric namespace name. + + :param metric_namespace_name: The metric namespace name. + :type metric_namespace_name: str + """ + + _attribute_map = { + 'metric_namespace_name': {'key': 'metricNamespaceName', 'type': 'str'}, + } + + def __init__(self, *, metric_namespace_name: str=None, **kwargs) -> None: + super(MetricNamespaceName, self).__init__(**kwargs) + self.metric_namespace_name = metric_namespace_name diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/metric_namespace_paged.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/metric_namespace_paged.py new file mode 100644 index 000000000000..9c3a60df700f --- /dev/null +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/metric_namespace_paged.py @@ -0,0 +1,27 @@ +# 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 msrest.paging import Paged + + +class MetricNamespacePaged(Paged): + """ + A paging container for iterating over a list of :class:`MetricNamespace ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[MetricNamespace]'} + } + + def __init__(self, *args, **kwargs): + + super(MetricNamespacePaged, self).__init__(*args, **kwargs) diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/metric_namespace_py3.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/metric_namespace_py3.py new file mode 100644 index 000000000000..6f81045b10e3 --- /dev/null +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/metric_namespace_py3.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class MetricNamespace(Model): + """Metric namespace class specifies the metadata for a metric namespace. + + :param id: The ID of the metricNamespace. + :type id: str + :param type: The type of the namespace. + :type type: str + :param name: The name of the namespace. + :type name: str + :param properties: Properties which include the fully qualified namespace + name. + :type properties: ~azure.mgmt.monitor.models.MetricNamespaceName + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'MetricNamespaceName'}, + } + + def __init__(self, *, id: str=None, type: str=None, name: str=None, properties=None, **kwargs) -> None: + super(MetricNamespace, self).__init__(**kwargs) + self.id = id + self.type = type + self.name = name + self.properties = properties diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/monitor_management_client.py b/azure-mgmt-monitor/azure/mgmt/monitor/monitor_management_client.py index f27f5bbcbefa..4580a30fc42e 100644 --- a/azure-mgmt-monitor/azure/mgmt/monitor/monitor_management_client.py +++ b/azure-mgmt-monitor/azure/mgmt/monitor/monitor_management_client.py @@ -31,6 +31,7 @@ from .operations.metric_alerts_operations import MetricAlertsOperations from .operations.metric_alerts_status_operations import MetricAlertsStatusOperations from .operations.scheduled_query_rules_operations import ScheduledQueryRulesOperations +from .operations.metric_namespaces_operations import MetricNamespacesOperations from . import models @@ -108,6 +109,8 @@ class MonitorManagementClient(SDKClient): :vartype metric_alerts_status: azure.mgmt.monitor.operations.MetricAlertsStatusOperations :ivar scheduled_query_rules: ScheduledQueryRules operations :vartype scheduled_query_rules: azure.mgmt.monitor.operations.ScheduledQueryRulesOperations + :ivar metric_namespaces: MetricNamespaces operations + :vartype metric_namespaces: azure.mgmt.monitor.operations.MetricNamespacesOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials @@ -163,3 +166,5 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.scheduled_query_rules = ScheduledQueryRulesOperations( self._client, self.config, self._serialize, self._deserialize) + self.metric_namespaces = MetricNamespacesOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/operations/__init__.py b/azure-mgmt-monitor/azure/mgmt/monitor/operations/__init__.py index 17a5cbbab15e..bec73c3cf3a2 100644 --- a/azure-mgmt-monitor/azure/mgmt/monitor/operations/__init__.py +++ b/azure-mgmt-monitor/azure/mgmt/monitor/operations/__init__.py @@ -27,6 +27,7 @@ from .metric_alerts_operations import MetricAlertsOperations from .metric_alerts_status_operations import MetricAlertsStatusOperations from .scheduled_query_rules_operations import ScheduledQueryRulesOperations +from .metric_namespaces_operations import MetricNamespacesOperations __all__ = [ 'AutoscaleSettingsOperations', @@ -47,4 +48,5 @@ 'MetricAlertsOperations', 'MetricAlertsStatusOperations', 'ScheduledQueryRulesOperations', + 'MetricNamespacesOperations', ] diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/operations/metric_namespaces_operations.py b/azure-mgmt-monitor/azure/mgmt/monitor/operations/metric_namespaces_operations.py new file mode 100644 index 000000000000..8dd5d6eab792 --- /dev/null +++ b/azure-mgmt-monitor/azure/mgmt/monitor/operations/metric_namespaces_operations.py @@ -0,0 +1,107 @@ +# 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. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class MetricNamespacesOperations(object): + """MetricNamespacesOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: Client Api Version. Constant value: "2017-12-01-preview". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2017-12-01-preview" + + self.config = config + + def list( + self, resource_uri, start_time=None, custom_headers=None, raw=False, **operation_config): + """Lists the metric namespaces for the resource. + + :param resource_uri: The identifier of the resource. + :type resource_uri: str + :param start_time: The ISO 8601 conform Date start time from which to + query for metric namespaces. + :type start_time: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of MetricNamespace + :rtype: + ~azure.mgmt.monitor.models.MetricNamespacePaged[~azure.mgmt.monitor.models.MetricNamespace] + :raises: + :class:`ErrorResponseException` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.list.metadata['url'] + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if start_time is not None: + query_parameters['startTime'] = self._serialize.query("start_time", start_time, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + deserialized = models.MetricNamespacePaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.MetricNamespacePaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/metricNamespaces'}