From 37a38281275076585af33721316814a615e9c107 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Fri, 13 Apr 2018 15:12:21 -0700 Subject: [PATCH] [AutoPR consumption/resource-manager] Renamed cost allocation tags to cost tags and added schema for get list of all available tag keys (#2389) * Generated from 1f2de0f37c163aa960c824541bb9094f41418b45 Renamed cost allocation tags to cost tags and added schema for get list of all available tag keys Renamed cost allocation tags to cost tags and added schema for get list of all available tag keys * Generated from 5699a841d9bb36bb99d1fbeecf46459473d054ac Incorporated review comments Incorporated review comments * Generated from 3bd6450532e1e5132bbbe60dd88be6ff2716818a Incorporated review comments Incorporated review comments * Generated from 7f53393ed97f6918aed8a574dc62a42fd1e36011 Incorporated review comments Incorporated review comments --- .../consumption_management_client.py | 13 ++- .../azure/mgmt/consumption/models/__init__.py | 12 ++- .../{cost_allocation_tag.py => cost_tag.py} | 8 +- .../{cost_allocation_tags.py => cost_tags.py} | 17 ++-- .../azure/mgmt/consumption/models/tag.py | 28 ++++++ .../azure/mgmt/consumption/models/tags.py | 51 ++++++++++ .../mgmt/consumption/operations/__init__.py | 6 +- ..._operations.py => cost_tags_operations.py} | 43 +++++---- .../consumption/operations/tags_operations.py | 94 +++++++++++++++++++ 9 files changed, 227 insertions(+), 45 deletions(-) rename azure-mgmt-consumption/azure/mgmt/consumption/models/{cost_allocation_tag.py => cost_tag.py} (81%) rename azure-mgmt-consumption/azure/mgmt/consumption/models/{cost_allocation_tags.py => cost_tags.py} (72%) create mode 100644 azure-mgmt-consumption/azure/mgmt/consumption/models/tag.py create mode 100644 azure-mgmt-consumption/azure/mgmt/consumption/models/tags.py rename azure-mgmt-consumption/azure/mgmt/consumption/operations/{cost_allocation_tags_operations.py => cost_tags_operations.py} (80%) create mode 100644 azure-mgmt-consumption/azure/mgmt/consumption/operations/tags_operations.py 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 4b582714b6b0..a29e24ea95e3 100644 --- a/azure-mgmt-consumption/azure/mgmt/consumption/consumption_management_client.py +++ b/azure-mgmt-consumption/azure/mgmt/consumption/consumption_management_client.py @@ -21,7 +21,8 @@ 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 .operations.cost_tags_operations import CostTagsOperations +from .operations.tags_operations import TagsOperations from . import models @@ -79,8 +80,10 @@ 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 + :ivar cost_tags: CostTags operations + :vartype cost_tags: azure.mgmt.consumption.operations.CostTagsOperations + :ivar tags: Tags operations + :vartype tags: azure.mgmt.consumption.operations.TagsOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials @@ -117,5 +120,7 @@ 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.cost_tags = CostTagsOperations( + self._client, self.config, self._serialize, self._deserialize) + self.tags = TagsOperations( 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 699ba3830208..a9112625868b 100644 --- a/azure-mgmt-consumption/azure/mgmt/consumption/models/__init__.py +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/__init__.py @@ -15,13 +15,15 @@ from .reservation_summaries import ReservationSummaries from .reservation_details import ReservationDetails from .reservation_recommendations import ReservationRecommendations +from .tag import Tag +from .tags import Tags from .budget_time_period import BudgetTimePeriod from .filters import Filters 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 .cost_tag import CostTag +from .cost_tags import CostTags from .error_details import ErrorDetails from .error_response import ErrorResponse, ErrorResponseException from .operation_display import OperationDisplay @@ -53,13 +55,15 @@ 'ReservationSummaries', 'ReservationDetails', 'ReservationRecommendations', + 'Tag', + 'Tags', 'BudgetTimePeriod', 'Filters', 'CurrentSpend', 'Notification', 'Budget', - 'CostAllocationTag', - 'CostAllocationTags', + 'CostTag', + 'CostTags', '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_tag.py similarity index 81% rename from azure-mgmt-consumption/azure/mgmt/consumption/models/cost_allocation_tag.py rename to azure-mgmt-consumption/azure/mgmt/consumption/models/cost_tag.py index 6176ebb7cd72..af15f79e0c68 100644 --- a/azure-mgmt-consumption/azure/mgmt/consumption/models/cost_allocation_tag.py +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/cost_tag.py @@ -12,10 +12,10 @@ from msrest.serialization import Model -class CostAllocationTag(Model): - """The cost allocation tag. +class CostTag(Model): + """The cost tag. - :param key: Cost allocation tag key. + :param key: Cost tag key. :type key: str """ @@ -24,5 +24,5 @@ class CostAllocationTag(Model): } def __init__(self, key=None): - super(CostAllocationTag, self).__init__() + super(CostTag, 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_tags.py similarity index 72% rename from azure-mgmt-consumption/azure/mgmt/consumption/models/cost_allocation_tags.py rename to azure-mgmt-consumption/azure/mgmt/consumption/models/cost_tags.py index 3688c720f6b9..4773e92bde71 100644 --- a/azure-mgmt-consumption/azure/mgmt/consumption/models/cost_allocation_tags.py +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/cost_tags.py @@ -12,8 +12,8 @@ from .proxy_resource import ProxyResource -class CostAllocationTags(ProxyResource): - """A cost allocation tag resource. +class CostTags(ProxyResource): + """A cost tag resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -28,9 +28,8 @@ class CostAllocationTags(ProxyResource): 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 cost_tags: Cost tags. + :type cost_tags: list[~azure.mgmt.consumption.models.CostTag] """ _validation = { @@ -44,9 +43,9 @@ class CostAllocationTags(ProxyResource): 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'e_tag': {'key': 'eTag', 'type': 'str'}, - 'cost_allocation_tags': {'key': 'properties.costAllocationTags', 'type': '[CostAllocationTag]'}, + 'cost_tags': {'key': 'properties.costTags', 'type': '[CostTag]'}, } - 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 + def __init__(self, e_tag=None, cost_tags=None): + super(CostTags, self).__init__(e_tag=e_tag) + self.cost_tags = cost_tags diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/tag.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/tag.py new file mode 100644 index 000000000000..d1403dabeb28 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/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 Tag(Model): + """The tag resource. + + :param key: Tag key. + :type key: str + """ + + _attribute_map = { + 'key': {'key': 'key', 'type': 'str'}, + } + + def __init__(self, key=None): + super(Tag, self).__init__() + self.key = key diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/tags.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/tags.py new file mode 100644 index 000000000000..e3bcdd517698 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/tags.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 .proxy_resource import ProxyResource + + +class Tags(ProxyResource): + """A resource listing all tags. + + 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 tags: A list of Tag. + :type tags: list[~azure.mgmt.consumption.models.Tag] + """ + + _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'}, + 'tags': {'key': 'properties.tags', 'type': '[Tag]'}, + } + + def __init__(self, e_tag=None, tags=None): + super(Tags, self).__init__(e_tag=e_tag) + self.tags = tags diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/operations/__init__.py b/azure-mgmt-consumption/azure/mgmt/consumption/operations/__init__.py index 1ee112dda428..cad7c9a0d7e9 100644 --- a/azure-mgmt-consumption/azure/mgmt/consumption/operations/__init__.py +++ b/azure-mgmt-consumption/azure/mgmt/consumption/operations/__init__.py @@ -17,7 +17,8 @@ from .budgets_operations import BudgetsOperations from .operations import Operations from .price_sheet_operations import PriceSheetOperations -from .cost_allocation_tags_operations import CostAllocationTagsOperations +from .cost_tags_operations import CostTagsOperations +from .tags_operations import TagsOperations __all__ = [ 'UsageDetailsOperations', @@ -28,5 +29,6 @@ 'BudgetsOperations', 'Operations', 'PriceSheetOperations', - 'CostAllocationTagsOperations', + 'CostTagsOperations', + 'TagsOperations', ] diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/operations/cost_allocation_tags_operations.py b/azure-mgmt-consumption/azure/mgmt/consumption/operations/cost_tags_operations.py similarity index 80% rename from azure-mgmt-consumption/azure/mgmt/consumption/operations/cost_allocation_tags_operations.py rename to azure-mgmt-consumption/azure/mgmt/consumption/operations/cost_tags_operations.py index 689c045f2d8f..1232aacba452 100644 --- a/azure-mgmt-consumption/azure/mgmt/consumption/operations/cost_allocation_tags_operations.py +++ b/azure-mgmt-consumption/azure/mgmt/consumption/operations/cost_tags_operations.py @@ -15,8 +15,8 @@ from .. import models -class CostAllocationTagsOperations(object): - """CostAllocationTagsOperations operations. +class CostTagsOperations(object): + """CostTagsOperations operations. :param client: Client for service requests. :param config: Configuration of service client. @@ -38,7 +38,7 @@ def __init__(self, client, config, serializer, deserializer): def get( self, billing_account_id, custom_headers=None, raw=False, **operation_config): - """Get cost allocation tags for a billing account. + """Get cost tags for a billing account. :param billing_account_id: Azure Billing Account ID. :type billing_account_id: str @@ -47,8 +47,8 @@ def get( deserialized response :param operation_config: :ref:`Operation configuration overrides`. - :return: CostAllocationTags or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.consumption.models.CostAllocationTags or + :return: CostTags or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.consumption.models.CostTags or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException` @@ -84,21 +84,21 @@ def get( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('CostAllocationTags', response) + deserialized = self._deserialize('CostTags', 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'} + get.metadata = {'url': '/providers/Microsoft.CostManagement/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/costTags'} 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. + self, billing_account_id, e_tag=None, cost_tags=None, custom_headers=None, raw=False, **operation_config): + """The operation to create or update cost 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 @@ -106,21 +106,20 @@ def create_or_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 cost_tags: Cost tags. + :type cost_tags: list[~azure.mgmt.consumption.models.CostTag] :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 + :return: CostTags or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.consumption.models.CostTags or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException` """ - parameters = models.CostAllocationTags(e_tag=e_tag, cost_allocation_tags=cost_allocation_tags) + parameters = models.CostTags(e_tag=e_tag, cost_tags=cost_tags) # Construct URL url = self.create_or_update.metadata['url'] @@ -144,7 +143,7 @@ def create_or_update( 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') + body_content = self._serialize.body(parameters, 'CostTags') # Construct and send request request = self._client.put(url, query_parameters) @@ -157,13 +156,13 @@ def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('CostAllocationTags', response) + deserialized = self._deserialize('CostTags', response) if response.status_code == 201: - deserialized = self._deserialize('CostAllocationTags', response) + deserialized = self._deserialize('CostTags', 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'} + create_or_update.metadata = {'url': '/providers/Microsoft.CostManagement/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/costTags'} diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/operations/tags_operations.py b/azure-mgmt-consumption/azure/mgmt/consumption/operations/tags_operations.py new file mode 100644 index 000000000000..39bb97c00f1b --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/operations/tags_operations.py @@ -0,0 +1,94 @@ +# 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 TagsOperations(object): + """TagsOperations 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 all available tag keys 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: Tags or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.consumption.models.Tags 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('Tags', 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/tags'}