Skip to content

Commit

Permalink
[AutoPR applicationinsights/resource-manager] Add purge operations to…
Browse files Browse the repository at this point in the history
… AppInsights management plane (#2043)

* Generated from 891212c0bfb6b3267802c8984cf607d3242dcaac

Adding purge status operation

* Generated from aea5fabd66933d3377055411a89774f8e62692fd

capitalize response status
  • Loading branch information
AutorestCI committed Mar 7, 2018
1 parent 33557f7 commit 2f42d0c
Show file tree
Hide file tree
Showing 8 changed files with 309 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,21 @@ class ApplicationInsightsManagementClientConfiguration(AzureConfiguration):
object<msrestazure.azure_active_directory>`
:param subscription_id: The Azure subscription ID.
:type subscription_id: str
:param purge_id: In a purge status request, this is the Id of the
operation the status of which is returned.
:type purge_id: str
:param str base_url: Service URL
"""

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

if credentials is None:
raise ValueError("Parameter 'credentials' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")
if purge_id is None:
raise ValueError("Parameter 'purge_id' must not be None.")
if not base_url:
base_url = 'https://management.azure.com'

Expand All @@ -58,6 +63,7 @@ def __init__(

self.credentials = credentials
self.subscription_id = subscription_id
self.purge_id = purge_id


class ApplicationInsightsManagementClient(object):
Expand Down Expand Up @@ -96,13 +102,16 @@ class ApplicationInsightsManagementClient(object):
object<msrestazure.azure_active_directory>`
:param subscription_id: The Azure subscription ID.
:type subscription_id: str
:param purge_id: In a purge status request, this is the Id of the
operation the status of which is returned.
:type purge_id: str
:param str base_url: Service URL
"""

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

self.config = ApplicationInsightsManagementClientConfiguration(credentials, subscription_id, base_url)
self.config = ApplicationInsightsManagementClientConfiguration(credentials, subscription_id, purge_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 @@ -15,6 +15,10 @@
from .resource import Resource
from .tags_resource import TagsResource
from .application_insights_component import ApplicationInsightsComponent
from .component_purge_body_filters import ComponentPurgeBodyFilters
from .component_purge_body import ComponentPurgeBody
from .component_purge_response import ComponentPurgeResponse
from .component_purge_status_response import ComponentPurgeStatusResponse
from .web_test_geolocation import WebTestGeolocation
from .web_test_properties_configuration import WebTestPropertiesConfiguration
from .web_test import WebTest
Expand Down Expand Up @@ -45,6 +49,7 @@
ApplicationType,
FlowType,
RequestSource,
PurgeState,
WebTestKind,
)

Expand All @@ -55,6 +60,10 @@
'Resource',
'TagsResource',
'ApplicationInsightsComponent',
'ComponentPurgeBodyFilters',
'ComponentPurgeBody',
'ComponentPurgeResponse',
'ComponentPurgeStatusResponse',
'WebTestGeolocation',
'WebTestPropertiesConfiguration',
'WebTest',
Expand Down Expand Up @@ -84,5 +93,6 @@
'ApplicationType',
'FlowType',
'RequestSource',
'PurgeState',
'WebTestKind',
]
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ class RequestSource(Enum):
rest = "rest"


class PurgeState(Enum):

pending = "Pending"
completed = "Completed"


class WebTestKind(Enum):

ping = "ping"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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 ComponentPurgeBody(Model):
"""Describes the body of a purge request for an App Insights component.
:param table: Table from which to purge data.
:type table: str
:param filters: The set of columns and filters (queries) to run over them
to purge the resulting data.
:type filters:
list[~azure.mgmt.applicationinsights.models.ComponentPurgeBodyFilters]
"""

_validation = {
'table': {'required': True},
'filters': {'required': True},
}

_attribute_map = {
'table': {'key': 'table', 'type': 'str'},
'filters': {'key': 'filters', 'type': '[ComponentPurgeBodyFilters]'},
}

def __init__(self, table, filters):
super(ComponentPurgeBody, self).__init__()
self.table = table
self.filters = filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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 ComponentPurgeBodyFilters(Model):
"""User-defined filters to return data which will be purged from the table.
:param column: The column of the table over which the given query should
run
:type column: str
:param filter: A query to to run over the provided table and column to
purge the corresponding data.
:type filter: str
"""

_attribute_map = {
'column': {'key': 'column', 'type': 'str'},
'filter': {'key': 'filter', 'type': 'str'},
}

def __init__(self, column=None, filter=None):
super(ComponentPurgeBodyFilters, self).__init__()
self.column = column
self.filter = filter
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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 ComponentPurgeResponse(Model):
"""Response containing operationId for a specific purge action.
:param operation_id: Id to use when querying for status for a particular
purge operation.
:type operation_id: str
"""

_validation = {
'operation_id': {'required': True},
}

_attribute_map = {
'operation_id': {'key': 'operationId', 'type': 'str'},
}

def __init__(self, operation_id):
super(ComponentPurgeResponse, self).__init__()
self.operation_id = operation_id
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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 ComponentPurgeStatusResponse(Model):
"""Response containing status for a specific purge operation.
:param status: Status of the operation represented by the requested Id.
Possible values include: 'Pending', 'Completed'
:type status: str or ~azure.mgmt.applicationinsights.models.PurgeState
"""

_validation = {
'status': {'required': True},
}

_attribute_map = {
'status': {'key': 'status', 'type': 'str'},
}

def __init__(self, status):
super(ComponentPurgeStatusResponse, self).__init__()
self.status = status
Original file line number Diff line number Diff line change
Expand Up @@ -436,3 +436,145 @@ def update_tags(

return deserialized
update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}'}

def purge(
self, resource_group_name, resource_name, table, filters, custom_headers=None, raw=False, **operation_config):
"""Purges data in an Application Insights component by a set of
user-defined filters.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param resource_name: The name of the Application Insights component
resource.
:type resource_name: str
:param table: Table from which to purge data.
:type table: str
:param filters: The set of columns and filters (queries) to run over
them to purge the resulting data.
:type filters:
list[~azure.mgmt.applicationinsights.models.ComponentPurgeBodyFilters]
: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: ComponentPurgeResponse or ClientRawResponse if raw=true
:rtype: ~azure.mgmt.applicationinsights.models.ComponentPurgeResponse
or ~msrest.pipeline.ClientRawResponse
:raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
"""
body = models.ComponentPurgeBody(table=table, filters=filters)

# Construct URL
url = self.purge.metadata['url']
path_format_arguments = {
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
'resourceName': self._serialize.url("resource_name", resource_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['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, 'ComponentPurgeBody')

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

if response.status_code not in [202]:
exp = CloudError(response)
exp.request_id = response.headers.get('x-ms-request-id')
raise exp

deserialized = None

if response.status_code == 202:
deserialized = self._deserialize('ComponentPurgeResponse', response)

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

return deserialized
purge.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/purge'}

def get_purge_status(
self, resource_group_name, resource_name, custom_headers=None, raw=False, **operation_config):
"""Gets the status of a previously submitted purge using the id returned
from the original purge request.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param resource_name: The name of the Application Insights component
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: ComponentPurgeStatusResponse or ClientRawResponse if raw=true
:rtype:
~azure.mgmt.applicationinsights.models.ComponentPurgeStatusResponse or
~msrest.pipeline.ClientRawResponse
:raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
"""
# Construct URL
url = self.get_purge_status.metadata['url']
path_format_arguments = {
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
'resourceName': self._serialize.url("resource_name", resource_name, 'str'),
'purgeId': self._serialize.url("self.config.purge_id", self.config.purge_id, '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['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 and send request
request = self._client.get(url, query_parameters)
response = self._client.send(request, header_parameters, stream=False, **operation_config)

if response.status_code not in [200]:
exp = CloudError(response)
exp.request_id = response.headers.get('x-ms-request-id')
raise exp

deserialized = None

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

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

return deserialized
get_purge_status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/operations/{purgeId}'}

0 comments on commit 2f42d0c

Please sign in to comment.