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 workloadmonitor/resource-manager] Adding PUT notificationSettings api #3780

Merged
3 changes: 3 additions & 0 deletions azure-mgmt-workloadmonitor/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
include *.rst
include azure/__init__.py
include azure/mgmt/__init__.py

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


class NotificationSetting(ProxyResource):
"""Model for component.
"""Model for NotificationSetting.

Variables are only populated by the server, and will be ignored when
sending a request.
Expand All @@ -28,27 +28,28 @@ class NotificationSetting(ProxyResource):
:vartype type: str
:ivar etag: For optimistic concurrency control.
:vartype etag: str
:ivar action_groups: List of action group resource ids to be notified
:vartype action_groups: list[str]
:ivar action_group_resource_ids: List of action group resource ids to be
notified
:vartype action_group_resource_ids: list[str]
"""

_validation = {
'id': {'readonly': True},
'name': {'readonly': True},
'type': {'readonly': True},
'etag': {'readonly': True},
'action_groups': {'readonly': True},
'action_group_resource_ids': {'readonly': True},
}

_attribute_map = {
'id': {'key': 'id', 'type': 'str'},
'name': {'key': 'name', 'type': 'str'},
'type': {'key': 'type', 'type': 'str'},
'etag': {'key': 'etag', 'type': 'str'},
'action_groups': {'key': 'properties.actionGroups', 'type': '[str]'},
'action_group_resource_ids': {'key': 'properties.actionGroupResourceIds', 'type': '[str]'},
}

def __init__(self, **kwargs):
super(NotificationSetting, self).__init__(**kwargs)
self.etag = None
self.action_groups = None
self.action_group_resource_ids = None
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


class NotificationSetting(ProxyResource):
"""Model for component.
"""Model for NotificationSetting.

Variables are only populated by the server, and will be ignored when
sending a request.
Expand All @@ -28,27 +28,28 @@ class NotificationSetting(ProxyResource):
:vartype type: str
:ivar etag: For optimistic concurrency control.
:vartype etag: str
:ivar action_groups: List of action group resource ids to be notified
:vartype action_groups: list[str]
:ivar action_group_resource_ids: List of action group resource ids to be
notified
:vartype action_group_resource_ids: list[str]
"""

_validation = {
'id': {'readonly': True},
'name': {'readonly': True},
'type': {'readonly': True},
'etag': {'readonly': True},
'action_groups': {'readonly': True},
'action_group_resource_ids': {'readonly': True},
}

_attribute_map = {
'id': {'key': 'id', 'type': 'str'},
'name': {'key': 'name', 'type': 'str'},
'type': {'key': 'type', 'type': 'str'},
'etag': {'key': 'etag', 'type': 'str'},
'action_groups': {'key': 'properties.actionGroups', 'type': '[str]'},
'action_group_resource_ids': {'key': 'properties.actionGroupResourceIds', 'type': '[str]'},
}

def __init__(self, **kwargs) -> None:
super(NotificationSetting, self).__init__(**kwargs)
self.etag = None
self.action_groups = None
self.action_group_resource_ids = None
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class NotificationSettingsOperations(object):
:param serializer: An object model serializer.
:param deserializer: An object model deserializer.
:ivar api_version: The API version to use for this operation. Constant value: "2018-08-31-preview".
:ivar notification_setting_name: Default string modeled as parameter for URL to work correctly. Constant value: "default".
"""

models = models
Expand All @@ -33,6 +34,7 @@ def __init__(self, client, config, serializer, deserializer):
self._serialize = serializer
self._deserialize = deserializer
self.api_version = "2018-08-31-preview"
self.notification_setting_name = "default"

self.config = config

Expand Down Expand Up @@ -116,3 +118,147 @@ def internal_paging(next_link=None, raw=False):

return deserialized
list_by_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.WorkloadMonitor/notificationSettings'}

def get(
self, resource_group_name, resource_namespace, resource_type, resource_name, custom_headers=None, raw=False, **operation_config):
"""Get a of notification setting for a resource.

:param resource_group_name: The name of the resource group. The name
is case insensitive.
:type resource_group_name: str
:param resource_namespace: The Namespace of the resource.
:type resource_namespace: str
:param resource_type: The type of the resource.
:type resource_type: str
:param resource_name: Name of the resource.
:type resource_name: 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<msrest:optionsforoperations>`.
:return: NotificationSetting or ClientRawResponse if raw=true
:rtype: ~azure.mgmt.workloadmonitor.models.NotificationSetting or
~msrest.pipeline.ClientRawResponse
:raises:
:class:`ErrorResponseException<azure.mgmt.workloadmonitor.models.ErrorResponseException>`
"""
# Construct URL
url = self.get.metadata['url']
path_format_arguments = {
'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'),
'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'),
'resourceType': self._serialize.url("resource_type", resource_type, 'str'),
'resourceName': self._serialize.url("resource_name", resource_name, 'str'),
'notificationSettingName': self._serialize.url("self.notification_setting_name", self.notification_setting_name, 'str')
}
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')

# 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)

deserialized = None

if response.status_code == 200:
deserialized = self._deserialize('NotificationSetting', response)

if raw:
client_raw_response = ClientRawResponse(deserialized, response)
return client_raw_response

return deserialized
get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.WorkloadMonitor/notificationSettings/{notificationSettingName}'}

def update(
self, resource_group_name, resource_namespace, resource_type, resource_name, custom_headers=None, raw=False, **operation_config):
"""Update notification settings for a resource.

:param resource_group_name: The name of the resource group. The name
is case insensitive.
:type resource_group_name: str
:param resource_namespace: The Namespace of the resource.
:type resource_namespace: str
:param resource_type: The type of the resource.
:type resource_type: str
:param resource_name: Name of the resource.
:type resource_name: 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<msrest:optionsforoperations>`.
:return: NotificationSetting or ClientRawResponse if raw=true
:rtype: ~azure.mgmt.workloadmonitor.models.NotificationSetting or
~msrest.pipeline.ClientRawResponse
:raises:
:class:`ErrorResponseException<azure.mgmt.workloadmonitor.models.ErrorResponseException>`
"""
body = None

# Construct URL
url = self.update.metadata['url']
path_format_arguments = {
'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'),
'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'),
'resourceType': self._serialize.url("resource_type", resource_type, 'str'),
'resourceName': self._serialize.url("resource_name", resource_name, 'str'),
'notificationSettingName': self._serialize.url("self.notification_setting_name", self.notification_setting_name, 'str')
}
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')

# Construct headers
header_parameters = {}
header_parameters['Accept'] = 'application/json'
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
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 body
body_content = self._serialize.body(body, 'NotificationSetting')

# Construct and send request
request = self._client.put(url, query_parameters, header_parameters, body_content)
response = self._client.send(request, stream=False, **operation_config)

if response.status_code not in [200]:
raise models.ErrorResponseException(self._deserialize, response)

deserialized = None

if response.status_code == 200:
deserialized = self._deserialize('NotificationSetting', response)

if raw:
client_raw_response = ClientRawResponse(deserialized, response)
return client_raw_response

return deserialized
update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.WorkloadMonitor/notificationSettings/{notificationSettingName}'}