Skip to content

Commit

Permalink
[AutoPR consumption/resource-manager] Consumption specifications for …
Browse files Browse the repository at this point in the history
…cost insights and reporting operations (#2692)

* Generated from 1d5842324bcb1bfe92271adacb25ea0a144eab4c

Removed x-ms-odata method for POST op

* Generated from 7eea456cc2d1c2c66a33b2ce1d1cb96889654b7e

Merging upstream to fork
  • Loading branch information
AutorestCI committed Jul 12, 2018
1 parent 979a869 commit 112756d
Show file tree
Hide file tree
Showing 35 changed files with 3,603 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@
from msrest import Serializer, Deserializer
from msrestazure import AzureConfiguration
from .version import VERSION
from msrest.pipeline import ClientRawResponse
import uuid
from .operations.price_sheet_operations import PriceSheetOperations
from .operations.usage_details_operations import UsageDetailsOperations
from .operations.forecasts_operations import ForecastsOperations
from .operations.operations import Operations
from .operations.report_config_operations import ReportConfigOperations
from .operations.billing_account_dimensions_operations import BillingAccountDimensionsOperations
from .operations.subscription_dimensions_operations import SubscriptionDimensionsOperations
from .operations.resource_group_dimensions_operations import ResourceGroupDimensionsOperations
from . import models


Expand Down Expand Up @@ -56,10 +64,22 @@ class ConsumptionManagementClient(object):
:ivar config: Configuration for client.
:vartype config: ConsumptionManagementClientConfiguration
:ivar price_sheet: PriceSheet operations
:vartype price_sheet: azure.mgmt.consumption.operations.PriceSheetOperations
:ivar usage_details: UsageDetails operations
:vartype usage_details: azure.mgmt.consumption.operations.UsageDetailsOperations
:ivar forecasts: Forecasts operations
:vartype forecasts: azure.mgmt.consumption.operations.ForecastsOperations
:ivar operations: Operations operations
:vartype operations: azure.mgmt.consumption.operations.Operations
:ivar report_config: ReportConfig operations
:vartype report_config: azure.mgmt.consumption.operations.ReportConfigOperations
:ivar billing_account_dimensions: BillingAccountDimensions operations
:vartype billing_account_dimensions: azure.mgmt.consumption.operations.BillingAccountDimensionsOperations
:ivar subscription_dimensions: SubscriptionDimensions operations
:vartype subscription_dimensions: azure.mgmt.consumption.operations.SubscriptionDimensionsOperations
:ivar resource_group_dimensions: ResourceGroupDimensions operations
:vartype resource_group_dimensions: azure.mgmt.consumption.operations.ResourceGroupDimensionsOperations
:param credentials: Credentials needed for the client to connect to Azure.
:type credentials: :mod:`A msrestazure Credentials
Expand All @@ -80,7 +100,237 @@ def __init__(
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)

self.price_sheet = PriceSheetOperations(
self._client, self.config, self._serialize, self._deserialize)
self.usage_details = UsageDetailsOperations(
self._client, self.config, self._serialize, self._deserialize)
self.forecasts = ForecastsOperations(
self._client, self.config, self._serialize, self._deserialize)
self.operations = Operations(
self._client, self.config, self._serialize, self._deserialize)
self.report_config = ReportConfigOperations(
self._client, self.config, self._serialize, self._deserialize)
self.billing_account_dimensions = BillingAccountDimensionsOperations(
self._client, self.config, self._serialize, self._deserialize)
self.subscription_dimensions = SubscriptionDimensionsOperations(
self._client, self.config, self._serialize, self._deserialize)
self.resource_group_dimensions = ResourceGroupDimensionsOperations(
self._client, self.config, self._serialize, self._deserialize)

def analyze_subscription_usage(
self, parameters, custom_headers=None, raw=False, **operation_config):
"""Lists the usage data for subscriptionId.
:param parameters: Parameters supplied to the CreateOrUpdate Report
Config operation.
:type parameters:
~azure.mgmt.consumption.models.ReportConfigDefinition
: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: An iterator like instance of UsageAnalysis
:rtype:
~azure.mgmt.consumption.models.UsageAnalysisPaged[~azure.mgmt.consumption.models.UsageAnalysis]
:raises:
:class:`ErrorResponseException<azure.mgmt.consumption.models.ErrorResponseException>`
"""
def internal_paging(next_link=None, raw=False):

if not next_link:
# Construct URL
url = self.analyze_subscription_usage.metadata['url']
path_format_arguments = {
'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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')

else:
url = next_link
query_parameters = {}

# 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, 'ReportConfigDefinition')

# Construct and send request
request = self._client.post(url, query_parameters)
response = self._client.send(
request, header_parameters, body_content, stream=False, **operation_config)

if response.status_code not in [200]:
raise models.ErrorResponseException(self._deserialize, response)

return response

# Deserialize response
deserialized = models.UsageAnalysisPaged(internal_paging, self._deserialize.dependencies)

if raw:
header_dict = {}
client_raw_response = models.UsageAnalysisPaged(internal_paging, self._deserialize.dependencies, header_dict)
return client_raw_response

return deserialized
analyze_subscription_usage.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/AnalyzeUsage'}

def analyze_resource_group_usage(
self, resource_group_name, parameters, custom_headers=None, raw=False, **operation_config):
"""Lists the usage data for subscriptionId and resource group.
:param resource_group_name: Azure Resource Group Name.
:type resource_group_name: str
:param parameters: Parameters supplied to the CreateOrUpdate Report
Config operation.
:type parameters:
~azure.mgmt.consumption.models.ReportConfigDefinition
: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: An iterator like instance of UsageAnalysis
:rtype:
~azure.mgmt.consumption.models.UsageAnalysisPaged[~azure.mgmt.consumption.models.UsageAnalysis]
:raises:
:class:`ErrorResponseException<azure.mgmt.consumption.models.ErrorResponseException>`
"""
def internal_paging(next_link=None, raw=False):

if not next_link:
# Construct URL
url = self.analyze_resource_group_usage.metadata['url']
path_format_arguments = {
'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_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')

else:
url = next_link
query_parameters = {}

# 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, 'ReportConfigDefinition')

# Construct and send request
request = self._client.post(url, query_parameters)
response = self._client.send(
request, header_parameters, body_content, stream=False, **operation_config)

if response.status_code not in [200]:
raise models.ErrorResponseException(self._deserialize, response)

return response

# Deserialize response
deserialized = models.UsageAnalysisPaged(internal_paging, self._deserialize.dependencies)

if raw:
header_dict = {}
client_raw_response = models.UsageAnalysisPaged(internal_paging, self._deserialize.dependencies, header_dict)
return client_raw_response

return deserialized
analyze_resource_group_usage.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Consumption/AnalyzeUsage'}

def analyze_billing_account_usage(
self, billing_account_id, parameters, custom_headers=None, raw=False, **operation_config):
"""Lists the usage data for billing account.
:param billing_account_id: BillingAccount ID
:type billing_account_id: str
:param parameters: Parameters supplied to the CreateOrUpdate Report
Config operation.
:type parameters:
~azure.mgmt.consumption.models.ReportConfigDefinition
: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: An iterator like instance of UsageAnalysis
:rtype:
~azure.mgmt.consumption.models.UsageAnalysisPaged[~azure.mgmt.consumption.models.UsageAnalysis]
:raises:
:class:`ErrorResponseException<azure.mgmt.consumption.models.ErrorResponseException>`
"""
def internal_paging(next_link=None, raw=False):

if not next_link:
# Construct URL
url = self.analyze_billing_account_usage.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')

else:
url = next_link
query_parameters = {}

# 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, 'ReportConfigDefinition')

# Construct and send request
request = self._client.post(url, query_parameters)
response = self._client.send(
request, header_parameters, body_content, stream=False, **operation_config)

if response.status_code not in [200]:
raise models.ErrorResponseException(self._deserialize, response)

return response

# Deserialize response
deserialized = models.UsageAnalysisPaged(internal_paging, self._deserialize.dependencies)

if raw:
header_dict = {}
client_raw_response = models.UsageAnalysisPaged(internal_paging, self._deserialize.dependencies, header_dict)
return client_raw_response

return deserialized
analyze_billing_account_usage.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/AnalyzeUsage'}
62 changes: 62 additions & 0 deletions azure-mgmt-consumption/azure/mgmt/consumption/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,45 @@
from .operation_display import OperationDisplay
from .operation import Operation
from .resource import Resource
from .meter_details import MeterDetails
from .price_sheet_properties import PriceSheetProperties
from .price_sheet_result import PriceSheetResult
from .forecast_properties_confidence_levels_item import ForecastPropertiesConfidenceLevelsItem
from .forecast import Forecast
from .usage_detail import UsageDetail
from .report_config_recurrence_period import ReportConfigRecurrencePeriod
from .report_config_schedule import ReportConfigSchedule
from .report_config_delivery_destination import ReportConfigDeliveryDestination
from .report_config_delivery_info import ReportConfigDeliveryInfo
from .report_config_time_period import ReportConfigTimePeriod
from .report_config_dataset_configuration import ReportConfigDatasetConfiguration
from .report_config_aggregation import ReportConfigAggregation
from .report_config_grouping import ReportConfigGrouping
from .report_config_comparison_expression import ReportConfigComparisonExpression
from .report_config_filter import ReportConfigFilter
from .report_config_dataset import ReportConfigDataset
from .report_config_definition import ReportConfigDefinition
from .report_config import ReportConfig
from .report_config_list_result import ReportConfigListResult
from .dimension import Dimension
from .usage_analysis_column import UsageAnalysisColumn
from .usage_analysis import UsageAnalysis
from .query_options import QueryOptions
from .usage_detail_paged import UsageDetailPaged
from .forecast_paged import ForecastPaged
from .operation_paged import OperationPaged
from .dimension_paged import DimensionPaged
from .usage_analysis_paged import UsageAnalysisPaged
from .consumption_management_client_enums import (
Grain,
ChargeType,
Bound,
StatusType,
RecurrenceType,
FormatType,
TimeframeType,
GranularityType,
ReportConfigColumnType,
)

__all__ = [
Expand All @@ -30,11 +61,42 @@
'OperationDisplay',
'Operation',
'Resource',
'MeterDetails',
'PriceSheetProperties',
'PriceSheetResult',
'ForecastPropertiesConfidenceLevelsItem',
'Forecast',
'UsageDetail',
'ReportConfigRecurrencePeriod',
'ReportConfigSchedule',
'ReportConfigDeliveryDestination',
'ReportConfigDeliveryInfo',
'ReportConfigTimePeriod',
'ReportConfigDatasetConfiguration',
'ReportConfigAggregation',
'ReportConfigGrouping',
'ReportConfigComparisonExpression',
'ReportConfigFilter',
'ReportConfigDataset',
'ReportConfigDefinition',
'ReportConfig',
'ReportConfigListResult',
'Dimension',
'UsageAnalysisColumn',
'UsageAnalysis',
'QueryOptions',
'UsageDetailPaged',
'ForecastPaged',
'OperationPaged',
'DimensionPaged',
'UsageAnalysisPaged',
'Grain',
'ChargeType',
'Bound',
'StatusType',
'RecurrenceType',
'FormatType',
'TimeframeType',
'GranularityType',
'ReportConfigColumnType',
]
Loading

0 comments on commit 112756d

Please sign in to comment.