diff --git a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/application_insights_management_client.py b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/application_insights_management_client.py index 4359650d15af..2d858aacfc17 100644 --- a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/application_insights_management_client.py +++ b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/application_insights_management_client.py @@ -28,6 +28,7 @@ from .operations.favorite_operations import FavoriteOperations from .operations.web_test_locations_operations import WebTestLocationsOperations from .operations.web_tests_operations import WebTestsOperations +from .operations.analytics_item_operations import AnalyticsItemOperations from .operations.workbooks_operations import WorkbooksOperations from .operations.workbook_operations import WorkbookOperations from . import models @@ -101,6 +102,8 @@ class ApplicationInsightsManagementClient(object): :vartype web_test_locations: azure.mgmt.applicationinsights.operations.WebTestLocationsOperations :ivar web_tests: WebTests operations :vartype web_tests: azure.mgmt.applicationinsights.operations.WebTestsOperations + :ivar analytics_item: AnalyticsItem operations + :vartype analytics_item: azure.mgmt.applicationinsights.operations.AnalyticsItemOperations :ivar workbooks: Workbooks operations :vartype workbooks: azure.mgmt.applicationinsights.operations.WorkbooksOperations :ivar workbook: Workbook operations @@ -155,6 +158,8 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.web_tests = WebTestsOperations( self._client, self.config, self._serialize, self._deserialize) + self.analytics_item = AnalyticsItemOperations( + self._client, self.config, self._serialize, self._deserialize) self.workbooks = WorkbooksOperations( self._client, self.config, self._serialize, self._deserialize) self.workbook = WorkbookOperations( diff --git a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/__init__.py b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/__init__.py index 08ae6c3b694d..d5461ffaf45e 100644 --- a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/__init__.py +++ b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/__init__.py @@ -43,6 +43,8 @@ from .web_test_geolocation import WebTestGeolocation from .web_test_properties_configuration import WebTestPropertiesConfiguration from .web_test import WebTest +from .application_insights_component_analytics_item_properties import ApplicationInsightsComponentAnalyticsItemProperties +from .application_insights_component_analytics_item import ApplicationInsightsComponentAnalyticsItem from .workbook import Workbook from .workbooks import Workbooks from .link_properties import LinkProperties @@ -60,8 +62,12 @@ PurgeState, FavoriteType, WebTestKind, + ItemScope, + ItemType, SharedTypeKind, FavoriteSourceType, + ItemScopePath, + ItemTypeParameter, CategoryType, ) @@ -100,6 +106,8 @@ 'WebTestGeolocation', 'WebTestPropertiesConfiguration', 'WebTest', + 'ApplicationInsightsComponentAnalyticsItemProperties', + 'ApplicationInsightsComponentAnalyticsItem', 'Workbook', 'Workbooks', 'LinkProperties', @@ -116,7 +124,11 @@ 'PurgeState', 'FavoriteType', 'WebTestKind', + 'ItemScope', + 'ItemType', 'SharedTypeKind', 'FavoriteSourceType', + 'ItemScopePath', + 'ItemTypeParameter', 'CategoryType', ] diff --git a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/application_insights_component_analytics_item.py b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/application_insights_component_analytics_item.py new file mode 100644 index 000000000000..1b11deb39442 --- /dev/null +++ b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/application_insights_component_analytics_item.py @@ -0,0 +1,76 @@ +# 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 ApplicationInsightsComponentAnalyticsItem(Model): + """Properties that define an Analytics item that is associated to an + Application Insights component. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :param id: Internally assigned unique id of the item definition. + :type id: str + :param name: The user-defined name of the item. + :type name: str + :param content: The content of this item + :type content: str + :ivar version: This instance's version of the data model. This can change + as new features are added. + :vartype version: str + :param scope: Enum indicating if this item definition is owned by a + specific user or is shared between all users with access to the + Application Insights component. Possible values include: 'shared', 'user' + :type scope: str or ~azure.mgmt.applicationinsights.models.ItemScope + :param type: Enum indicating the type of the Analytics item. Possible + values include: 'query', 'function', 'folder', 'recent' + :type type: str or ~azure.mgmt.applicationinsights.models.ItemType + :ivar time_created: Date and time in UTC when this item was created. + :vartype time_created: str + :ivar time_modified: Date and time in UTC of the last modification that + was made to this item. + :vartype time_modified: str + :param properties: + :type properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAnalyticsItemProperties + """ + + _validation = { + 'version': {'readonly': True}, + 'time_created': {'readonly': True}, + 'time_modified': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'Id', 'type': 'str'}, + 'name': {'key': 'Name', 'type': 'str'}, + 'content': {'key': 'Content', 'type': 'str'}, + 'version': {'key': 'Version', 'type': 'str'}, + 'scope': {'key': 'Scope', 'type': 'str'}, + 'type': {'key': 'Type', 'type': 'str'}, + 'time_created': {'key': 'TimeCreated', 'type': 'str'}, + 'time_modified': {'key': 'TimeModified', 'type': 'str'}, + 'properties': {'key': 'Properties', 'type': 'ApplicationInsightsComponentAnalyticsItemProperties'}, + } + + def __init__(self, id=None, name=None, content=None, scope=None, type=None, properties=None): + super(ApplicationInsightsComponentAnalyticsItem, self).__init__() + self.id = id + self.name = name + self.content = content + self.version = None + self.scope = scope + self.type = type + self.time_created = None + self.time_modified = None + self.properties = properties diff --git a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/application_insights_component_analytics_item_properties.py b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/application_insights_component_analytics_item_properties.py new file mode 100644 index 000000000000..9ef8b8996b16 --- /dev/null +++ b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/application_insights_component_analytics_item_properties.py @@ -0,0 +1,30 @@ +# 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 ApplicationInsightsComponentAnalyticsItemProperties(Model): + """A set of properties that can be defined in the context of a specific item + type. Each type may have its own properties. + + :param function_alias: A function alias, used when the type of the item is + Function + :type function_alias: str + """ + + _attribute_map = { + 'function_alias': {'key': 'functionAlias', 'type': 'str'}, + } + + def __init__(self, function_alias=None): + super(ApplicationInsightsComponentAnalyticsItemProperties, self).__init__() + self.function_alias = function_alias diff --git a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/application_insights_management_client_enums.py b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/application_insights_management_client_enums.py index 2c674b6c8366..9f47193bd8d7 100644 --- a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/application_insights_management_client_enums.py +++ b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/application_insights_management_client_enums.py @@ -46,6 +46,20 @@ class WebTestKind(Enum): multistep = "multistep" +class ItemScope(Enum): + + shared = "shared" + user = "user" + + +class ItemType(Enum): + + query = "query" + function = "function" + folder = "folder" + recent = "recent" + + class SharedTypeKind(Enum): user = "user" @@ -64,6 +78,21 @@ class FavoriteSourceType(Enum): segmentation = "segmentation" +class ItemScopePath(Enum): + + analytics_items = "analyticsItems" + myanalytics_items = "myanalyticsItems" + + +class ItemTypeParameter(Enum): + + none = "none" + query = "query" + function = "function" + folder = "folder" + recent = "recent" + + class CategoryType(Enum): workbook = "workbook" diff --git a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/component_purge_body_filters.py b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/component_purge_body_filters.py index 716d03491f25..39d2d8642002 100644 --- a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/component_purge_body_filters.py +++ b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/component_purge_body_filters.py @@ -18,17 +18,23 @@ class ComponentPurgeBodyFilters(Model): :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 + :param operator: A query operator to evaluate over the provided column and + value(s). + :type operator: str + :param value: the value for the operator to function over. This can be a + number (e.g., > 100), a string (timestamp >= '2017-09-01') or array of + values. + :type value: object """ _attribute_map = { 'column': {'key': 'column', 'type': 'str'}, - 'filter': {'key': 'filter', 'type': 'str'}, + 'operator': {'key': 'operator', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'object'}, } - def __init__(self, column=None, filter=None): + def __init__(self, column=None, operator=None, value=None): super(ComponentPurgeBodyFilters, self).__init__() self.column = column - self.filter = filter + self.operator = operator + self.value = value diff --git a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/operations/__init__.py b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/operations/__init__.py index 8b2ac082b781..5d80e59ee21c 100644 --- a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/operations/__init__.py +++ b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/operations/__init__.py @@ -24,6 +24,7 @@ from .favorite_operations import FavoriteOperations from .web_test_locations_operations import WebTestLocationsOperations from .web_tests_operations import WebTestsOperations +from .analytics_item_operations import AnalyticsItemOperations from .workbooks_operations import WorkbooksOperations from .workbook_operations import WorkbookOperations @@ -43,6 +44,7 @@ 'FavoriteOperations', 'WebTestLocationsOperations', 'WebTestsOperations', + 'AnalyticsItemOperations', 'WorkbooksOperations', 'WorkbookOperations', ] diff --git a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/operations/analytics_item_operations.py b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/operations/analytics_item_operations.py new file mode 100644 index 000000000000..2f96fd3e210a --- /dev/null +++ b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/operations/analytics_item_operations.py @@ -0,0 +1,371 @@ +# 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 msrestazure.azure_exceptions import CloudError + +from .. import models + + +class AnalyticsItemOperations(object): + """AnalyticsItemOperations 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: "2015-05-01". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2015-05-01" + + self.config = config + + def list( + self, resource_group_name, resource_name, scope_path, scope="shared", type="none", include_content=None, custom_headers=None, raw=False, **operation_config): + """Gets a list of Analytics Items defined within an Application Insights + component. + + :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 scope_path: Enum indicating if this item definition is owned by + a specific user or is shared between all users with access to the + Application Insights component. Possible values include: + 'analyticsItems', 'myanalyticsItems' + :type scope_path: str or + ~azure.mgmt.applicationinsights.models.ItemScopePath + :param scope: Enum indicating if this item definition is owned by a + specific user or is shared between all users with access to the + Application Insights component. Possible values include: 'shared', + 'user' + :type scope: str or ~azure.mgmt.applicationinsights.models.ItemScope + :param type: Enum indicating the type of the Analytics item. Possible + values include: 'none', 'query', 'function', 'folder', 'recent' + :type type: str or + ~azure.mgmt.applicationinsights.models.ItemTypeParameter + :param include_content: Flag indicating whether or not to return the + content of each applicable item. If false, only return the item + information. + :type include_content: bool + :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: list or ClientRawResponse if raw=true + :rtype: + list[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAnalyticsItem] + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.list.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + 'scopePath': self._serialize.url("scope_path", scope_path, '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') + if scope is not None: + query_parameters['scope'] = self._serialize.query("scope", scope, 'str') + if type is not None: + query_parameters['type'] = self._serialize.query("type", type, 'str') + if include_content is not None: + query_parameters['includeContent'] = self._serialize.query("include_content", include_content, 'bool') + + # 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('[ApplicationInsightsComponentAnalyticsItem]', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}'} + + def get( + self, resource_group_name, resource_name, scope_path, id=None, name=None, custom_headers=None, raw=False, **operation_config): + """Gets a specific Analytics Items defined within an Application Insights + component. + + :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 scope_path: Enum indicating if this item definition is owned by + a specific user or is shared between all users with access to the + Application Insights component. Possible values include: + 'analyticsItems', 'myanalyticsItems' + :type scope_path: str or + ~azure.mgmt.applicationinsights.models.ItemScopePath + :param id: The Id of a specific item defined in the Application + Insights component + :type id: str + :param name: The name of a specific item defined in the Application + Insights component + :type 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`. + :return: ApplicationInsightsComponentAnalyticsItem or + ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAnalyticsItem + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + 'scopePath': self._serialize.url("scope_path", scope_path, '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') + if id is not None: + query_parameters['id'] = self._serialize.query("id", id, 'str') + if name is not None: + query_parameters['name'] = self._serialize.query("name", name, '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('ApplicationInsightsComponentAnalyticsItem', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item'} + + def put( + self, resource_group_name, resource_name, scope_path, item_properties, override_item=None, custom_headers=None, raw=False, **operation_config): + """Adds or Updates a specific Analytics Item within an Application + Insights component. + + :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 scope_path: Enum indicating if this item definition is owned by + a specific user or is shared between all users with access to the + Application Insights component. Possible values include: + 'analyticsItems', 'myanalyticsItems' + :type scope_path: str or + ~azure.mgmt.applicationinsights.models.ItemScopePath + :param item_properties: Properties that need to be specified to create + a new item and add it to an Application Insights component. + :type item_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAnalyticsItem + :param override_item: Flag indicating whether or not to force save an + item. This allows overriding an item if it already exists. + :type override_item: bool + :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: ApplicationInsightsComponentAnalyticsItem or + ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAnalyticsItem + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.put.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + 'scopePath': self._serialize.url("scope_path", scope_path, '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') + if override_item is not None: + query_parameters['overrideItem'] = self._serialize.query("override_item", override_item, 'bool') + + # 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(item_properties, 'ApplicationInsightsComponentAnalyticsItem') + + # Construct and send request + request = self._client.put(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, 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('ApplicationInsightsComponentAnalyticsItem', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item'} + + def delete( + self, resource_group_name, resource_name, scope_path, id=None, name=None, custom_headers=None, raw=False, **operation_config): + """Deletes a specific Analytics Items defined within an Application + Insights component. + + :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 scope_path: Enum indicating if this item definition is owned by + a specific user or is shared between all users with access to the + Application Insights component. Possible values include: + 'analyticsItems', 'myanalyticsItems' + :type scope_path: str or + ~azure.mgmt.applicationinsights.models.ItemScopePath + :param id: The Id of a specific item defined in the Application + Insights component + :type id: str + :param name: The name of a specific item defined in the Application + Insights component + :type 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`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.delete.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + 'scopePath': self._serialize.url("scope_path", scope_path, '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') + if id is not None: + query_parameters['id'] = self._serialize.query("id", id, 'str') + if name is not None: + query_parameters['name'] = self._serialize.query("name", name, '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.delete(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 + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item'} diff --git a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/operations/components_operations.py b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/operations/components_operations.py index a8645ec2d1f3..6ef8925afec7 100644 --- a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/operations/components_operations.py +++ b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/operations/components_operations.py @@ -12,6 +12,8 @@ import uuid from msrest.pipeline import ClientRawResponse from msrestazure.azure_exceptions import CloudError +from msrest.exceptions import DeserializationError +from msrestazure.azure_operation import AzureOperationPoller from .. import models @@ -437,32 +439,9 @@ 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`. - :return: ComponentPurgeResponse or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.applicationinsights.models.ComponentPurgeResponse - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _purge_initial( + self, resource_group_name, resource_name, table, filters, custom_headers=None, raw=False, **operation_config): body = models.ComponentPurgeBody(table=table, filters=filters) # Construct URL @@ -496,13 +475,15 @@ def purge( response = self._client.send( request, header_parameters, body_content, stream=False, **operation_config) - if response.status_code not in [202]: + if response.status_code not in [200, 202]: 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 response.status_code == 202: deserialized = self._deserialize('ComponentPurgeResponse', response) @@ -511,73 +492,77 @@ def purge( 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, purge_id, custom_headers=None, raw=False, **operation_config): - """Gets the status of a previously submitted purge using the id returned - from the original purge request. + 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 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 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`. - :return: ComponentPurgeStatusResponse or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.applicationinsights.models.ComponentPurgeStatusResponse or + :return: An instance of AzureOperationPoller that returns object or + ClientRawResponse if raw=true + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[object] or ~msrest.pipeline.ClientRawResponse :raises: :class:`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("purge_id", purge_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) + raw_result = self._purge_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + table=table, + filters=filters, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + # Construct and send request + def long_running_send(): + return raw_result.response - # 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') + def get_long_running_status(status_link, headers=None): - # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) + request = self._client.get(status_link) + if headers: + request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] + return 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 + def get_long_running_output(response): - deserialized = None + if response.status_code not in [200, 202]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp - if response.status_code == 200: - deserialized = self._deserialize('ComponentPurgeStatusResponse', response) + deserialized = self._deserialize('object', response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_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}'} + return deserialized + + long_running_operation_timeout = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + return AzureOperationPoller( + long_running_send, get_long_running_output, + get_long_running_status, long_running_operation_timeout) + purge.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/purge'} diff --git a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/operations/workbook_operations.py b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/operations/workbook_operations.py index e24c527ce987..1b3f5e7a9976 100644 --- a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/operations/workbook_operations.py +++ b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/operations/workbook_operations.py @@ -36,9 +36,9 @@ def __init__(self, client, config, serializer, deserializer): self.config = config - def delete( + def get( self, resource_group_name, resource_name, location, custom_headers=None, raw=False, **operation_config): - """Delete a workbook. + """Get a single workbook by its resourceName. :param resource_group_name: The name of the resource group. :type resource_group_name: str @@ -52,13 +52,14 @@ def delete( deserialized response :param operation_config: :ref:`Operation configuration overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse + :return: Workbook or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.applicationinsights.models.Workbook or + ~msrest.pipeline.ClientRawResponse :raises: :class:`WorkbookErrorException` """ # Construct URL - url = self.delete.metadata['url'] + url = self.get.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), @@ -82,43 +83,47 @@ def delete( header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request - request = self._client.delete(url, query_parameters) + request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **operation_config) - if response.status_code not in [201, 204]: + if response.status_code not in [200]: raise models.WorkbookErrorException(self._deserialize, response) + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('Workbook', response) + if raw: - client_raw_response = ClientRawResponse(None, response) + client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}'} - def create_or_update( - self, resource_group_name, resource_name, workbook_properties, custom_headers=None, raw=False, **operation_config): - """Create a new workbook. + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}'} + + def delete( + self, resource_group_name, resource_name, location, custom_headers=None, raw=False, **operation_config): + """Delete a workbook. :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 workbook_properties: Properties that need to be specified to - create a new workbook. - :type workbook_properties: - ~azure.mgmt.applicationinsights.models.Workbook + :param location: The name of location where workbook is stored. + :type location: 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: Workbook or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.applicationinsights.models.Workbook or - ~msrest.pipeline.ClientRawResponse + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`WorkbookErrorException` """ # Construct URL - url = self.create_or_update.metadata['url'] + url = self.delete.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), @@ -128,6 +133,7 @@ def create_or_update( # Construct parameters query_parameters = {} + query_parameters['location'] = self._serialize.query("location", location, 'str') query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') # Construct headers @@ -140,34 +146,21 @@ def create_or_update( 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(workbook_properties, 'Workbook') - # Construct and send request - request = self._client.put(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.delete(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) - if response.status_code not in [200, 201]: + if response.status_code not in [201, 204]: raise models.WorkbookErrorException(self._deserialize, response) - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('Workbook', response) - if response.status_code == 201: - deserialized = self._deserialize('Workbook', response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response = ClientRawResponse(None, response) return client_raw_response + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}'} - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}'} - - def update( + def create_or_update( self, resource_group_name, resource_name, workbook_properties, custom_headers=None, raw=False, **operation_config): - """Updates a workbook that has already been added. + """Create a new workbook. :param resource_group_name: The name of the resource group. :type resource_group_name: str @@ -190,7 +183,7 @@ def update( :class:`WorkbookErrorException` """ # Construct URL - url = self.update.metadata['url'] + url = self.create_or_update.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), @@ -216,34 +209,40 @@ def update( body_content = self._serialize.body(workbook_properties, 'Workbook') # Construct and send request - request = self._client.patch(url, query_parameters) + request = self._client.put(url, query_parameters) response = self._client.send( request, header_parameters, body_content, stream=False, **operation_config) - if response.status_code not in [200]: + if response.status_code not in [200, 201]: raise models.WorkbookErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('Workbook', response) + if response.status_code == 201: + deserialized = self._deserialize('Workbook', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}'} - def get( - self, resource_name, location, custom_headers=None, raw=False, **operation_config): - """Get a single workbook by its resourceName. + def update( + self, resource_group_name, resource_name, workbook_properties, custom_headers=None, raw=False, **operation_config): + """Updates a workbook that has already been added. + :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 location: The name of location where workbook is stored. - :type location: str + :param workbook_properties: Properties that need to be specified to + create a new workbook. + :type workbook_properties: + ~azure.mgmt.applicationinsights.models.Workbook :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -256,16 +255,16 @@ def get( :class:`WorkbookErrorException` """ # Construct URL - url = self.get.metadata['url'] + url = self.update.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, '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['location'] = self._serialize.query("location", location, 'str') query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') # Construct headers @@ -278,83 +277,13 @@ def get( 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]: - raise models.WorkbookErrorException(self._deserialize, response) - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('Workbook', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/workbooks/{resourceName}'} - - def list( - self, source_id, category, tags=None, can_fetch_content=None, custom_headers=None, raw=False, **operation_config): - """Gets a list of workbooks by sourceId. - - :param source_id: Azure Resource Id that will fetch all linked - workbooks. - :type source_id: str - :param category: Category of workbook to return. Possible values - include: 'workbook', 'TSG', 'performance', 'retention' - :type category: str or - ~azure.mgmt.applicationinsights.models.CategoryType - :param tags: Tags presents on each workbook returned. - :type tags: list[str] - :param can_fetch_content: Flag indicating whether or not to return the - full content for each applicable workbook. If false, only return - summary content for workbooks. - :type can_fetch_content: bool - :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: list or ClientRawResponse if raw=true - :rtype: list[~azure.mgmt.applicationinsights.models.Workbook] or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`WorkbookErrorException` - """ - # Construct URL - url = self.list.metadata['url'] - path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['sourceId'] = self._serialize.query("source_id", source_id, 'str') - query_parameters['category'] = self._serialize.query("category", category, 'str') - if tags is not None: - query_parameters['tags'] = self._serialize.query("tags", tags, '[str]', div=',') - if can_fetch_content is not None: - query_parameters['canFetchContent'] = self._serialize.query("can_fetch_content", can_fetch_content, 'bool') - 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(workbook_properties, 'Workbook') # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) + request = self._client.patch(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200]: raise models.WorkbookErrorException(self._deserialize, response) @@ -362,11 +291,11 @@ def list( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('[Workbook]', response) + deserialized = self._deserialize('Workbook', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/workbooks'} + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}'}