Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions azure-monitor/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.. :changelog:

Release History
===============

0.1.0 (1970-01-01)
++++++++++++++++++

* Initial Release
2 changes: 2 additions & 0 deletions azure-monitor/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include *.rst
include azure_bdist_wheel.py
49 changes: 49 additions & 0 deletions azure-monitor/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Microsoft Azure SDK for Python
==============================

This is the Microsoft Azure MyService Management Client Library.

Azure Resource Manager (ARM) is the next generation of management APIs that
replace the old Azure Service Management (ASM).

This package has been tested with Python 2.7, 3.4, 3.5, 3.6 and 3.7.

For the older Azure Service Management (ASM) libraries, see
`azure-servicemanagement-legacy <https://pypi.python.org/pypi/azure-servicemanagement-legacy>`__ library.

For a more complete set of Azure libraries, see the `azure <https://pypi.python.org/pypi/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 `MyService Management
<https://docs.microsoft.com/python/api/overview/azure/>`__
on docs.microsoft.com.


Provide Feedback
================

If you encounter any bugs or have suggestions, please file an issue in the
`Issues <https://github.com/Azure/azure-sdk-for-python/issues>`__
section of the project.
1 change: 1 addition & 0 deletions azure-monitor/azure/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
18 changes: 18 additions & 0 deletions azure-monitor/azure/monitor/__init__.py
Original file line number Diff line number Diff line change
@@ -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 .azure_metrics_client import AzureMetricsClient
from .version import VERSION

__all__ = ['AzureMetricsClient']

__version__ = VERSION

162 changes: 162 additions & 0 deletions azure-monitor/azure/monitor/azure_metrics_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# 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 Serializer, Deserializer
from msrestazure import AzureConfiguration
from .version import VERSION
from msrest.pipeline import ClientRawResponse
import uuid
from . import models


class AzureMetricsClientConfiguration(AzureConfiguration):
"""Configuration for AzureMetricsClient
Note that all parameters used to create this instance are saved as instance
attributes.

:param credentials: Credentials needed for the client to connect to Azure.
:type credentials: :mod:`A msrestazure Credentials
object<msrestazure.azure_active_directory>`
: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://monitoring.azure.com'

super(AzureMetricsClientConfiguration, self).__init__(base_url)

self.add_user_agent('azure-monitor/{}'.format(VERSION))
self.add_user_agent('Azure-SDK-For-Python')

self.credentials = credentials


class AzureMetricsClient(SDKClient):
"""Monitor Management Client

:ivar config: Configuration for client.
:vartype config: AzureMetricsClientConfiguration

:param credentials: Credentials needed for the client to connect to Azure.
:type credentials: :mod:`A msrestazure Credentials
object<msrestazure.azure_active_directory>`
:param str base_url: Service URL
"""

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

self.config = AzureMetricsClientConfiguration(credentials, base_url)
super(AzureMetricsClient, 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 = '2018-09-01-preview'
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)


def azure_monitor_custom_metrics_ingestion_api(
self, subscription_id, resource_group_name, resource_provider, resource_type_name, resource_name, content_type=None, content_length=None, time=None, data=None, custom_headers=None, raw=False, **operation_config):
"""Ingestion API used by Azure custom metrics
Responsible of below operation
1. Authorize the request
2. Deserialize payload request body
3. Perform validation of the payload
4. Commits the payload for metrics ingestion.

:param subscription_id: The azure subscription id
:type subscription_id: str
:param resource_group_name: The ARM resource group name
:type resource_group_name: str
:param resource_provider: The ARM resource provider name
:type resource_provider: str
:param resource_type_name: The ARM resource type name
:type resource_type_name: str
:param resource_name: The ARM resource name
:type resource_name: str
:param content_type: Supports application/json and
application/x-ndjson
:type content_type: str
:param content_length: Content length of the payload
:type content_length: int
:param time: Gets or sets Time property (in ISO 8601 format)
:type time: str
:param data:
:type data: ~azure.monitor.models.AzureMetricsData
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param operation_config: :ref:`Operation configuration
overrides<msrest:optionsforoperations>`.
:return: AzureMetricsResult or ClientRawResponse if raw=true
:rtype: ~azure.monitor.models.AzureMetricsResult or
~msrest.pipeline.ClientRawResponse
:raises:
:class:`AzureMetricsResultException<azure.monitor.models.AzureMetricsResultException>`
"""
body = models.AzureMetricsDocument(time=time, data=data)

# Construct URL
url = self.azure_monitor_custom_metrics_ingestion_api.metadata['url']
path_format_arguments = {
'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'resourceProvider': self._serialize.url("resource_provider", resource_provider, 'str'),
'resourceTypeName': self._serialize.url("resource_type_name", resource_type_name, 'str'),
'resourceName': self._serialize.url("resource_name", resource_name, 'str')
}
url = self._client.format_url(url, **path_format_arguments)

# Construct parameters
query_parameters = {}

# Construct headers
header_parameters = {}
header_parameters['Accept'] = 'application/json'
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
if self.config.generate_client_request_id:
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
if custom_headers:
header_parameters.update(custom_headers)
if content_type is not None:
header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
if content_length is not None:
header_parameters['Content-Length'] = self._serialize.header("content_length", content_length, 'int')
if self.config.accept_language is not None:
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

# Construct body
body_content = self._serialize.body(body, 'AzureMetricsDocument')

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

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

deserialized = None

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

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

return deserialized
azure_monitor_custom_metrics_ingestion_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProvider}/{resourceTypeName}/{resourceName}/metrics'}
37 changes: 37 additions & 0 deletions azure-monitor/azure/monitor/models/__init__.py
Original file line number Diff line number Diff line change
@@ -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 .azure_time_series_data_py3 import AzureTimeSeriesData
from .azure_metrics_base_data_py3 import AzureMetricsBaseData
from .azure_metrics_data_py3 import AzureMetricsData
from .azure_metrics_document_py3 import AzureMetricsDocument
from .api_error_py3 import ApiError
from .api_failure_response_py3 import ApiFailureResponse
from .azure_metrics_result_py3 import AzureMetricsResult, AzureMetricsResultException
except (SyntaxError, ImportError):
from .azure_time_series_data import AzureTimeSeriesData
from .azure_metrics_base_data import AzureMetricsBaseData
from .azure_metrics_data import AzureMetricsData
from .azure_metrics_document import AzureMetricsDocument
from .api_error import ApiError
from .api_failure_response import ApiFailureResponse
from .azure_metrics_result import AzureMetricsResult, AzureMetricsResultException

__all__ = [
'AzureTimeSeriesData',
'AzureMetricsBaseData',
'AzureMetricsData',
'AzureMetricsDocument',
'ApiError',
'ApiFailureResponse',
'AzureMetricsResult', 'AzureMetricsResultException',
]
32 changes: 32 additions & 0 deletions azure-monitor/azure/monitor/models/api_error.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 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 ApiError(Model):
"""ApiError.

:param code: Gets or sets the azure metrics error code
:type code: str
:param message: Gets or sets the azure metrics error message
:type message: str
"""

_attribute_map = {
'code': {'key': 'code', 'type': 'str'},
'message': {'key': 'message', 'type': 'str'},
}

def __init__(self, **kwargs):
super(ApiError, self).__init__(**kwargs)
self.code = kwargs.get('code', None)
self.message = kwargs.get('message', None)
32 changes: 32 additions & 0 deletions azure-monitor/azure/monitor/models/api_error_py3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 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 ApiError(Model):
"""ApiError.

:param code: Gets or sets the azure metrics error code
:type code: str
:param message: Gets or sets the azure metrics error message
:type message: str
"""

_attribute_map = {
'code': {'key': 'code', 'type': 'str'},
'message': {'key': 'message', 'type': 'str'},
}

def __init__(self, *, code: str=None, message: str=None, **kwargs) -> None:
super(ApiError, self).__init__(**kwargs)
self.code = code
self.message = message
28 changes: 28 additions & 0 deletions azure-monitor/azure/monitor/models/api_failure_response.py
Original file line number Diff line number Diff line change
@@ -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 ApiFailureResponse(Model):
"""ApiFailureResponse.

:param error:
:type error: ~azure.monitor.models.ApiError
"""

_attribute_map = {
'error': {'key': 'error', 'type': 'ApiError'},
}

def __init__(self, **kwargs):
super(ApiFailureResponse, self).__init__(**kwargs)
self.error = kwargs.get('error', None)
Loading