diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/consumption_management_client.py b/azure-mgmt-consumption/azure/mgmt/consumption/consumption_management_client.py index d197daccd705..4b582714b6b0 100644 --- a/azure-mgmt-consumption/azure/mgmt/consumption/consumption_management_client.py +++ b/azure-mgmt-consumption/azure/mgmt/consumption/consumption_management_client.py @@ -21,6 +21,7 @@ from .operations.budgets_operations import BudgetsOperations from .operations.operations import Operations from .operations.price_sheet_operations import PriceSheetOperations +from .operations.cost_allocation_tags_operations import CostAllocationTagsOperations from . import models @@ -34,21 +35,16 @@ class ConsumptionManagementClientConfiguration(AzureConfiguration): object` :param subscription_id: Azure Subscription ID. :type subscription_id: str - :param grain: Can be daily or monthly. Possible values include: - 'DailyGrain', 'MonthlyGrain' - :type grain: str or ~azure.mgmt.consumption.models.Datagrain :param str base_url: Service URL """ def __init__( - self, credentials, subscription_id, grain, base_url=None): + self, credentials, subscription_id, base_url=None): if credentials is None: raise ValueError("Parameter 'credentials' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - if grain is None: - raise ValueError("Parameter 'grain' must not be None.") if not base_url: base_url = 'https://management.azure.com' @@ -59,7 +55,6 @@ def __init__( self.credentials = credentials self.subscription_id = subscription_id - self.grain = grain class ConsumptionManagementClient(object): @@ -84,22 +79,21 @@ class ConsumptionManagementClient(object): :vartype operations: azure.mgmt.consumption.operations.Operations :ivar price_sheet: PriceSheet operations :vartype price_sheet: azure.mgmt.consumption.operations.PriceSheetOperations + :ivar cost_allocation_tags: CostAllocationTags operations + :vartype cost_allocation_tags: azure.mgmt.consumption.operations.CostAllocationTagsOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials object` :param subscription_id: Azure Subscription ID. :type subscription_id: str - :param grain: Can be daily or monthly. Possible values include: - 'DailyGrain', 'MonthlyGrain' - :type grain: str or ~azure.mgmt.consumption.models.Datagrain :param str base_url: Service URL """ def __init__( - self, credentials, subscription_id, grain, base_url=None): + self, credentials, subscription_id, base_url=None): - self.config = ConsumptionManagementClientConfiguration(credentials, subscription_id, grain, base_url) + self.config = ConsumptionManagementClientConfiguration(credentials, subscription_id, base_url) self._client = ServiceClient(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -123,3 +117,5 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.price_sheet = PriceSheetOperations( self._client, self.config, self._serialize, self._deserialize) + self.cost_allocation_tags = CostAllocationTagsOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/__init__.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/__init__.py index 5a6c78695c3c..699ba3830208 100644 --- a/azure-mgmt-consumption/azure/mgmt/consumption/models/__init__.py +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/__init__.py @@ -20,6 +20,8 @@ from .current_spend import CurrentSpend from .notification import Notification from .budget import Budget +from .cost_allocation_tag import CostAllocationTag +from .cost_allocation_tags import CostAllocationTags from .error_details import ErrorDetails from .error_response import ErrorResponse, ErrorResponseException from .operation_display import OperationDisplay @@ -56,6 +58,8 @@ 'CurrentSpend', 'Notification', 'Budget', + 'CostAllocationTag', + 'CostAllocationTags', 'ErrorDetails', 'ErrorResponse', 'ErrorResponseException', 'OperationDisplay', diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/cost_allocation_tag.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/cost_allocation_tag.py new file mode 100644 index 000000000000..6176ebb7cd72 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/cost_allocation_tag.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 CostAllocationTag(Model): + """The cost allocation tag. + + :param key: Cost allocation tag key. + :type key: str + """ + + _attribute_map = { + 'key': {'key': 'key', 'type': 'str'}, + } + + def __init__(self, key=None): + super(CostAllocationTag, self).__init__() + self.key = key diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/cost_allocation_tags.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/cost_allocation_tags.py new file mode 100644 index 000000000000..3688c720f6b9 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/cost_allocation_tags.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 .proxy_resource import ProxyResource + + +class CostAllocationTags(ProxyResource): + """A cost allocation tag resource. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param e_tag: eTag of the resource. To handle concurrent update scenarion, + this field will be used to determine whether the user is updating the + latest version or not. + :type e_tag: str + :param cost_allocation_tags: Cost allocation tags. + :type cost_allocation_tags: + list[~azure.mgmt.consumption.models.CostAllocationTag] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, + 'cost_allocation_tags': {'key': 'properties.costAllocationTags', 'type': '[CostAllocationTag]'}, + } + + def __init__(self, e_tag=None, cost_allocation_tags=None): + super(CostAllocationTags, self).__init__(e_tag=e_tag) + self.cost_allocation_tags = cost_allocation_tags diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/operations/__init__.py b/azure-mgmt-consumption/azure/mgmt/consumption/operations/__init__.py index 3558f88f9eb6..1ee112dda428 100644 --- a/azure-mgmt-consumption/azure/mgmt/consumption/operations/__init__.py +++ b/azure-mgmt-consumption/azure/mgmt/consumption/operations/__init__.py @@ -17,6 +17,7 @@ from .budgets_operations import BudgetsOperations from .operations import Operations from .price_sheet_operations import PriceSheetOperations +from .cost_allocation_tags_operations import CostAllocationTagsOperations __all__ = [ 'UsageDetailsOperations', @@ -27,4 +28,5 @@ 'BudgetsOperations', 'Operations', 'PriceSheetOperations', + 'CostAllocationTagsOperations', ] diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/operations/cost_allocation_tags_operations.py b/azure-mgmt-consumption/azure/mgmt/consumption/operations/cost_allocation_tags_operations.py new file mode 100644 index 000000000000..689c045f2d8f --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/operations/cost_allocation_tags_operations.py @@ -0,0 +1,169 @@ +# 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 CostAllocationTagsOperations(object): + """CostAllocationTagsOperations 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: Version of the API to be used with the client request. The current version is 2018-03-31. Constant value: "2018-03-31". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2018-03-31" + + self.config = config + + def get( + self, billing_account_id, custom_headers=None, raw=False, **operation_config): + """Get cost allocation tags for a billing account. + + :param billing_account_id: Azure Billing Account ID. + :type billing_account_id: 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: CostAllocationTags or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.consumption.models.CostAllocationTags or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'billingAccountId': self._serialize.url("billing_account_id", billing_account_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['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.ErrorResponseException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('CostAllocationTags', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/providers/Microsoft.CostManagement/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/costAllocationTags'} + + def create_or_update( + self, billing_account_id, e_tag=None, cost_allocation_tags=None, custom_headers=None, raw=False, **operation_config): + """The operation to create or update cost allocation tags assiciated with + a billing account. Update operation requires latest eTag to be set in + the request mandatorily. You may obtain the latest eTag by performing a + get operation. Create operation does not require eTag. + + :param billing_account_id: Azure Billing Account ID. + :type billing_account_id: str + :param e_tag: eTag of the resource. To handle concurrent update + scenarion, this field will be used to determine whether the user is + updating the latest version or not. + :type e_tag: str + :param cost_allocation_tags: Cost allocation tags. + :type cost_allocation_tags: + list[~azure.mgmt.consumption.models.CostAllocationTag] + :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: CostAllocationTags or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.consumption.models.CostAllocationTags or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + parameters = models.CostAllocationTags(e_tag=e_tag, cost_allocation_tags=cost_allocation_tags) + + # Construct URL + url = self.create_or_update.metadata['url'] + path_format_arguments = { + 'billingAccountId': self._serialize.url("billing_account_id", billing_account_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['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, 'CostAllocationTags') + + # 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.ErrorResponseException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('CostAllocationTags', response) + if response.status_code == 201: + deserialized = self._deserialize('CostAllocationTags', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + create_or_update.metadata = {'url': '/providers/Microsoft.CostManagement/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/costAllocationTags'} diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/operations/reservations_summaries_operations.py b/azure-mgmt-consumption/azure/mgmt/consumption/operations/reservations_summaries_operations.py index 70b25308e47e..40254b9bfb76 100644 --- a/azure-mgmt-consumption/azure/mgmt/consumption/operations/reservations_summaries_operations.py +++ b/azure-mgmt-consumption/azure/mgmt/consumption/operations/reservations_summaries_operations.py @@ -37,11 +37,14 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def list_by_reservation_order( - self, reservation_order_id, filter=None, custom_headers=None, raw=False, **operation_config): + self, reservation_order_id, grain, filter=None, custom_headers=None, raw=False, **operation_config): """Lists the reservations summaries for daily or monthly grain. :param reservation_order_id: Order Id of the reservation :type reservation_order_id: str + :param grain: Can be daily or monthly. Possible values include: + 'DailyGrain', 'MonthlyGrain' + :type grain: str or ~azure.mgmt.consumption.models.Datagrain :param filter: Required only for daily grain. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge' :type filter: str @@ -68,7 +71,7 @@ def internal_paging(next_link=None, raw=False): # Construct parameters query_parameters = {} - query_parameters['grain'] = self._serialize.query("self.config.grain", self.config.grain, 'str') + query_parameters['grain'] = self._serialize.query("grain", grain, 'str') if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') @@ -109,13 +112,16 @@ def internal_paging(next_link=None, raw=False): list_by_reservation_order.metadata = {'url': '/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationSummaries'} def list_by_reservation_order_and_reservation( - self, reservation_order_id, reservation_id, filter=None, custom_headers=None, raw=False, **operation_config): + self, reservation_order_id, reservation_id, grain, filter=None, custom_headers=None, raw=False, **operation_config): """Lists the reservations summaries for daily or monthly grain. :param reservation_order_id: Order Id of the reservation :type reservation_order_id: str :param reservation_id: Id of the reservation :type reservation_id: str + :param grain: Can be daily or monthly. Possible values include: + 'DailyGrain', 'MonthlyGrain' + :type grain: str or ~azure.mgmt.consumption.models.Datagrain :param filter: Required only for daily grain. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge' :type filter: str @@ -143,7 +149,7 @@ def internal_paging(next_link=None, raw=False): # Construct parameters query_parameters = {} - query_parameters['grain'] = self._serialize.query("self.config.grain", self.config.grain, 'str') + query_parameters['grain'] = self._serialize.query("grain", grain, 'str') if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')