diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 0609ad090fcf..483fd98d56c6 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -4,6 +4,7 @@ /azure-batch/ @annatisch @matthchr /azure-keyvault/ @schaabs +/azure-loganalytics/ @alexeldeib /azure-mgmt-batch/ @annatisch @matthchr /azure-mgmt-batchai/ @AlexanderYukhanov /azure-mgmt-cdn/ @tjprescott diff --git a/azure-loganalytics/HISTORY.rst b/azure-loganalytics/HISTORY.rst new file mode 100644 index 000000000000..1be0570ff0b0 --- /dev/null +++ b/azure-loganalytics/HISTORY.rst @@ -0,0 +1,9 @@ +.. :changelog: + +Release History +=============== + +0.1.0 (2018-07-11) +++++++++++++++++++ + +* Initial Release diff --git a/azure-loganalytics/MANIFEST.in b/azure-loganalytics/MANIFEST.in new file mode 100644 index 000000000000..9ecaeb15de50 --- /dev/null +++ b/azure-loganalytics/MANIFEST.in @@ -0,0 +1,2 @@ +include *.rst +include azure_bdist_wheel.py \ No newline at end of file diff --git a/azure-loganalytics/README.rst b/azure-loganalytics/README.rst new file mode 100644 index 000000000000..f4f4204ffd17 --- /dev/null +++ b/azure-loganalytics/README.rst @@ -0,0 +1,43 @@ +Microsoft Azure SDK for Python +============================== + +This is the Microsoft Azure Log Analytics Client Library. + +This package has been tested with Python 2.7, 3.4, 3.5 and 3.6. + +For a more complete set of Azure libraries, see the `azure `__ bundle package. + + +Compatibility +============= + +**IMPORTANT**: If you have an earlier version of the azure package +(version < 1.0), you should uninstall it before installing this package. + +You can check the version using pip: + +.. code:: shell + + pip freeze + +If you see azure==0.11.0 (or any version below 1.0), uninstall it first: + +.. code:: shell + + pip uninstall azure + + +Usage +===== + +For code examples, see `Log Analytics +`__ +on docs.microsoft.com. + + +Provide Feedback +================ + +If you encounter any bugs or have suggestions, please file an issue in the +`Issues `__ +section of the project. diff --git a/azure-loganalytics/azure/__init__.py b/azure-loganalytics/azure/__init__.py new file mode 100644 index 000000000000..de40ea7ca058 --- /dev/null +++ b/azure-loganalytics/azure/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/azure-loganalytics/azure/loganalytics/__init__.py b/azure-loganalytics/azure/loganalytics/__init__.py new file mode 100644 index 000000000000..b26c9dd64784 --- /dev/null +++ b/azure-loganalytics/azure/loganalytics/__init__.py @@ -0,0 +1,18 @@ +# 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 .log_analytics_data_client import LogAnalyticsDataClient +from .version import VERSION + +__all__ = ['LogAnalyticsDataClient'] + +__version__ = VERSION + diff --git a/azure-loganalytics/azure/loganalytics/log_analytics_data_client.py b/azure-loganalytics/azure/loganalytics/log_analytics_data_client.py new file mode 100644 index 000000000000..75521bb6886b --- /dev/null +++ b/azure-loganalytics/azure/loganalytics/log_analytics_data_client.py @@ -0,0 +1,132 @@ +# 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.service_client import SDKClient +from msrest import Configuration, Serializer, Deserializer +from .version import VERSION +from msrest.pipeline import ClientRawResponse +from . import models + + +class LogAnalyticsDataClientConfiguration(Configuration): + """Configuration for LogAnalyticsDataClient + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credentials: Subscription credentials which uniquely identify + client subscription. + :type credentials: None + :param str base_url: Service URL + """ + + def __init__( + self, credentials, base_url=None): + + if credentials is None: + raise ValueError("Parameter 'credentials' must not be None.") + if not base_url: + base_url = 'https://api.loganalytics.io/v1' + + super(LogAnalyticsDataClientConfiguration, self).__init__(base_url) + + self.add_user_agent('azure-loganalytics/{}'.format(VERSION)) + + self.credentials = credentials + + +class LogAnalyticsDataClient(SDKClient): + """Log Analytics Data Plane Client + + :ivar config: Configuration for client. + :vartype config: LogAnalyticsDataClientConfiguration + + :param credentials: Subscription credentials which uniquely identify + client subscription. + :type credentials: None + :param str base_url: Service URL + """ + + def __init__( + self, credentials, base_url=None): + + self.config = LogAnalyticsDataClientConfiguration(credentials, base_url) + super(LogAnalyticsDataClient, self).__init__(self.config.credentials, self.config) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self.api_version = 'v1' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + + def query( + self, workspace_id, body, custom_headers=None, raw=False, **operation_config): + """Execute an Analytics query. + + Executes an Analytics query for data. + [Here](https://dev.loganalytics.io/documentation/Using-the-API) is an + example for using POST with an Analytics query. + + :param workspace_id: ID of the workspace. This is Workspace ID from + the Properties blade in the Azure portal. + :type workspace_id: str + :param body: The Analytics query. Learn more about the [Analytics + query + syntax](https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/) + :type body: ~azure.loganalytics.models.QueryBody + :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: QueryResults or ClientRawResponse if raw=true + :rtype: ~azure.loganalytics.models.QueryResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.query.metadata['url'] + path_format_arguments = { + 'workspaceId': self._serialize.url("workspace_id", workspace_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(body, 'QueryBody') + + # 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 [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('QueryResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + query.metadata = {'url': '/workspaces/{workspaceId}/query'} diff --git a/azure-loganalytics/azure/loganalytics/models/__init__.py b/azure-loganalytics/azure/loganalytics/models/__init__.py new file mode 100644 index 000000000000..14fa816d7ba5 --- /dev/null +++ b/azure-loganalytics/azure/loganalytics/models/__init__.py @@ -0,0 +1,37 @@ +# 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. +# -------------------------------------------------------------------------- + +try: + from .query_body_py3 import QueryBody + from .column_py3 import Column + from .table_py3 import Table + from .query_results_py3 import QueryResults + from .error_detail_py3 import ErrorDetail + from .error_info_py3 import ErrorInfo + from .error_response_py3 import ErrorResponse, ErrorResponseException +except (SyntaxError, ImportError): + from .query_body import QueryBody + from .column import Column + from .table import Table + from .query_results import QueryResults + from .error_detail import ErrorDetail + from .error_info import ErrorInfo + from .error_response import ErrorResponse, ErrorResponseException + +__all__ = [ + 'QueryBody', + 'Column', + 'Table', + 'QueryResults', + 'ErrorDetail', + 'ErrorInfo', + 'ErrorResponse', 'ErrorResponseException', +] diff --git a/azure-loganalytics/azure/loganalytics/models/column.py b/azure-loganalytics/azure/loganalytics/models/column.py new file mode 100644 index 000000000000..fde9b294d351 --- /dev/null +++ b/azure-loganalytics/azure/loganalytics/models/column.py @@ -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 Column(Model): + """A table column. + + A column in a table. + + :param name: The name of this column. + :type name: str + :param type: The data type of this column. + :type type: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(Column, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.type = kwargs.get('type', None) diff --git a/azure-loganalytics/azure/loganalytics/models/column_py3.py b/azure-loganalytics/azure/loganalytics/models/column_py3.py new file mode 100644 index 000000000000..4df2ac58398f --- /dev/null +++ b/azure-loganalytics/azure/loganalytics/models/column_py3.py @@ -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 Column(Model): + """A table column. + + A column in a table. + + :param name: The name of this column. + :type name: str + :param type: The data type of this column. + :type type: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__(self, *, name: str=None, type: str=None, **kwargs) -> None: + super(Column, self).__init__(**kwargs) + self.name = name + self.type = type diff --git a/azure-loganalytics/azure/loganalytics/models/error_detail.py b/azure-loganalytics/azure/loganalytics/models/error_detail.py new file mode 100644 index 000000000000..3fd620dffa45 --- /dev/null +++ b/azure-loganalytics/azure/loganalytics/models/error_detail.py @@ -0,0 +1,58 @@ +# 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 ErrorDetail(Model): + """Error details. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. The error's code. + :type code: str + :param message: Required. A human readable error message. + :type message: str + :param target: Indicates which property in the request is responsible for + the error. + :type target: str + :param value: Indicates which value in 'target' is responsible for the + error. + :type value: str + :param resources: Indicates resources which were responsible for the + error. + :type resources: list[str] + :param additional_properties: + :type additional_properties: object + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + 'resources': {'key': 'resources', 'type': '[str]'}, + 'additional_properties': {'key': 'additionalProperties', 'type': 'object'}, + } + + def __init__(self, **kwargs): + super(ErrorDetail, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + self.target = kwargs.get('target', None) + self.value = kwargs.get('value', None) + self.resources = kwargs.get('resources', None) + self.additional_properties = kwargs.get('additional_properties', None) diff --git a/azure-loganalytics/azure/loganalytics/models/error_detail_py3.py b/azure-loganalytics/azure/loganalytics/models/error_detail_py3.py new file mode 100644 index 000000000000..8c714de89d18 --- /dev/null +++ b/azure-loganalytics/azure/loganalytics/models/error_detail_py3.py @@ -0,0 +1,58 @@ +# 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 ErrorDetail(Model): + """Error details. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. The error's code. + :type code: str + :param message: Required. A human readable error message. + :type message: str + :param target: Indicates which property in the request is responsible for + the error. + :type target: str + :param value: Indicates which value in 'target' is responsible for the + error. + :type value: str + :param resources: Indicates resources which were responsible for the + error. + :type resources: list[str] + :param additional_properties: + :type additional_properties: object + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + 'resources': {'key': 'resources', 'type': '[str]'}, + 'additional_properties': {'key': 'additionalProperties', 'type': 'object'}, + } + + def __init__(self, *, code: str, message: str, target: str=None, value: str=None, resources=None, additional_properties=None, **kwargs) -> None: + super(ErrorDetail, self).__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.value = value + self.resources = resources + self.additional_properties = additional_properties diff --git a/azure-loganalytics/azure/loganalytics/models/error_info.py b/azure-loganalytics/azure/loganalytics/models/error_info.py new file mode 100644 index 000000000000..60b1bff092d7 --- /dev/null +++ b/azure-loganalytics/azure/loganalytics/models/error_info.py @@ -0,0 +1,51 @@ +# 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 ErrorInfo(Model): + """The code and message for an error. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. A machine readable error code. + :type code: str + :param message: Required. A human readable error message. + :type message: str + :param details: error details. + :type details: list[~azure.loganalytics.models.ErrorDetail] + :param innererror: Inner error details if they exist. + :type innererror: ~azure.loganalytics.models.ErrorInfo + :param additional_properties: + :type additional_properties: object + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDetail]'}, + 'innererror': {'key': 'innererror', 'type': 'ErrorInfo'}, + 'additional_properties': {'key': 'additionalProperties', 'type': 'object'}, + } + + def __init__(self, **kwargs): + super(ErrorInfo, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + self.details = kwargs.get('details', None) + self.innererror = kwargs.get('innererror', None) + self.additional_properties = kwargs.get('additional_properties', None) diff --git a/azure-loganalytics/azure/loganalytics/models/error_info_py3.py b/azure-loganalytics/azure/loganalytics/models/error_info_py3.py new file mode 100644 index 000000000000..1692b9d1696a --- /dev/null +++ b/azure-loganalytics/azure/loganalytics/models/error_info_py3.py @@ -0,0 +1,51 @@ +# 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 ErrorInfo(Model): + """The code and message for an error. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. A machine readable error code. + :type code: str + :param message: Required. A human readable error message. + :type message: str + :param details: error details. + :type details: list[~azure.loganalytics.models.ErrorDetail] + :param innererror: Inner error details if they exist. + :type innererror: ~azure.loganalytics.models.ErrorInfo + :param additional_properties: + :type additional_properties: object + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDetail]'}, + 'innererror': {'key': 'innererror', 'type': 'ErrorInfo'}, + 'additional_properties': {'key': 'additionalProperties', 'type': 'object'}, + } + + def __init__(self, *, code: str, message: str, details=None, innererror=None, additional_properties=None, **kwargs) -> None: + super(ErrorInfo, self).__init__(**kwargs) + self.code = code + self.message = message + self.details = details + self.innererror = innererror + self.additional_properties = additional_properties diff --git a/azure-loganalytics/azure/loganalytics/models/error_response.py b/azure-loganalytics/azure/loganalytics/models/error_response.py new file mode 100644 index 000000000000..8ecb3f3ed702 --- /dev/null +++ b/azure-loganalytics/azure/loganalytics/models/error_response.py @@ -0,0 +1,49 @@ +# 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 ErrorResponse(Model): + """Error details. + + Contains details when the response code indicates an error. + + All required parameters must be populated in order to send to Azure. + + :param error: Required. The error details. + :type error: ~azure.loganalytics.models.ErrorInfo + """ + + _validation = { + 'error': {'required': True}, + } + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorInfo'}, + } + + def __init__(self, **kwargs): + super(ErrorResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class ErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) diff --git a/azure-loganalytics/azure/loganalytics/models/error_response_py3.py b/azure-loganalytics/azure/loganalytics/models/error_response_py3.py new file mode 100644 index 000000000000..d12bb2b0a344 --- /dev/null +++ b/azure-loganalytics/azure/loganalytics/models/error_response_py3.py @@ -0,0 +1,49 @@ +# 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 ErrorResponse(Model): + """Error details. + + Contains details when the response code indicates an error. + + All required parameters must be populated in order to send to Azure. + + :param error: Required. The error details. + :type error: ~azure.loganalytics.models.ErrorInfo + """ + + _validation = { + 'error': {'required': True}, + } + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorInfo'}, + } + + def __init__(self, *, error, **kwargs) -> None: + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class ErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) diff --git a/azure-loganalytics/azure/loganalytics/models/query_body.py b/azure-loganalytics/azure/loganalytics/models/query_body.py new file mode 100644 index 000000000000..255d440bed40 --- /dev/null +++ b/azure-loganalytics/azure/loganalytics/models/query_body.py @@ -0,0 +1,45 @@ +# 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 QueryBody(Model): + """The Analytics query. Learn more about the [Analytics query + syntax](https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/). + + All required parameters must be populated in order to send to Azure. + + :param query: Required. The query to execute. + :type query: str + :param timespan: Optional. The timespan over which to query data. This is + an ISO8601 time period value. This timespan is applied in addition to any + that are specified in the query expression. + :type timespan: str + :param workspaces: A list of workspaces that are included in the query. + :type workspaces: list[str] + """ + + _validation = { + 'query': {'required': True}, + } + + _attribute_map = { + 'query': {'key': 'query', 'type': 'str'}, + 'timespan': {'key': 'timespan', 'type': 'str'}, + 'workspaces': {'key': 'workspaces', 'type': '[str]'}, + } + + def __init__(self, **kwargs): + super(QueryBody, self).__init__(**kwargs) + self.query = kwargs.get('query', None) + self.timespan = kwargs.get('timespan', None) + self.workspaces = kwargs.get('workspaces', None) diff --git a/azure-loganalytics/azure/loganalytics/models/query_body_py3.py b/azure-loganalytics/azure/loganalytics/models/query_body_py3.py new file mode 100644 index 000000000000..65d455bd0103 --- /dev/null +++ b/azure-loganalytics/azure/loganalytics/models/query_body_py3.py @@ -0,0 +1,45 @@ +# 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 QueryBody(Model): + """The Analytics query. Learn more about the [Analytics query + syntax](https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/). + + All required parameters must be populated in order to send to Azure. + + :param query: Required. The query to execute. + :type query: str + :param timespan: Optional. The timespan over which to query data. This is + an ISO8601 time period value. This timespan is applied in addition to any + that are specified in the query expression. + :type timespan: str + :param workspaces: A list of workspaces that are included in the query. + :type workspaces: list[str] + """ + + _validation = { + 'query': {'required': True}, + } + + _attribute_map = { + 'query': {'key': 'query', 'type': 'str'}, + 'timespan': {'key': 'timespan', 'type': 'str'}, + 'workspaces': {'key': 'workspaces', 'type': '[str]'}, + } + + def __init__(self, *, query: str, timespan: str=None, workspaces=None, **kwargs) -> None: + super(QueryBody, self).__init__(**kwargs) + self.query = query + self.timespan = timespan + self.workspaces = workspaces diff --git a/azure-loganalytics/azure/loganalytics/models/query_results.py b/azure-loganalytics/azure/loganalytics/models/query_results.py new file mode 100644 index 000000000000..a13f3c811b7c --- /dev/null +++ b/azure-loganalytics/azure/loganalytics/models/query_results.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 QueryResults(Model): + """A query response. + + Contains the tables, columns & rows resulting from a query. + + All required parameters must be populated in order to send to Azure. + + :param tables: Required. The list of tables, columns and rows. + :type tables: list[~azure.loganalytics.models.Table] + """ + + _validation = { + 'tables': {'required': True}, + } + + _attribute_map = { + 'tables': {'key': 'tables', 'type': '[Table]'}, + } + + def __init__(self, **kwargs): + super(QueryResults, self).__init__(**kwargs) + self.tables = kwargs.get('tables', None) diff --git a/azure-loganalytics/azure/loganalytics/models/query_results_py3.py b/azure-loganalytics/azure/loganalytics/models/query_results_py3.py new file mode 100644 index 000000000000..a9265f7bcbfb --- /dev/null +++ b/azure-loganalytics/azure/loganalytics/models/query_results_py3.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 QueryResults(Model): + """A query response. + + Contains the tables, columns & rows resulting from a query. + + All required parameters must be populated in order to send to Azure. + + :param tables: Required. The list of tables, columns and rows. + :type tables: list[~azure.loganalytics.models.Table] + """ + + _validation = { + 'tables': {'required': True}, + } + + _attribute_map = { + 'tables': {'key': 'tables', 'type': '[Table]'}, + } + + def __init__(self, *, tables, **kwargs) -> None: + super(QueryResults, self).__init__(**kwargs) + self.tables = tables diff --git a/azure-loganalytics/azure/loganalytics/models/table.py b/azure-loganalytics/azure/loganalytics/models/table.py new file mode 100644 index 000000000000..699897409570 --- /dev/null +++ b/azure-loganalytics/azure/loganalytics/models/table.py @@ -0,0 +1,46 @@ +# 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 Table(Model): + """A query response table. + + Contains the columns and rows for one table in a query response. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. The name of the table. + :type name: str + :param columns: Required. The list of columns in this table. + :type columns: list[~azure.loganalytics.models.Column] + :param rows: Required. The resulting rows from this query. + :type rows: list[list[object]] + """ + + _validation = { + 'name': {'required': True}, + 'columns': {'required': True}, + 'rows': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'columns': {'key': 'columns', 'type': '[Column]'}, + 'rows': {'key': 'rows', 'type': '[[object]]'}, + } + + def __init__(self, **kwargs): + super(Table, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.columns = kwargs.get('columns', None) + self.rows = kwargs.get('rows', None) diff --git a/azure-loganalytics/azure/loganalytics/models/table_py3.py b/azure-loganalytics/azure/loganalytics/models/table_py3.py new file mode 100644 index 000000000000..dc7dbe3e09b3 --- /dev/null +++ b/azure-loganalytics/azure/loganalytics/models/table_py3.py @@ -0,0 +1,46 @@ +# 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 Table(Model): + """A query response table. + + Contains the columns and rows for one table in a query response. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. The name of the table. + :type name: str + :param columns: Required. The list of columns in this table. + :type columns: list[~azure.loganalytics.models.Column] + :param rows: Required. The resulting rows from this query. + :type rows: list[list[object]] + """ + + _validation = { + 'name': {'required': True}, + 'columns': {'required': True}, + 'rows': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'columns': {'key': 'columns', 'type': '[Column]'}, + 'rows': {'key': 'rows', 'type': '[[object]]'}, + } + + def __init__(self, *, name: str, columns, rows, **kwargs) -> None: + super(Table, self).__init__(**kwargs) + self.name = name + self.columns = columns + self.rows = rows diff --git a/azure-loganalytics/azure/loganalytics/version.py b/azure-loganalytics/azure/loganalytics/version.py new file mode 100644 index 000000000000..e0ec669828cb --- /dev/null +++ b/azure-loganalytics/azure/loganalytics/version.py @@ -0,0 +1,13 @@ +# 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. +# -------------------------------------------------------------------------- + +VERSION = "0.1.0" + diff --git a/azure-loganalytics/azure_bdist_wheel.py b/azure-loganalytics/azure_bdist_wheel.py new file mode 100644 index 000000000000..8a81d1b61775 --- /dev/null +++ b/azure-loganalytics/azure_bdist_wheel.py @@ -0,0 +1,54 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +from distutils import log as logger +import os.path + +from wheel.bdist_wheel import bdist_wheel +class azure_bdist_wheel(bdist_wheel): + """The purpose of this class is to build wheel a little differently than the sdist, + without requiring to build the wheel from the sdist (i.e. you can build the wheel + directly from source). + """ + + description = "Create an Azure wheel distribution" + + user_options = bdist_wheel.user_options + \ + [('azure-namespace-package=', None, + "Name of the deepest nspkg used")] + + def initialize_options(self): + bdist_wheel.initialize_options(self) + self.azure_namespace_package = None + + def finalize_options(self): + bdist_wheel.finalize_options(self) + if self.azure_namespace_package and not self.azure_namespace_package.endswith("-nspkg"): + raise ValueError("azure_namespace_package must finish by -nspkg") + + def run(self): + if not self.distribution.install_requires: + self.distribution.install_requires = [] + self.distribution.install_requires.append( + "{}>=2.0.0".format(self.azure_namespace_package)) + bdist_wheel.run(self) + + def write_record(self, bdist_dir, distinfo_dir): + if self.azure_namespace_package: + # Split and remove last part, assuming it's "nspkg" + subparts = self.azure_namespace_package.split('-')[0:-1] + folder_with_init = [os.path.join(*subparts[0:i+1]) for i in range(len(subparts))] + for azure_sub_package in folder_with_init: + init_file = os.path.join(bdist_dir, azure_sub_package, '__init__.py') + if os.path.isfile(init_file): + logger.info("manually remove {} while building the wheel".format(init_file)) + os.remove(init_file) + else: + raise ValueError("Unable to find {}. Are you sure of your namespace package?".format(init_file)) + bdist_wheel.write_record(self, bdist_dir, distinfo_dir) +cmdclass = { + 'bdist_wheel': azure_bdist_wheel, +} diff --git a/azure-loganalytics/sdk_packaging.toml b/azure-loganalytics/sdk_packaging.toml new file mode 100644 index 000000000000..9410fbbee7ea --- /dev/null +++ b/azure-loganalytics/sdk_packaging.toml @@ -0,0 +1,6 @@ +[packaging] +package_name = "azure-loganalytics" +package_pprint_name = "Log Analytics" +package_doc_id = "" +is_stable = false +is_arm = false diff --git a/azure-loganalytics/setup.cfg b/azure-loganalytics/setup.cfg new file mode 100644 index 000000000000..669e94e63df3 --- /dev/null +++ b/azure-loganalytics/setup.cfg @@ -0,0 +1,3 @@ +[bdist_wheel] +universal=1 +azure-namespace-package=azure-nspkg \ No newline at end of file diff --git a/azure-loganalytics/setup.py b/azure-loganalytics/setup.py new file mode 100644 index 000000000000..49882c7bc2ec --- /dev/null +++ b/azure-loganalytics/setup.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +import re +import os.path +from io import open +from setuptools import find_packages, setup +try: + from azure_bdist_wheel import cmdclass +except ImportError: + from distutils import log as logger + logger.warn("Wheel is not available, disabling bdist_wheel hook") + cmdclass = {} + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-loganalytics" +PACKAGE_PPRINT_NAME = "Log Analytics" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# azure v0.x is not compatible with this package +# azure v0.x used to have a __version__ attribute (newer versions don't) +try: + import azure + try: + ver = azure.__version__ + raise Exception( + 'This package is incompatible with azure=={}. '.format(ver) + + 'Uninstall it with "pip uninstall azure".' + ) + except AttributeError: + pass +except ImportError: + pass + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, 'version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.rst', encoding='utf-8') as f: + readme = f.read() +with open('HISTORY.rst', encoding='utf-8') as f: + history = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + history, + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python', + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=["tests"]), + install_requires=[ + 'msrest>=0.4.29,<2.0.0', + 'azure-common~=1.1', + ], + cmdclass=cmdclass +) diff --git a/azure-loganalytics/tests/recordings/test_query.test_query.yaml b/azure-loganalytics/tests/recordings/test_query.test_query.yaml new file mode 100644 index 000000000000..6adeafb0276f --- /dev/null +++ b/azure-loganalytics/tests/recordings/test_query.test_query.yaml @@ -0,0 +1,91 @@ +interactions: +- request: + body: '{"query": "Heartbeat | take 10"}' + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['32'] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.6.4 (Windows-10-10.0.17134-SP0) requests/2.19.1 msrest/0.5.1 + azure-loganalytics/0.1.0] + x-api-key: [DEMO_KEY] + method: POST + uri: https://api.loganalytics.io/v1/workspaces/DEMO_WORKSPACE/query + response: + body: {string: '{"tables":[{"name":"PrimaryResult","columns":[{"name":"TenantId","type":"string"},{"name":"SourceSystem","type":"string"},{"name":"TimeGenerated","type":"datetime"},{"name":"MG","type":"string"},{"name":"ManagementGroupName","type":"string"},{"name":"SourceComputerId","type":"string"},{"name":"ComputerIP","type":"string"},{"name":"Computer","type":"string"},{"name":"Category","type":"string"},{"name":"OSType","type":"string"},{"name":"OSName","type":"string"},{"name":"OSMajorVersion","type":"string"},{"name":"OSMinorVersion","type":"string"},{"name":"Version","type":"string"},{"name":"SCAgentChannel","type":"string"},{"name":"IsGatewayInstalled","type":"bool"},{"name":"RemoteIPLongitude","type":"real"},{"name":"RemoteIPLatitude","type":"real"},{"name":"RemoteIPCountry","type":"string"},{"name":"SubscriptionId","type":"string"},{"name":"ResourceGroup","type":"string"},{"name":"ResourceProvider","type":"string"},{"name":"Resource","type":"string"},{"name":"ResourceId","type":"string"},{"name":"ResourceType","type":"string"},{"name":"ComputerEnvironment","type":"string"},{"name":"Solutions","type":"string"},{"name":"VMUUID","type":"string"},{"name":"Type","type":"string"}],"rows":[["b438b4f6-912a-46d5-9cb1-b44069212abc","OpsManager","2018-07-11T06:49:32.393Z","00000000-0000-0000-0000-000000000001","AOI-b438b4f6-912a-46d5-9cb1-b44069212abc","d60ef052-e184-4433-9afe-cfab55837dae","167.220.196.238","On-Premise-16S","Direct + Agent","Windows","","10","0","8.0.11072.0","Direct",false,-0.91,51.47,"United + Kingdom","","","","","","","Non-Azure","\"security\", \"updates\", \"antiMalware\", + \"changeTracking\", \"sqlAssessment\", \"adAssessment\", \"azureAutomation\", + \"networkMonitoring\", \"containers\", \"containerInsights\", \"serviceMap\", + \"adReplication\", \"compatibilityAssessment\", \"dnsAnalytics\", \"wireData2\", + \"waaSUpdateInsights\", \"securityCenterFree\", \"deviceHealthProd\"","34bd465a-bd7b-4112-a6d9-b99f81450f94","Heartbeat"],["b438b4f6-912a-46d5-9cb1-b44069212abc","OpsManager","2018-07-11T06:50:33.29Z","00000000-0000-0000-0000-000000000002","","81422fdd-5aa4-49d9-aa86-5e78139aa8e7","13.82.239.225","Contosoweb-Linux","Direct + Agent","Linux","Red Hat Enterprise Linux","6","9","1.6.0-42","Direct",null,-78.17,38.73,"United + States","e4272367-5645-4c4e-9c67-3b74b59a6982","contosoautomation","microsoft.compute","contosoweb-linux","/subscriptions/e4272367-5645-4c4e-9c67-3b74b59a6982/resourcegroups/contosoautomation/providers/microsoft.compute/virtualmachines/contosoweb-linux","virtualmachines","Azure","\"security\", + \"updates\", \"antiMalware\", \"changeTracking\", \"sqlAssessment\", \"adAssessment\", + \"azureAutomation\", \"networkMonitoring\", \"containers\", \"containerInsights\", + \"serviceMap\", \"adReplication\", \"compatibilityAssessment\", \"dnsAnalytics\", + \"wireData2\", \"waaSUpdateInsights\", \"securityCenterFree\", \"deviceHealthProd\"","66116469-e3b8-7844-b435-6587685c7918","Heartbeat"],["b438b4f6-912a-46d5-9cb1-b44069212abc","OpsManager","2018-07-11T06:50:37.16Z","00000000-0000-0000-0000-000000000001","AOI-b438b4f6-912a-46d5-9cb1-b44069212abc","e652ac47-3731-480d-8c45-06115a929da3","40.124.11.163","ContosoAzADDS2","Direct + Agent","Windows","","10","0","8.0.11081.0","Direct",false,-98.54,29.47,"United + States","e4272367-5645-4c4e-9c67-3b74b59a6982","contosoazurehq","microsoft.compute","contosoazadds2","/subscriptions/e4272367-5645-4c4e-9c67-3b74b59a6982/resourcegroups/contosoazurehq/providers/microsoft.compute/virtualmachines/contosoazadds2","virtualmachines","Azure","\"security\", + \"updates\", \"antiMalware\", \"changeTracking\", \"sqlAssessment\", \"adAssessment\", + \"azureAutomation\", \"networkMonitoring\", \"containers\", \"containerInsights\", + \"serviceMap\", \"adReplication\", \"compatibilityAssessment\", \"dnsAnalytics\", + \"wireData2\", \"waaSUpdateInsights\", \"securityCenterFree\", \"deviceHealthProd\"","8d136c56-4e91-4eaf-92a7-02bfbdf5f3b5","Heartbeat"],["b438b4f6-912a-46d5-9cb1-b44069212abc","OpsManager","2018-07-11T06:50:49.543Z","00000000-0000-0000-0000-000000000001","AOI-b438b4f6-912a-46d5-9cb1-b44069212abc","62180e48-dcf8-4bcd-9ca4-02f1ec85a1ac","52.161.28.190","ContosoWebSrvr1","Direct + Agent","Windows","","6","2","8.0.11081.0","Direct",false,-104.75,41.14,"United + States","e4272367-5645-4c4e-9c67-3b74b59a6982","contosoautomation","microsoft.compute","contosowebsrvr1","/subscriptions/e4272367-5645-4c4e-9c67-3b74b59a6982/resourcegroups/contosoautomation/providers/microsoft.compute/virtualmachines/contosowebsrvr1","virtualmachines","Azure","\"security\", + \"updates\", \"antiMalware\", \"changeTracking\", \"sqlAssessment\", \"adAssessment\", + \"azureAutomation\", \"networkMonitoring\", \"containers\", \"containerInsights\", + \"serviceMap\", \"adReplication\", \"compatibilityAssessment\", \"dnsAnalytics\", + \"wireData2\", \"waaSUpdateInsights\", \"securityCenterFree\", \"deviceHealthProd\"","cb4d29c3-2e93-4bfb-a186-603d26729310","Heartbeat"],["b438b4f6-912a-46d5-9cb1-b44069212abc","OpsManager","2018-07-11T06:50:37.847Z","00000000-0000-0000-0000-000000000001","AOI-b438b4f6-912a-46d5-9cb1-b44069212abc","d19ee03d-94e7-4914-adc3-52384a301395","104.43.139.78","AZTest2","Direct + Agent","Windows","","10","0","8.0.11081.0","Direct",false,-93.62,41.59,"United + States","e4272367-5645-4c4e-9c67-3b74b59a6982","aztest","microsoft.compute","aztest2","/subscriptions/e4272367-5645-4c4e-9c67-3b74b59a6982/resourcegroups/aztest/providers/microsoft.compute/virtualmachines/aztest2","virtualmachines","Azure","\"security\", + \"updates\", \"antiMalware\", \"changeTracking\", \"sqlAssessment\", \"adAssessment\", + \"azureAutomation\", \"networkMonitoring\", \"containers\", \"containerInsights\", + \"serviceMap\", \"adReplication\", \"compatibilityAssessment\", \"dnsAnalytics\", + \"wireData2\", \"waaSUpdateInsights\", \"securityCenterFree\", \"deviceHealthProd\"","a860c408-abf7-4a93-9942-fa7f59af805f","Heartbeat"],["b438b4f6-912a-46d5-9cb1-b44069212abc","OpsManager","2018-07-11T06:50:36.827Z","00000000-0000-0000-0000-000000000002","","314cbc19-b236-49ef-868b-fa9b1b2eb988","40.88.30.92","k8s-master-C225FF51-0","Direct + Agent","Linux","Ubuntu","16","04","1.6.0-42","Direct",null,-78.17,38.73,"United + States","e4272367-5645-4c4e-9c67-3b74b59a6982","javamoviedbjenkinsgrpcontit","microsoft.compute","k8s-master-c225ff51-0","/subscriptions/e4272367-5645-4c4e-9c67-3b74b59a6982/resourcegroups/javamoviedbjenkinsgrpcontit/providers/microsoft.compute/virtualmachines/k8s-master-c225ff51-0","virtualmachines","Azure","\"security\", + \"updates\", \"antiMalware\", \"changeTracking\", \"sqlAssessment\", \"adAssessment\", + \"azureAutomation\", \"networkMonitoring\", \"containers\", \"containerInsights\", + \"serviceMap\", \"adReplication\", \"compatibilityAssessment\", \"dnsAnalytics\", + \"wireData2\", \"waaSUpdateInsights\", \"securityCenterFree\", \"deviceHealthProd\"","c7fe1299-92ca-174e-875a-ead8d087635e","Heartbeat"],["b438b4f6-912a-46d5-9cb1-b44069212abc","OpsManager","2018-07-11T06:51:14.757Z","00000000-0000-0000-0000-000000000001","AOI-b438b4f6-912a-46d5-9cb1-b44069212abc","fd56411d-5e07-4750-8db1-7cdd2ddda9e6","52.165.151.211","AZTest","Direct + Agent","Windows","","10","0","8.0.11081.0","Direct",false,-93.62,41.59,"United + States","e4272367-5645-4c4e-9c67-3b74b59a6982","aztest","microsoft.compute","aztest","/subscriptions/e4272367-5645-4c4e-9c67-3b74b59a6982/resourcegroups/aztest/providers/microsoft.compute/virtualmachines/aztest","virtualmachines","Azure","\"security\", + \"updates\", \"antiMalware\", \"changeTracking\", \"sqlAssessment\", \"adAssessment\", + \"azureAutomation\", \"networkMonitoring\", \"containers\", \"containerInsights\", + \"serviceMap\", \"adReplication\", \"compatibilityAssessment\", \"dnsAnalytics\", + \"wireData2\", \"waaSUpdateInsights\", \"securityCenterFree\", \"deviceHealthProd\"","a6563fe3-9f43-4cfe-910f-9f85ecd6fea4","Heartbeat"],["b438b4f6-912a-46d5-9cb1-b44069212abc","OpsManager","2018-07-11T06:52:34.147Z","00000000-0000-0000-0000-000000000001","AOI-b438b4f6-912a-46d5-9cb1-b44069212abc","e7d0be0e-635c-42f8-8b1e-c954cbb3491d","104.215.85.192","ContosoSQLSrv1","Direct + Agent","Windows","","6","3","8.0.11081.0","Direct",false,-98.54,29.47,"United + States","e4272367-5645-4c4e-9c67-3b74b59a6982","contosoazurehq","microsoft.compute","restoreconstoso","/subscriptions/e4272367-5645-4c4e-9c67-3b74b59a6982/resourcegroups/contosoazurehq/providers/microsoft.compute/virtualmachines/restoreconstoso","virtualmachines","Azure","\"security\", + \"updates\", \"antiMalware\", \"changeTracking\", \"sqlAssessment\", \"adAssessment\", + \"azureAutomation\", \"networkMonitoring\", \"containers\", \"containerInsights\", + \"serviceMap\", \"adReplication\", \"compatibilityAssessment\", \"dnsAnalytics\", + \"wireData2\", \"waaSUpdateInsights\", \"securityCenterFree\", \"deviceHealthProd\"","4c9bb3b2-f821-4412-b15c-c0200fabc7b6","Heartbeat"],["b438b4f6-912a-46d5-9cb1-b44069212abc","OpsManager","2018-07-11T06:52:43.64Z","00000000-0000-0000-0000-000000000002","","a183bc69-380a-40a1-b81c-8bfa2b998cab","52.136.235.220","k8s-agent-26B291EE-0","Direct + Agent","Linux","Ubuntu","16","04","1.6.0-42","Direct",null,4.94,52.31,"Netherlands","e4272367-5645-4c4e-9c67-3b74b59a6982","devjavamoviedbweugrpcontit","microsoft.compute","k8s-agent-26b291ee-0","/subscriptions/e4272367-5645-4c4e-9c67-3b74b59a6982/resourcegroups/devjavamoviedbweugrpcontit/providers/microsoft.compute/virtualmachines/k8s-agent-26b291ee-0","virtualmachines","Azure","\"security\", + \"updates\", \"antiMalware\", \"changeTracking\", \"sqlAssessment\", \"adAssessment\", + \"azureAutomation\", \"networkMonitoring\", \"containers\", \"containerInsights\", + \"serviceMap\", \"adReplication\", \"compatibilityAssessment\", \"dnsAnalytics\", + \"wireData2\", \"waaSUpdateInsights\", \"securityCenterFree\", \"deviceHealthProd\"","b91c66ae-88d1-864d-99bf-b9a5227fd8c2","Heartbeat"],["b438b4f6-912a-46d5-9cb1-b44069212abc","OpsManager","2018-07-11T06:53:14.78Z","00000000-0000-0000-0000-000000000001","AOI-b438b4f6-912a-46d5-9cb1-b44069212abc","fd56411d-5e07-4750-8db1-7cdd2ddda9e6","52.165.151.211","AZTest","Direct + Agent","Windows","","10","0","8.0.11081.0","Direct",false,-93.62,41.59,"United + States","e4272367-5645-4c4e-9c67-3b74b59a6982","aztest","microsoft.compute","aztest","/subscriptions/e4272367-5645-4c4e-9c67-3b74b59a6982/resourcegroups/aztest/providers/microsoft.compute/virtualmachines/aztest","virtualmachines","Azure","\"security\", + \"updates\", \"antiMalware\", \"changeTracking\", \"sqlAssessment\", \"adAssessment\", + \"azureAutomation\", \"networkMonitoring\", \"containers\", \"containerInsights\", + \"serviceMap\", \"adReplication\", \"compatibilityAssessment\", \"dnsAnalytics\", + \"wireData2\", \"waaSUpdateInsights\", \"securityCenterFree\", \"deviceHealthProd\"","a6563fe3-9f43-4cfe-910f-9f85ecd6fea4","Heartbeat"]]}]}'} + headers: + access-control-allow-origin: ['*'] + access-control-expose-headers: ['Retry-After,Age,WWW-Authenticate,x-resource-identities,x-ms-status-location'] + connection: [keep-alive] + content-length: ['10807'] + content-location: ['https://eastus.api.loganalytics.io/v1/workspaces/DEMO_WORKSPACE/query'] + content-type: [application/json; charset=utf-8] + date: ['Wed, 11 Jul 2018 18:11:41 GMT'] + server: [nginx] + strict-transport-security: [max-age=31536000; includeSubDomains] + transfer-encoding: [chunked] + vary: [Accept-Encoding] + via: [1.1 draft-oms-blue.0c04f4bf-851c-11e8-a775-70b3d5800012] + x-content-type-options: [nosniff] + status: {code: 200, message: OK} +version: 1 diff --git a/azure-loganalytics/tests/test_query.py b/azure-loganalytics/tests/test_query.py new file mode 100644 index 000000000000..d0098b7baa63 --- /dev/null +++ b/azure-loganalytics/tests/test_query.py @@ -0,0 +1,27 @@ +from azure.loganalytics import LogAnalyticsDataClient +from azure.loganalytics.models import QueryBody +from devtools_testutils import AzureMgmtTestCase + +class LogAnalyticsQueryTest(AzureMgmtTestCase): + def setUp(self): + super(LogAnalyticsQueryTest, self).setUp() + self.client = self.create_basic_client(LogAnalyticsDataClient) + + def test_query(self): + query = 'Heartbeat | take 10' + workspace = 'DEMO_WORKSPACE' + result = self.client.query(workspace, QueryBody(**{'query': query})) + print(result.tables[0].columns) + print(result.tables[0].rows[0]) + # All queries should return at least a table. + self.assertGreaterEqual(len(result.tables), 1) + + # Heartbeat table schema has 29 columns. + self.assertEqual(len(result.tables[0].columns), 29) + + # The workspace should contain enough data to retrieve 10 rows, as asked + self.assertEqual(len(result.tables[0].rows), 10) + + # Validate deserialization + self.assertIs(type(result.tables[0].rows[0][16]), float) + self.assertIs(type(result.tables[0].rows[0][15]), bool) \ No newline at end of file diff --git a/azure-sdk-tools/packaging_tools/conf.py b/azure-sdk-tools/packaging_tools/conf.py index 6140b6eac2de..783de37c1f51 100644 --- a/azure-sdk-tools/packaging_tools/conf.py +++ b/azure-sdk-tools/packaging_tools/conf.py @@ -14,7 +14,8 @@ "package_name": "packagename", "package_pprint_name": "MyService Management", "package_doc_id": "", - "is_stable": False + "is_stable": False, + "is_arm": True } def read_conf(folder: Path) -> Dict[str, Any]: diff --git a/package_service_mapping.json b/package_service_mapping.json index b175024d3bc4..3e45ef7fb6db 100644 --- a/package_service_mapping.json +++ b/package_service_mapping.json @@ -122,6 +122,13 @@ ], "service_name": "Key Vault" }, + "azure-loganalytics": { + "service_name": "Log Analytics", + "category ": "Client", + "namespaces": [ + "azure.loganalytics" + ] + }, "azure-mgmt-advisor": { "category ": "Management", "namespaces": [