Skip to content

Commit

Permalink
[AutoPR consumption/resource-manager] Introducing UsageDetails and Ag…
Browse files Browse the repository at this point in the history
…gregated Cost by Managment Group Scope. Also updated some existing examples to include missing billingperiod in billingPeriodId Property. (#3085)

* Generated from 12751061e78dc5b2f8eeef917245068f094e5d14

Introducing UsageDetails and Aggregated Cost by Managment Group Scope. Also updated some existing examples to include missing "billingperiod" in "billingPeriodId" Property.

* Generated from f7e522f1bd3b5937cf127b68da80d85c60631b2b

Addressed comments from review

* Generated from 0dc16e7f2fcf746f4c39a977d4a04c862b47dd26

Added location parameter to managementgroupId and also added Get To method name of AggregatedCost
  • Loading branch information
AutorestCI authored Aug 9, 2018
1 parent faf478f commit 86b7fd4
Show file tree
Hide file tree
Showing 18 changed files with 649 additions and 139 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from .operations.tags_operations import TagsOperations
from .operations.forecasts_operations import ForecastsOperations
from .operations.operations import Operations
from .operations.aggregated_cost_operations import AggregatedCostOperations
from . import models


Expand Down Expand Up @@ -90,6 +91,8 @@ class ConsumptionManagementClient(SDKClient):
:vartype forecasts: azure.mgmt.consumption.operations.ForecastsOperations
:ivar operations: Operations operations
:vartype operations: azure.mgmt.consumption.operations.Operations
:ivar aggregated_cost: AggregatedCost operations
:vartype aggregated_cost: azure.mgmt.consumption.operations.AggregatedCostOperations
:param credentials: Credentials needed for the client to connect to Azure.
:type credentials: :mod:`A msrestazure Credentials
Expand Down Expand Up @@ -134,3 +137,5 @@ def __init__(
self._client, self.config, self._serialize, self._deserialize)
self.operations = Operations(
self._client, self.config, self._serialize, self._deserialize)
self.aggregated_cost = AggregatedCostOperations(
self._client, self.config, self._serialize, self._deserialize)
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from .price_sheet_result_py3 import PriceSheetResult
from .forecast_properties_confidence_levels_item_py3 import ForecastPropertiesConfidenceLevelsItem
from .forecast_py3 import Forecast
from .management_group_aggregated_cost_result_py3 import ManagementGroupAggregatedCostResult
from .error_details_py3 import ErrorDetails
from .error_response_py3 import ErrorResponse, ErrorResponseException
from .operation_display_py3 import OperationDisplay
Expand Down Expand Up @@ -63,6 +64,7 @@
from .price_sheet_result import PriceSheetResult
from .forecast_properties_confidence_levels_item import ForecastPropertiesConfidenceLevelsItem
from .forecast import Forecast
from .management_group_aggregated_cost_result import ManagementGroupAggregatedCostResult
from .error_details import ErrorDetails
from .error_response import ErrorResponse, ErrorResponseException
from .operation_display import OperationDisplay
Expand Down Expand Up @@ -113,6 +115,7 @@
'PriceSheetResult',
'ForecastPropertiesConfidenceLevelsItem',
'Forecast',
'ManagementGroupAggregatedCostResult',
'ErrorDetails',
'ErrorResponse', 'ErrorResponseException',
'OperationDisplay',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# 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 .resource import Resource


class ManagementGroupAggregatedCostResult(Resource):
"""A management group aggregated cost 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
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar billing_period_id: The id of the billing period resource that the
aggregated cost belongs to.
:vartype billing_period_id: str
:ivar azure_charges: Azure Charges.
:vartype azure_charges: decimal.Decimal
:ivar marketplace_charges: Marketplace Charges.
:vartype marketplace_charges: decimal.Decimal
:ivar charges_billed_separately: Charges Billed Separately.
:vartype charges_billed_separately: decimal.Decimal
:ivar currency: The ISO currency in which the meter is charged, for
example, USD.
:vartype currency: str
:param children: Children of a management group
:type children:
list[~azure.mgmt.consumption.models.ManagementGroupAggregatedCostResult]
"""

_validation = {
'id': {'readonly': True},
'name': {'readonly': True},
'type': {'readonly': True},
'tags': {'readonly': True},
'billing_period_id': {'readonly': True},
'azure_charges': {'readonly': True},
'marketplace_charges': {'readonly': True},
'charges_billed_separately': {'readonly': True},
'currency': {'readonly': True},
}

_attribute_map = {
'id': {'key': 'id', 'type': 'str'},
'name': {'key': 'name', 'type': 'str'},
'type': {'key': 'type', 'type': 'str'},
'tags': {'key': 'tags', 'type': '{str}'},
'billing_period_id': {'key': 'properties.billingPeriodId', 'type': 'str'},
'azure_charges': {'key': 'properties.azureCharges', 'type': 'decimal'},
'marketplace_charges': {'key': 'properties.marketplaceCharges', 'type': 'decimal'},
'charges_billed_separately': {'key': 'properties.chargesBilledSeparately', 'type': 'decimal'},
'currency': {'key': 'properties.currency', 'type': 'str'},
'children': {'key': 'properties.children', 'type': '[ManagementGroupAggregatedCostResult]'},
}

def __init__(self, **kwargs):
super(ManagementGroupAggregatedCostResult, self).__init__(**kwargs)
self.billing_period_id = None
self.azure_charges = None
self.marketplace_charges = None
self.charges_billed_separately = None
self.currency = None
self.children = kwargs.get('children', None)
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# 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 .resource_py3 import Resource


class ManagementGroupAggregatedCostResult(Resource):
"""A management group aggregated cost 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
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar billing_period_id: The id of the billing period resource that the
aggregated cost belongs to.
:vartype billing_period_id: str
:ivar azure_charges: Azure Charges.
:vartype azure_charges: decimal.Decimal
:ivar marketplace_charges: Marketplace Charges.
:vartype marketplace_charges: decimal.Decimal
:ivar charges_billed_separately: Charges Billed Separately.
:vartype charges_billed_separately: decimal.Decimal
:ivar currency: The ISO currency in which the meter is charged, for
example, USD.
:vartype currency: str
:param children: Children of a management group
:type children:
list[~azure.mgmt.consumption.models.ManagementGroupAggregatedCostResult]
"""

_validation = {
'id': {'readonly': True},
'name': {'readonly': True},
'type': {'readonly': True},
'tags': {'readonly': True},
'billing_period_id': {'readonly': True},
'azure_charges': {'readonly': True},
'marketplace_charges': {'readonly': True},
'charges_billed_separately': {'readonly': True},
'currency': {'readonly': True},
}

_attribute_map = {
'id': {'key': 'id', 'type': 'str'},
'name': {'key': 'name', 'type': 'str'},
'type': {'key': 'type', 'type': 'str'},
'tags': {'key': 'tags', 'type': '{str}'},
'billing_period_id': {'key': 'properties.billingPeriodId', 'type': 'str'},
'azure_charges': {'key': 'properties.azureCharges', 'type': 'decimal'},
'marketplace_charges': {'key': 'properties.marketplaceCharges', 'type': 'decimal'},
'charges_billed_separately': {'key': 'properties.chargesBilledSeparately', 'type': 'decimal'},
'currency': {'key': 'properties.currency', 'type': 'str'},
'children': {'key': 'properties.children', 'type': '[ManagementGroupAggregatedCostResult]'},
}

def __init__(self, *, children=None, **kwargs) -> None:
super(ManagementGroupAggregatedCostResult, self).__init__(**kwargs)
self.billing_period_id = None
self.azure_charges = None
self.marketplace_charges = None
self.charges_billed_separately = None
self.currency = None
self.children = children
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from .tags_operations import TagsOperations
from .forecasts_operations import ForecastsOperations
from .operations import Operations
from .aggregated_cost_operations import AggregatedCostOperations

__all__ = [
'UsageDetailsOperations',
Expand All @@ -35,4 +36,5 @@
'TagsOperations',
'ForecastsOperations',
'Operations',
'AggregatedCostOperations',
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# 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 AggregatedCostOperations(object):
"""AggregatedCostOperations 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-06-30. Constant value: "2018-06-30".
"""

models = models

def __init__(self, client, config, serializer, deserializer):

self._client = client
self._serialize = serializer
self._deserialize = deserializer
self.api_version = "2018-06-30"

self.config = config

def get_by_management_group(
self, management_group_id, custom_headers=None, raw=False, **operation_config):
"""Provides the aggregate cost of a management group and all child
management groups by current billing period.
:param management_group_id: Azure Management Group ID.
:type management_group_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: ManagementGroupAggregatedCostResult or ClientRawResponse if
raw=true
:rtype:
~azure.mgmt.consumption.models.ManagementGroupAggregatedCostResult or
~msrest.pipeline.ClientRawResponse
:raises:
:class:`ErrorResponseException<azure.mgmt.consumption.models.ErrorResponseException>`
"""
# Construct URL
url = self.get_by_management_group.metadata['url']
path_format_arguments = {
'managementGroupId': self._serialize.url("management_group_id", management_group_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'
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)
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('ManagementGroupAggregatedCostResult', response)

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

return deserialized
get_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Consumption/aggregatedcost'}

def get_for_billing_period_by_management_group(
self, management_group_id, billing_period_name, custom_headers=None, raw=False, **operation_config):
"""Provides the aggregate cost of a management group and all child
management groups by specified billing period.
:param management_group_id: Azure Management Group ID.
:type management_group_id: str
:param billing_period_name: Billing Period Name.
:type billing_period_name: 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: ManagementGroupAggregatedCostResult or ClientRawResponse if
raw=true
:rtype:
~azure.mgmt.consumption.models.ManagementGroupAggregatedCostResult or
~msrest.pipeline.ClientRawResponse
:raises:
:class:`ErrorResponseException<azure.mgmt.consumption.models.ErrorResponseException>`
"""
# Construct URL
url = self.get_for_billing_period_by_management_group.metadata['url']
path_format_arguments = {
'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'),
'billingPeriodName': self._serialize.url("billing_period_name", billing_period_name, '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'
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)
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('ManagementGroupAggregatedCostResult', response)

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

return deserialized
get_for_billing_period_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/Microsoft.Consumption/aggregatedcost'}
Loading

0 comments on commit 86b7fd4

Please sign in to comment.