Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoPR monitor/resource-manager] [Monitor] Fixing issue with metricsnamespace incorrecly specified as client level argument #2565 #2080

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 102 additions & 77 deletions azure-mgmt-monitor/azure/mgmt/monitor/models/event_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,90 +15,115 @@
class EventData(Model):
"""The Azure event log entries are of type EventData.

:param authorization:
:type authorization: ~azure.mgmt.monitor.models.SenderAuthorization
:param claims: key value pairs to identify ARM permissions.
:type claims: dict[str, str]
:param caller: the email address of the user who has performed the
Variables are only populated by the server, and will be ignored when
sending a request.

:ivar authorization:
:vartype authorization: ~azure.mgmt.monitor.models.SenderAuthorization
:ivar claims: key value pairs to identify ARM permissions.
:vartype claims: dict[str, str]
:ivar caller: the email address of the user who has performed the
operation, the UPN claim or SPN claim based on availability.
:type caller: str
:param description: the description of the event.
:type description: str
:param id: the Id of this event as required by ARM for RBAC. It contains
:vartype caller: str
:ivar description: the description of the event.
:vartype description: str
:ivar id: the Id of this event as required by ARM for RBAC. It contains
the EventDataID and a timestamp information.
:type id: str
:param event_data_id: the event data Id. This is a unique identifier for
an event.
:type event_data_id: str
:param correlation_id: the correlation Id, usually a GUID in the string
:vartype id: str
:ivar event_data_id: the event data Id. This is a unique identifier for an
event.
:vartype event_data_id: str
:ivar correlation_id: the correlation Id, usually a GUID in the string
format. The correlation Id is shared among the events that belong to the
same uber operation.
:type correlation_id: str
:param event_name: the event name. This value should not be confused with
:vartype correlation_id: str
:ivar event_name: the event name. This value should not be confused with
OperationName. For practical purposes, OperationName might be more
appealing to end users.
:type event_name: ~azure.mgmt.monitor.models.LocalizableString
:param category: the event category.
:type category: ~azure.mgmt.monitor.models.LocalizableString
:param http_request: the HTTP request info. Usually includes the
:vartype event_name: ~azure.mgmt.monitor.models.LocalizableString
:ivar category: the event category.
:vartype category: ~azure.mgmt.monitor.models.LocalizableString
:ivar http_request: the HTTP request info. Usually includes the
'clientRequestId', 'clientIpAddress' (IP address of the user who initiated
the event) and 'method' (HTTP method e.g. PUT).
:type http_request: ~azure.mgmt.monitor.models.HttpRequestInfo
:param level: the event level. Possible values include: 'Critical',
:vartype http_request: ~azure.mgmt.monitor.models.HttpRequestInfo
:ivar level: the event level. Possible values include: 'Critical',
'Error', 'Warning', 'Informational', 'Verbose'
:type level: str or ~azure.mgmt.monitor.models.EventLevel
:param resource_group_name: the resource group name of the impacted
:vartype level: str or ~azure.mgmt.monitor.models.EventLevel
:ivar resource_group_name: the resource group name of the impacted
resource.
:type resource_group_name: str
:param resource_provider_name: the resource provider name of the impacted
:vartype resource_group_name: str
:ivar resource_provider_name: the resource provider name of the impacted
resource.
:type resource_provider_name: ~azure.mgmt.monitor.models.LocalizableString
:param resource_id: the resource uri that uniquely identifies the resource
:vartype resource_provider_name:
~azure.mgmt.monitor.models.LocalizableString
:ivar resource_id: the resource uri that uniquely identifies the resource
that caused this event.
:type resource_id: str
:param resource_type: the resource type
:type resource_type: ~azure.mgmt.monitor.models.LocalizableString
:param operation_id: It is usually a GUID shared among the events
:vartype resource_id: str
:ivar resource_type: the resource type
:vartype resource_type: ~azure.mgmt.monitor.models.LocalizableString
:ivar operation_id: It is usually a GUID shared among the events
corresponding to single operation. This value should not be confused with
EventName.
:type operation_id: str
:param operation_name: the operation name.
:type operation_name: ~azure.mgmt.monitor.models.LocalizableString
:param properties: the set of <Key, Value> pairs (usually a
:vartype operation_id: str
:ivar operation_name: the operation name.
:vartype operation_name: ~azure.mgmt.monitor.models.LocalizableString
:ivar properties: the set of <Key, Value> pairs (usually a
Dictionary<String, String>) that includes details about the event.
:type properties: dict[str, str]
:param status: a string describing the status of the operation. Some
:vartype properties: dict[str, str]
:ivar status: a string describing the status of the operation. Some
typical values are: Started, In progress, Succeeded, Failed, Resolved.
:type status: ~azure.mgmt.monitor.models.LocalizableString
:param sub_status: the event sub status. Most of the time, when included,
:vartype status: ~azure.mgmt.monitor.models.LocalizableString
:ivar sub_status: the event sub status. Most of the time, when included,
this captures the HTTP status code of the REST call. Common values are: OK
(HTTP Status Code: 200), Created (HTTP Status Code: 201), Accepted (HTTP
Status Code: 202), No Content (HTTP Status Code: 204), Bad Request(HTTP
Status Code: 400), Not Found (HTTP Status Code: 404), Conflict (HTTP
Status Code: 409), Internal Server Error (HTTP Status Code: 500), Service
Unavailable (HTTP Status Code:503), Gateway Timeout (HTTP Status Code:
504)
:type sub_status: ~azure.mgmt.monitor.models.LocalizableString
:param event_timestamp: the timestamp of when the event was generated by
:vartype sub_status: ~azure.mgmt.monitor.models.LocalizableString
:ivar event_timestamp: the timestamp of when the event was generated by
the Azure service processing the request corresponding the event. It in
ISO 8601 format.
:type event_timestamp: datetime
:param submission_timestamp: the timestamp of when the event became
:vartype event_timestamp: datetime
:ivar submission_timestamp: the timestamp of when the event became
available for querying via this API. It is in ISO 8601 format. This value
should not be confused eventTimestamp. As there might be a delay between
the occurrence time of the event, and the time that the event is submitted
to the Azure logging infrastructure.
:type submission_timestamp: datetime
:param subscription_id: the Azure subscription Id usually a GUID.
:type subscription_id: str
:param tenant_id: the Azure tenant Id
:type tenant_id: str
:vartype submission_timestamp: datetime
:ivar subscription_id: the Azure subscription Id usually a GUID.
:vartype subscription_id: str
:ivar tenant_id: the Azure tenant Id
:vartype tenant_id: str
"""

_validation = {
'level': {'required': True},
'event_timestamp': {'required': True},
'submission_timestamp': {'required': True},
'authorization': {'readonly': True},
'claims': {'readonly': True},
'caller': {'readonly': True},
'description': {'readonly': True},
'id': {'readonly': True},
'event_data_id': {'readonly': True},
'correlation_id': {'readonly': True},
'event_name': {'readonly': True},
'category': {'readonly': True},
'http_request': {'readonly': True},
'level': {'readonly': True},
'resource_group_name': {'readonly': True},
'resource_provider_name': {'readonly': True},
'resource_id': {'readonly': True},
'resource_type': {'readonly': True},
'operation_id': {'readonly': True},
'operation_name': {'readonly': True},
'properties': {'readonly': True},
'status': {'readonly': True},
'sub_status': {'readonly': True},
'event_timestamp': {'readonly': True},
'submission_timestamp': {'readonly': True},
'subscription_id': {'readonly': True},
'tenant_id': {'readonly': True},
}

_attribute_map = {
Expand Down Expand Up @@ -128,29 +153,29 @@ class EventData(Model):
'tenant_id': {'key': 'tenantId', 'type': 'str'},
}

def __init__(self, level, event_timestamp, submission_timestamp, authorization=None, claims=None, caller=None, description=None, id=None, event_data_id=None, correlation_id=None, event_name=None, category=None, http_request=None, resource_group_name=None, resource_provider_name=None, resource_id=None, resource_type=None, operation_id=None, operation_name=None, properties=None, status=None, sub_status=None, subscription_id=None, tenant_id=None):
def __init__(self):
super(EventData, self).__init__()
self.authorization = authorization
self.claims = claims
self.caller = caller
self.description = description
self.id = id
self.event_data_id = event_data_id
self.correlation_id = correlation_id
self.event_name = event_name
self.category = category
self.http_request = http_request
self.level = level
self.resource_group_name = resource_group_name
self.resource_provider_name = resource_provider_name
self.resource_id = resource_id
self.resource_type = resource_type
self.operation_id = operation_id
self.operation_name = operation_name
self.properties = properties
self.status = status
self.sub_status = sub_status
self.event_timestamp = event_timestamp
self.submission_timestamp = submission_timestamp
self.subscription_id = subscription_id
self.tenant_id = tenant_id
self.authorization = None
self.claims = None
self.caller = None
self.description = None
self.id = None
self.event_data_id = None
self.correlation_id = None
self.event_name = None
self.category = None
self.http_request = None
self.level = None
self.resource_group_name = None
self.resource_provider_name = None
self.resource_id = None
self.resource_type = None
self.operation_id = None
self.operation_name = None
self.properties = None
self.status = None
self.sub_status = None
self.event_timestamp = None
self.submission_timestamp = None
self.subscription_id = None
self.tenant_id = None
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@ class MonitorManagementClientConfiguration(AzureConfiguration):
object<msrestazure.azure_active_directory>`
:param subscription_id: The Azure subscription Id.
:type subscription_id: str
:param metricnamespace: Metric namespace to query metric definitions for.
:type metricnamespace: str
:param str base_url: Service URL
"""

def __init__(
self, credentials, subscription_id, metricnamespace=None, base_url=None):
self, credentials, subscription_id, base_url=None):

if credentials is None:
raise ValueError("Parameter 'credentials' must not be None.")
Expand All @@ -63,7 +61,6 @@ def __init__(

self.credentials = credentials
self.subscription_id = subscription_id
self.metricnamespace = metricnamespace


class MonitorManagementClient(object):
Expand Down Expand Up @@ -108,15 +105,13 @@ class MonitorManagementClient(object):
object<msrestazure.azure_active_directory>`
:param subscription_id: The Azure subscription Id.
:type subscription_id: str
:param metricnamespace: Metric namespace to query metric definitions for.
:type metricnamespace: str
:param str base_url: Service URL
"""

def __init__(
self, credentials, subscription_id, metricnamespace=None, base_url=None):
self, credentials, subscription_id, base_url=None):

self.config = MonitorManagementClientConfiguration(credentials, subscription_id, metricnamespace, base_url)
self.config = MonitorManagementClientConfiguration(credentials, subscription_id, base_url)
self._client = ServiceClient(self.config.credentials, self.config)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@ def __init__(self, client, config, serializer, deserializer):
self.config = config

def list(
self, resource_uri, custom_headers=None, raw=False, **operation_config):
self, resource_uri, metricnamespace=None, custom_headers=None, raw=False, **operation_config):
"""Lists the metric definitions for the resource.

:param resource_uri: The identifier of the resource.
:type resource_uri: str
:param metricnamespace: Metric namespace to query metric definitions
for.
:type metricnamespace: str
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
Expand All @@ -66,8 +69,8 @@ def internal_paging(next_link=None, raw=False):
# Construct parameters
query_parameters = {}
query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
if self.config.metricnamespace is not None:
query_parameters['metricnamespace'] = self._serialize.query("self.config.metricnamespace", self.config.metricnamespace, 'str')
if metricnamespace is not None:
query_parameters['metricnamespace'] = self._serialize.query("metricnamespace", metricnamespace, 'str')

else:
url = next_link
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(self, client, config, serializer, deserializer):
self.config = config

def list(
self, resource_uri, timespan=None, interval=None, metric=None, aggregation=None, top=None, orderby=None, filter=None, result_type=None, custom_headers=None, raw=False, **operation_config):
self, resource_uri, timespan=None, interval=None, metric=None, aggregation=None, top=None, orderby=None, filter=None, result_type=None, metricnamespace=None, custom_headers=None, raw=False, **operation_config):
"""**Lists the metric values for a resource**.

:param resource_uri: The identifier of the resource.
Expand Down Expand Up @@ -76,6 +76,9 @@ def list(
allowed depends on the operation. See the operation's description for
details. Possible values include: 'Data', 'Metadata'
:type result_type: str or ~azure.mgmt.monitor.models.ResultType
:param metricnamespace: Metric namespace to query metric definitions
for.
:type metricnamespace: str
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
Expand Down Expand Up @@ -113,8 +116,8 @@ def list(
if result_type is not None:
query_parameters['resultType'] = self._serialize.query("result_type", result_type, 'ResultType')
query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
if self.config.metricnamespace is not None:
query_parameters['metricnamespace'] = self._serialize.query("self.config.metricnamespace", self.config.metricnamespace, 'str')
if metricnamespace is not None:
query_parameters['metricnamespace'] = self._serialize.query("metricnamespace", metricnamespace, 'str')

# Construct headers
header_parameters = {}
Expand Down