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 f093d5df3465..4359650d15af 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,8 @@ from .operations.favorite_operations import FavoriteOperations from .operations.web_test_locations_operations import WebTestLocationsOperations from .operations.web_tests_operations import WebTestsOperations +from .operations.workbooks_operations import WorkbooksOperations +from .operations.workbook_operations import WorkbookOperations from . import models @@ -99,6 +101,10 @@ 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 workbooks: Workbooks operations + :vartype workbooks: azure.mgmt.applicationinsights.operations.WorkbooksOperations + :ivar workbook: Workbook operations + :vartype workbook: azure.mgmt.applicationinsights.operations.WorkbookOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials @@ -149,3 +155,7 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.web_tests = WebTestsOperations( self._client, self.config, self._serialize, self._deserialize) + self.workbooks = WorkbooksOperations( + self._client, self.config, self._serialize, self._deserialize) + self.workbook = WorkbookOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/__init__.py b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/__init__.py index e794f75607f8..08ae6c3b694d 100644 --- a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/__init__.py +++ b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/__init__.py @@ -43,6 +43,11 @@ from .web_test_geolocation import WebTestGeolocation from .web_test_properties_configuration import WebTestPropertiesConfiguration from .web_test import WebTest +from .workbook import Workbook +from .workbooks import Workbooks +from .link_properties import LinkProperties +from .error_field_contract import ErrorFieldContract +from .workbook_error import WorkbookError, WorkbookErrorException from .operation_paged import OperationPaged from .application_insights_component_api_key_paged import ApplicationInsightsComponentAPIKeyPaged from .application_insights_component_paged import ApplicationInsightsComponentPaged @@ -55,7 +60,9 @@ PurgeState, FavoriteType, WebTestKind, + SharedTypeKind, FavoriteSourceType, + CategoryType, ) __all__ = [ @@ -93,6 +100,11 @@ 'WebTestGeolocation', 'WebTestPropertiesConfiguration', 'WebTest', + 'Workbook', + 'Workbooks', + 'LinkProperties', + 'ErrorFieldContract', + 'WorkbookError', 'WorkbookErrorException', 'OperationPaged', 'ApplicationInsightsComponentAPIKeyPaged', 'ApplicationInsightsComponentPaged', @@ -104,5 +116,7 @@ 'PurgeState', 'FavoriteType', 'WebTestKind', + 'SharedTypeKind', 'FavoriteSourceType', + 'CategoryType', ] 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 c97aa116b0f0..2c674b6c8366 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,12 @@ class WebTestKind(Enum): multistep = "multistep" +class SharedTypeKind(Enum): + + user = "user" + shared = "shared" + + class FavoriteSourceType(Enum): retention = "retention" @@ -56,3 +62,11 @@ class FavoriteSourceType(Enum): funnel = "funnel" impact = "impact" segmentation = "segmentation" + + +class CategoryType(Enum): + + workbook = "workbook" + tsg = "TSG" + performance = "performance" + retention = "retention" diff --git a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/error_field_contract.py b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/error_field_contract.py new file mode 100644 index 000000000000..2fb02530e91d --- /dev/null +++ b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/error_field_contract.py @@ -0,0 +1,36 @@ +# 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 ErrorFieldContract(Model): + """Error Field contract. + + :param code: Property level error code. + :type code: str + :param message: Human-readable representation of property-level error. + :type message: str + :param target: Property name. + :type target: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + } + + def __init__(self, code=None, message=None, target=None): + super(ErrorFieldContract, self).__init__() + self.code = code + self.message = message + self.target = target diff --git a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/link_properties.py b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/link_properties.py new file mode 100644 index 000000000000..3319a7f4d0a3 --- /dev/null +++ b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/link_properties.py @@ -0,0 +1,36 @@ +# 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 LinkProperties(Model): + """Contains a sourceId and workbook resource id to link two resources. + + :param source_id: The source Azure resource id + :type source_id: str + :param target_id: The workbook Azure resource id + :type target_id: str + :param category: The category of workbook + :type category: str + """ + + _attribute_map = { + 'source_id': {'key': 'sourceId', 'type': 'str'}, + 'target_id': {'key': 'targetId', 'type': 'str'}, + 'category': {'key': 'category', 'type': 'str'}, + } + + def __init__(self, source_id=None, target_id=None, category=None): + super(LinkProperties, self).__init__() + self.source_id = source_id + self.target_id = target_id + self.category = category diff --git a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/workbook.py b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/workbook.py new file mode 100644 index 000000000000..176aef106a65 --- /dev/null +++ b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/workbook.py @@ -0,0 +1,112 @@ +# 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 .resource import Resource + + +class Workbook(Resource): + """An Application Insights workbook definition. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Azure resource Id + :vartype id: str + :ivar name: Azure resource name + :vartype name: str + :ivar type: Azure resource type + :vartype type: str + :param location: Resource location + :type location: str + :param tags: Resource tags + :type tags: dict[str, str] + :param kind: The kind of workbook. Choices are user and shared. Possible + values include: 'user', 'shared' + :type kind: str or ~azure.mgmt.applicationinsights.models.SharedTypeKind + :param workbook_name: The user-defined name of the workbook. + :type workbook_name: str + :param serialized_data: Configuration of this particular workbook. + Configuration data is a string containing valid JSON + :type serialized_data: str + :param version: This instance's version of the data model. This can change + as new features are added that can be marked workbook. + :type version: str + :param workbook_id: Internally assigned unique id of the workbook + definition. + :type workbook_id: str + :param shared_type_kind: Enum indicating if this workbook definition is + owned by a specific user or is shared between all users with access to the + Application Insights component. Possible values include: 'user', 'shared'. + Default value: "shared" . + :type shared_type_kind: str or + ~azure.mgmt.applicationinsights.models.SharedTypeKind + :ivar time_modified: Date and time in UTC of the last modification that + was made to this workbook definition. + :vartype time_modified: str + :param category: Workbook category, as defined by the user at creation + time. + :type category: str + :param workbook_tags: A list of 0 or more tags that are associated with + this workbook definition + :type workbook_tags: list[str] + :param user_id: Unique user id of the specific user that owns this + workbook. + :type user_id: str + :param source_resource_id: Optional resourceId for a source resource. + :type source_resource_id: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'workbook_name': {'required': True}, + 'serialized_data': {'required': True}, + 'workbook_id': {'required': True}, + 'shared_type_kind': {'required': True}, + 'time_modified': {'readonly': True}, + 'category': {'required': True}, + 'user_id': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'workbook_name': {'key': 'properties.name', 'type': 'str'}, + 'serialized_data': {'key': 'properties.serializedData', 'type': 'str'}, + 'version': {'key': 'properties.version', 'type': 'str'}, + 'workbook_id': {'key': 'properties.workbookId', 'type': 'str'}, + 'shared_type_kind': {'key': 'properties.kind', 'type': 'str'}, + 'time_modified': {'key': 'properties.timeModified', 'type': 'str'}, + 'category': {'key': 'properties.category', 'type': 'str'}, + 'workbook_tags': {'key': 'properties.tags', 'type': '[str]'}, + 'user_id': {'key': 'properties.userId', 'type': 'str'}, + 'source_resource_id': {'key': 'properties.sourceResourceId', 'type': 'str'}, + } + + def __init__(self, location, workbook_name, serialized_data, workbook_id, category, user_id, tags=None, kind=None, version=None, shared_type_kind="shared", workbook_tags=None, source_resource_id=None): + super(Workbook, self).__init__(location=location, tags=tags) + self.kind = kind + self.workbook_name = workbook_name + self.serialized_data = serialized_data + self.version = version + self.workbook_id = workbook_id + self.shared_type_kind = shared_type_kind + self.time_modified = None + self.category = category + self.workbook_tags = workbook_tags + self.user_id = user_id + self.source_resource_id = source_resource_id diff --git a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/workbook_error.py b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/workbook_error.py new file mode 100644 index 000000000000..754d976046d0 --- /dev/null +++ b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/workbook_error.py @@ -0,0 +1,52 @@ +# 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 +from msrest.exceptions import HttpOperationError + + +class WorkbookError(Model): + """Error message body that will indicate why the operation failed. + + :param code: Service-defined error code. This code serves as a sub-status + for the HTTP error code specified in the response. + :type code: str + :param message: Human-readable representation of the error. + :type message: str + :param details: The list of invalid fields send in request, in case of + validation error. + :type details: + list[~azure.mgmt.applicationinsights.models.ErrorFieldContract] + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorFieldContract]'}, + } + + def __init__(self, code=None, message=None, details=None): + super(WorkbookError, self).__init__() + self.code = code + self.message = message + self.details = details + + +class WorkbookErrorException(HttpOperationError): + """Server responsed with exception of type: 'WorkbookError'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(WorkbookErrorException, self).__init__(deserialize, response, 'WorkbookError', *args) diff --git a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/workbooks.py b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/workbooks.py new file mode 100644 index 000000000000..fe59aec37ce0 --- /dev/null +++ b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/models/workbooks.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 Workbooks(Model): + """Workbook list result. + + :param value: An array of workbooks. + :type value: list[~azure.mgmt.applicationinsights.models.Workbook] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Workbook]'}, + } + + def __init__(self, value=None): + super(Workbooks, self).__init__() + 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 21a96abfc775..8b2ac082b781 100644 --- a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/operations/__init__.py +++ b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/operations/__init__.py @@ -24,6 +24,8 @@ from .favorite_operations import FavoriteOperations from .web_test_locations_operations import WebTestLocationsOperations from .web_tests_operations import WebTestsOperations +from .workbooks_operations import WorkbooksOperations +from .workbook_operations import WorkbookOperations __all__ = [ 'Operations', @@ -41,4 +43,6 @@ 'FavoriteOperations', 'WebTestLocationsOperations', 'WebTestsOperations', + 'WorkbooksOperations', + 'WorkbookOperations', ] diff --git a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/operations/workbook_operations.py b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/operations/workbook_operations.py new file mode 100644 index 000000000000..e24c527ce987 --- /dev/null +++ b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/operations/workbook_operations.py @@ -0,0 +1,372 @@ +# 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 WorkbookOperations(object): + """WorkbookOperations 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 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 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: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`WorkbookErrorException` + """ + # 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') + } + 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 + 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 [201, 204]: + raise models.WorkbookErrorException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, 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. + + :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 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 + :raises: + :class:`WorkbookErrorException` + """ + # Construct 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'), + '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(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) + + 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 + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{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 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 + :param operation_config: :ref:`Operation configuration + overrides`. + :return: Workbook or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.applicationinsights.models.Workbook or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`WorkbookErrorException` + """ + # Construct 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['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.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) + + 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 + 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. + + :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 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 + :raises: + :class:`WorkbookErrorException` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + '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['location'] = self._serialize.query("location", location, 'str') + 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]: + 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 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 + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/workbooks'} diff --git a/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/operations/workbooks_operations.py b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/operations/workbooks_operations.py new file mode 100644 index 000000000000..3a4ac53c7bf0 --- /dev/null +++ b/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/operations/workbooks_operations.py @@ -0,0 +1,114 @@ +# 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 WorkbooksOperations(object): + """WorkbooksOperations 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_by_resource_group( + self, resource_group_name, location, category, tags=None, can_fetch_content=None, custom_headers=None, raw=False, **operation_config): + """Get all Workbooks defined within a specified resource group and + category. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param location: The name of location where workbook is stored. + :type location: 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: Workbooks or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.applicationinsights.models.Workbooks or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`WorkbookErrorException` + """ + # Construct URL + url = self.list_by_resource_group.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') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['location'] = self._serialize.query("location", location, '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 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('Workbooks', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks'}