Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
from msrest import Serializer, Deserializer
from msrestazure import AzureConfiguration
from .version import VERSION
from msrest.pipeline import ClientRawResponse
import uuid
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 .operations.dimensions_operations import DimensionsOperations
from .operations.query_operations import QueryOperations
from .operations.forecast_operations import ForecastOperations
from .operations.cloud_connector_operations import CloudConnectorOperations
from .operations.external_billing_account_operations import ExternalBillingAccountOperations
from .operations.external_subscription_operations import ExternalSubscriptionOperations
from .operations.entities_operations import EntitiesOperations
from .operations.operations import Operations
from . import models

Expand Down Expand Up @@ -61,14 +62,20 @@ class CostManagementClient(SDKClient):
:ivar config: Configuration for client.
:vartype config: CostManagementClientConfiguration

:ivar report_config: ReportConfig operations
:vartype report_config: azure.mgmt.costmanagement.operations.ReportConfigOperations
:ivar billing_account_dimensions: BillingAccountDimensions operations
:vartype billing_account_dimensions: azure.mgmt.costmanagement.operations.BillingAccountDimensionsOperations
:ivar subscription_dimensions: SubscriptionDimensions operations
:vartype subscription_dimensions: azure.mgmt.costmanagement.operations.SubscriptionDimensionsOperations
:ivar resource_group_dimensions: ResourceGroupDimensions operations
:vartype resource_group_dimensions: azure.mgmt.costmanagement.operations.ResourceGroupDimensionsOperations
:ivar dimensions: Dimensions operations
:vartype dimensions: azure.mgmt.costmanagement.operations.DimensionsOperations
:ivar query: Query operations
:vartype query: azure.mgmt.costmanagement.operations.QueryOperations
:ivar forecast: Forecast operations
:vartype forecast: azure.mgmt.costmanagement.operations.ForecastOperations
:ivar cloud_connector: CloudConnector operations
:vartype cloud_connector: azure.mgmt.costmanagement.operations.CloudConnectorOperations
:ivar external_billing_account: ExternalBillingAccount operations
:vartype external_billing_account: azure.mgmt.costmanagement.operations.ExternalBillingAccountOperations
:ivar external_subscription: ExternalSubscription operations
:vartype external_subscription: azure.mgmt.costmanagement.operations.ExternalSubscriptionOperations
:ivar entities: Entities operations
:vartype entities: azure.mgmt.costmanagement.operations.EntitiesOperations
:ivar operations: Operations operations
:vartype operations: azure.mgmt.costmanagement.operations.Operations

Expand All @@ -87,235 +94,23 @@ def __init__(
super(CostManagementClient, self).__init__(self.config.credentials, self.config)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self.api_version = '2018-05-31'
self.api_version = '2019-03-01-preview'
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)

self.report_config = ReportConfigOperations(
self.dimensions = DimensionsOperations(
self._client, self.config, self._serialize, self._deserialize)
self.billing_account_dimensions = BillingAccountDimensionsOperations(
self.query = QueryOperations(
self._client, self.config, self._serialize, self._deserialize)
self.subscription_dimensions = SubscriptionDimensionsOperations(
self.forecast = ForecastOperations(
self._client, self.config, self._serialize, self._deserialize)
self.resource_group_dimensions = ResourceGroupDimensionsOperations(
self.cloud_connector = CloudConnectorOperations(
self._client, self.config, self._serialize, self._deserialize)
self.external_billing_account = ExternalBillingAccountOperations(
self._client, self.config, self._serialize, self._deserialize)
self.external_subscription = ExternalSubscriptionOperations(
self._client, self.config, self._serialize, self._deserialize)
self.entities = EntitiesOperations(
self._client, self.config, self._serialize, self._deserialize)
self.operations = Operations(
self._client, self.config, self._serialize, self._deserialize)

def query_subscription(
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.costmanagement.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 Query
:rtype:
~azure.mgmt.costmanagement.models.QueryPaged[~azure.mgmt.costmanagement.models.Query]
:raises:
:class:`ErrorResponseException<azure.mgmt.costmanagement.models.ErrorResponseException>`
"""
def internal_paging(next_link=None, raw=False):

if not next_link:
# Construct URL
url = self.query_subscription.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['Accept'] = 'application/json'
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, header_parameters, body_content)
response = self._client.send(request, stream=False, **operation_config)

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

return response

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

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

return deserialized
query_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CostManagement/Query'}

def query_resource_group(
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.costmanagement.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 Query
:rtype:
~azure.mgmt.costmanagement.models.QueryPaged[~azure.mgmt.costmanagement.models.Query]
:raises:
:class:`ErrorResponseException<azure.mgmt.costmanagement.models.ErrorResponseException>`
"""
def internal_paging(next_link=None, raw=False):

if not next_link:
# Construct URL
url = self.query_resource_group.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['Accept'] = 'application/json'
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, header_parameters, body_content)
response = self._client.send(request, stream=False, **operation_config)

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

return response

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

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

return deserialized
query_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.CostManagement/Query'}

def query_billing_account(
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.costmanagement.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 Query
:rtype:
~azure.mgmt.costmanagement.models.QueryPaged[~azure.mgmt.costmanagement.models.Query]
:raises:
:class:`ErrorResponseException<azure.mgmt.costmanagement.models.ErrorResponseException>`
"""
def internal_paging(next_link=None, raw=False):

if not next_link:
# Construct URL
url = self.query_billing_account.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['Accept'] = 'application/json'
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, header_parameters, body_content)
response = self._client.send(request, stream=False, **operation_config)

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

return response

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

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

return deserialized
query_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/Query'}
Loading