-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AutoPR consumption/resource-manager] Added schema spec for cost allo…
…cation tags (#2263) * Generated from 6388784ef9904e750e9ce09918b2b65e7d984616 Added schema spec for cost allocation tags Added schema spec for cost allocation tags * Generated from 3ccf1b464815326349f015f17a600df4ab5e35ab Updated Get Operation Updated Get Operation * Generated from 884aabe8882d794b987236ad2b0927a98317d28f Incorporated review comments Incorporated review comments * Generated from 3d1c7c16a7266814f1e4bd997169df1ebd1d2bce Review comments incorporated Review comments incorporated * Generated from def63250017ef0071aadd68a751623913f788af3 Updated path Updated path
- Loading branch information
1 parent
223df61
commit ef356ef
Showing
7 changed files
with
273 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
azure-mgmt-consumption/azure/mgmt/consumption/models/cost_allocation_tag.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 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 |
52 changes: 52 additions & 0 deletions
52
azure-mgmt-consumption/azure/mgmt/consumption/models/cost_allocation_tags.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
169 changes: 169 additions & 0 deletions
169
azure-mgmt-consumption/azure/mgmt/consumption/operations/cost_allocation_tags_operations.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<msrest:optionsforoperations>`. | ||
:return: CostAllocationTags or ClientRawResponse if raw=true | ||
:rtype: ~azure.mgmt.consumption.models.CostAllocationTags or | ||
~msrest.pipeline.ClientRawResponse | ||
:raises: | ||
:class:`ErrorResponseException<azure.mgmt.consumption.models.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<msrest:optionsforoperations>`. | ||
:return: CostAllocationTags or ClientRawResponse if raw=true | ||
:rtype: ~azure.mgmt.consumption.models.CostAllocationTags or | ||
~msrest.pipeline.ClientRawResponse | ||
:raises: | ||
:class:`ErrorResponseException<azure.mgmt.consumption.models.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'} |
Oops, something went wrong.