From 9ed01fb9e0fa44c3eabfeabf2ae2d03bc337fdc0 Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Sun, 26 Apr 2020 01:58:42 +0000 Subject: [PATCH] Generated from fb31128478b428a6bff99e3753b43f5bfd4d40e6 Did some minor changes --- .../azure-mgmt-costmanagement/README.md | 30 ++---- .../mgmt/costmanagement/models/__init__.py | 2 + .../models/_cost_management_client_enums.py | 6 ++ .../mgmt/costmanagement/models/_models.py | 6 ++ .../mgmt/costmanagement/models/_models_py3.py | 6 ++ .../operations/_dimensions_operations.py | 102 ++++++++++++++++++ .../operations/_query_operations.py | 74 +++++++++++++ .../azure-mgmt-costmanagement/setup.py | 6 +- 8 files changed, 211 insertions(+), 21 deletions(-) diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/README.md b/sdk/costmanagement/azure-mgmt-costmanagement/README.md index 8e49cdc26b15..30a17695c7c3 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/README.md +++ b/sdk/costmanagement/azure-mgmt-costmanagement/README.md @@ -1,29 +1,21 @@ -## Microsoft Azure SDK for Python +# Microsoft Azure SDK for Python This is the Microsoft Azure Cost Management Client Library. +This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. +For a more complete view of Azure libraries, see the [Github repo](https://github.com/Azure/azure-sdk-for-python/) -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. +# Usage -For the older Azure Service Management (ASM) libraries, see -[azure-servicemanagement-legacy](https://pypi.python.org/pypi/azure-servicemanagement-legacy) -library. +For code examples, see [Cost Management](https://docs.microsoft.com/python/api/overview/azure/) +on docs.microsoft.com. -For a more complete set of Azure libraries, see the -[azure](https://pypi.python.org/pypi/azure) bundle package. -## Usage +# Provide Feedback -For code examples, see [Cost -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) +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. -![image](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-costmanagement%2FREADME.png) + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-costmanagement%2FREADME.png) diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/__init__.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/__init__.py index f9cce82b9bb8..46ca503a0db5 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/__init__.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/__init__.py @@ -73,6 +73,7 @@ FormatType, ExecutionType, ExecutionStatus, + ExternalCloudProviderType, ) __all__ = [ @@ -112,4 +113,5 @@ 'FormatType', 'ExecutionType', 'ExecutionStatus', + 'ExternalCloudProviderType', ] diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_cost_management_client_enums.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_cost_management_client_enums.py index d447d8444908..c463d4694732 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_cost_management_client_enums.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_cost_management_client_enums.py @@ -74,3 +74,9 @@ class ExecutionStatus(str, Enum): timeout = "Timeout" new_data_not_available = "NewDataNotAvailable" data_not_available = "DataNotAvailable" + + +class ExternalCloudProviderType(str, Enum): + + external_subscriptions = "externalSubscriptions" + external_billing_accounts = "externalBillingAccounts" diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_models.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_models.py index b06344b3295c..4e877f41f95a 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_models.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_models.py @@ -200,6 +200,12 @@ def __init__(self, **kwargs): class ErrorResponse(Model): """Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message. + Some Error responses: + * 429 TooManyRequests - Request is throttled. Retry after waiting for the + time specified in the "x-ms-ratelimit-microsoft.consumption-retry-after" + header. + * 503 ServiceUnavailable - Service is temporarily unavailable. Retry after + waiting for the time specified in the "Retry-After" header. :param error: The details of the error. :type error: ~azure.mgmt.costmanagement.models.ErrorDetails diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_models_py3.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_models_py3.py index 01cef7145aec..9549a8b19cd5 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_models_py3.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_models_py3.py @@ -200,6 +200,12 @@ def __init__(self, **kwargs) -> None: class ErrorResponse(Model): """Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message. + Some Error responses: + * 429 TooManyRequests - Request is throttled. Retry after waiting for the + time specified in the "x-ms-ratelimit-microsoft.consumption-retry-after" + header. + * 503 ServiceUnavailable - Service is temporarily unavailable. Retry after + waiting for the time specified in the "Retry-After" header. :param error: The details of the error. :type error: ~azure.mgmt.costmanagement.models.ErrorDetails diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_dimensions_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_dimensions_operations.py index a753fb553a79..9d4082c233b1 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_dimensions_operations.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_dimensions_operations.py @@ -145,3 +145,105 @@ def internal_paging(next_link=None): return deserialized list.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/dimensions'} + + def by_external_cloud_provider_type( + self, external_cloud_provider_type, external_cloud_provider_id, filter=None, expand=None, skiptoken=None, top=None, custom_headers=None, raw=False, **operation_config): + """Lists the dimensions by the external cloud provider type. + + :param external_cloud_provider_type: The external cloud provider type + associated with dimension/query operations. This includes + 'externalSubscriptions' for linked account and + 'externalBillingAccounts' for consolidated account. Possible values + include: 'externalSubscriptions', 'externalBillingAccounts' + :type external_cloud_provider_type: str or + ~azure.mgmt.costmanagement.models.ExternalCloudProviderType + :param external_cloud_provider_id: This can be + '{externalSubscriptionId}' for linked account or + '{externalBillingAccountId}' for consolidated account used with + dimension/query operations. + :type external_cloud_provider_id: str + :param filter: May be used to filter dimensions by + properties/category, properties/usageStart, properties/usageEnd. + Supported operators are 'eq','lt', 'gt', 'le', 'ge'. + :type filter: str + :param expand: May be used to expand the properties/data within a + dimension category. By default, data is not included when listing + dimensions. + :type expand: str + :param skiptoken: Skiptoken is only used if a previous operation + returned a partial result. If a previous response contains a nextLink + element, the value of the nextLink element will include a skiptoken + parameter that specifies a starting point to use for subsequent calls. + :type skiptoken: str + :param top: May be used to limit the number of results to the most + recent N dimension data. + :type top: int + :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: An iterator like instance of Dimension + :rtype: + ~azure.mgmt.costmanagement.models.DimensionPaged[~azure.mgmt.costmanagement.models.Dimension] + :raises: + :class:`ErrorResponseException` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.by_external_cloud_provider_type.metadata['url'] + path_format_arguments = { + 'externalCloudProviderType': self._serialize.url("external_cloud_provider_type", external_cloud_provider_type, 'str'), + 'externalCloudProviderId': self._serialize.url("external_cloud_provider_id", external_cloud_provider_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + if skiptoken is not None: + query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.DimensionPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + by_external_cloud_provider_type.metadata = {'url': '/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/dimensions'} diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_query_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_query_operations.py index 00191d7f0ddf..4ce6b965f53f 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_query_operations.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_query_operations.py @@ -118,3 +118,77 @@ def usage( return deserialized usage.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/query'} + + def usage_by_external_cloud_provider_type( + self, external_cloud_provider_type, external_cloud_provider_id, parameters, custom_headers=None, raw=False, **operation_config): + """Query the usage data for external cloud provider type defined. + + :param external_cloud_provider_type: The external cloud provider type + associated with dimension/query operations. This includes + 'externalSubscriptions' for linked account and + 'externalBillingAccounts' for consolidated account. Possible values + include: 'externalSubscriptions', 'externalBillingAccounts' + :type external_cloud_provider_type: str or + ~azure.mgmt.costmanagement.models.ExternalCloudProviderType + :param external_cloud_provider_id: This can be + '{externalSubscriptionId}' for linked account or + '{externalBillingAccountId}' for consolidated account used with + dimension/query operations. + :type external_cloud_provider_id: str + :param parameters: Parameters supplied to the CreateOrUpdate Query + Config operation. + :type parameters: ~azure.mgmt.costmanagement.models.QueryDefinition + :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: QueryResult or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.costmanagement.models.QueryResult or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.usage_by_external_cloud_provider_type.metadata['url'] + path_format_arguments = { + 'externalCloudProviderType': self._serialize.url("external_cloud_provider_type", external_cloud_provider_type, 'str'), + 'externalCloudProviderId': self._serialize.url("external_cloud_provider_id", external_cloud_provider_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['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 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(parameters, 'QueryDefinition') + + # 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.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('QueryResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + usage_by_external_cloud_provider_type.metadata = {'url': '/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/query'} diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/setup.py b/sdk/costmanagement/azure-mgmt-costmanagement/setup.py index 2f95b055a0cb..e853a3e11b21 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/setup.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/setup.py @@ -36,7 +36,9 @@ pass # Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, 'version.py'), 'r') as fd: +with open(os.path.join(package_folder_path, 'version.py') + if os.path.exists(os.path.join(package_folder_path, 'version.py')) + else os.path.join(package_folder_path, '_version.py'), 'r') as fd: version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) @@ -64,10 +66,10 @@ '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', + 'Programming Language :: Python :: 3.8', 'License :: OSI Approved :: MIT License', ], zip_safe=False,