diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_cost_management_client.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_cost_management_client.py index 526f8dda92663..71864191a97c1 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_cost_management_client.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_cost_management_client.py @@ -13,10 +13,13 @@ from msrest import Serializer, Deserializer from ._configuration import CostManagementClientConfiguration +from .operations import ViewsOperations +from .operations import AlertsOperations +from .operations import ForecastOperations from .operations import DimensionsOperations from .operations import QueryOperations -from .operations import ExportsOperations from .operations import Operations +from .operations import ExportsOperations from . import models @@ -26,14 +29,20 @@ class CostManagementClient(SDKClient): :ivar config: Configuration for client. :vartype config: CostManagementClientConfiguration + :ivar views: Views operations + :vartype views: azure.mgmt.costmanagement.operations.ViewsOperations + :ivar alerts: Alerts operations + :vartype alerts: azure.mgmt.costmanagement.operations.AlertsOperations + :ivar forecast: Forecast operations + :vartype forecast: azure.mgmt.costmanagement.operations.ForecastOperations :ivar dimensions: Dimensions operations :vartype dimensions: azure.mgmt.costmanagement.operations.DimensionsOperations :ivar query: Query operations :vartype query: azure.mgmt.costmanagement.operations.QueryOperations - :ivar exports: Exports operations - :vartype exports: azure.mgmt.costmanagement.operations.ExportsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.costmanagement.operations.Operations + :ivar exports: Exports operations + :vartype exports: azure.mgmt.costmanagement.operations.ExportsOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials @@ -50,15 +59,21 @@ 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 = '2019-11-01' + self.api_version = '2020-06-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) + self.views = ViewsOperations( + self._client, self.config, self._serialize, self._deserialize) + self.alerts = AlertsOperations( + self._client, self.config, self._serialize, self._deserialize) + self.forecast = ForecastOperations( + self._client, self.config, self._serialize, self._deserialize) self.dimensions = DimensionsOperations( self._client, self.config, self._serialize, self._deserialize) self.query = QueryOperations( self._client, self.config, self._serialize, self._deserialize) - self.exports = ExportsOperations( - self._client, self.config, self._serialize, self._deserialize) self.operations = Operations( self._client, self.config, self._serialize, self._deserialize) + self.exports = ExportsOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/__init__.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/__init__.py index f9cce82b9bb84..4a333a7c4b892 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/__init__.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/__init__.py @@ -10,11 +10,19 @@ # -------------------------------------------------------------------------- try: + from ._models_py3 import Alert + from ._models_py3 import AlertPropertiesDefinition + from ._models_py3 import AlertPropertiesDetails + from ._models_py3 import AlertsResult from ._models_py3 import CommonExportProperties from ._models_py3 import Dimension + from ._models_py3 import DismissAlertPayload from ._models_py3 import ErrorDetails from ._models_py3 import ErrorResponse, ErrorResponseException from ._models_py3 import Export + from ._models_py3 import ExportDataset + from ._models_py3 import ExportDatasetConfiguration + from ._models_py3 import ExportDefinition from ._models_py3 import ExportDeliveryDestination from ._models_py3 import ExportDeliveryInfo from ._models_py3 import ExportExecution @@ -22,8 +30,14 @@ from ._models_py3 import ExportListResult from ._models_py3 import ExportRecurrencePeriod from ._models_py3 import ExportSchedule + from ._models_py3 import ExportTimePeriod + from ._models_py3 import ForecastDataset + from ._models_py3 import ForecastDefinition + from ._models_py3 import KpiProperties from ._models_py3 import Operation from ._models_py3 import OperationDisplay + from ._models_py3 import PivotProperties + from ._models_py3 import ProxyResource from ._models_py3 import QueryAggregation from ._models_py3 import QueryColumn from ._models_py3 import QueryComparisonExpression @@ -34,13 +48,30 @@ from ._models_py3 import QueryGrouping from ._models_py3 import QueryResult from ._models_py3 import QueryTimePeriod + from ._models_py3 import ReportConfigAggregation + from ._models_py3 import ReportConfigComparisonExpression + from ._models_py3 import ReportConfigDataset + from ._models_py3 import ReportConfigDatasetConfiguration + from ._models_py3 import ReportConfigFilter + from ._models_py3 import ReportConfigGrouping + from ._models_py3 import ReportConfigSorting + from ._models_py3 import ReportConfigTimePeriod from ._models_py3 import Resource + from ._models_py3 import View except (SyntaxError, ImportError): + from ._models import Alert + from ._models import AlertPropertiesDefinition + from ._models import AlertPropertiesDetails + from ._models import AlertsResult from ._models import CommonExportProperties from ._models import Dimension + from ._models import DismissAlertPayload from ._models import ErrorDetails from ._models import ErrorResponse, ErrorResponseException from ._models import Export + from ._models import ExportDataset + from ._models import ExportDatasetConfiguration + from ._models import ExportDefinition from ._models import ExportDeliveryDestination from ._models import ExportDeliveryInfo from ._models import ExportExecution @@ -48,8 +79,14 @@ from ._models import ExportListResult from ._models import ExportRecurrencePeriod from ._models import ExportSchedule + from ._models import ExportTimePeriod + from ._models import ForecastDataset + from ._models import ForecastDefinition + from ._models import KpiProperties from ._models import Operation from ._models import OperationDisplay + from ._models import PivotProperties + from ._models import ProxyResource from ._models import QueryAggregation from ._models import QueryColumn from ._models import QueryComparisonExpression @@ -60,27 +97,64 @@ from ._models import QueryGrouping from ._models import QueryResult from ._models import QueryTimePeriod + from ._models import ReportConfigAggregation + from ._models import ReportConfigComparisonExpression + from ._models import ReportConfigDataset + from ._models import ReportConfigDatasetConfiguration + from ._models import ReportConfigFilter + from ._models import ReportConfigGrouping + from ._models import ReportConfigSorting + from ._models import ReportConfigTimePeriod from ._models import Resource + from ._models import View from ._paged_models import DimensionPaged from ._paged_models import OperationPaged +from ._paged_models import ViewPaged from ._cost_management_client_enums import ( + ReportTimeframeType, + ReportGranularityType, + ReportConfigColumnType, + OperatorType, + ChartType, + AccumulatedType, + MetricType, + KpiTypeType, + PivotTypeType, + AlertType, + AlertCategory, + AlertCriteria, + AlertSource, + AlertTimeGrainType, + AlertOperator, + AlertStatus, + ForecastType, + ForecastTimeframeType, + GranularityType, ExportType, TimeframeType, - GranularityType, QueryColumnType, StatusType, RecurrenceType, FormatType, ExecutionType, ExecutionStatus, + ExternalCloudProviderType, ) __all__ = [ + 'Alert', + 'AlertPropertiesDefinition', + 'AlertPropertiesDetails', + 'AlertsResult', 'CommonExportProperties', 'Dimension', + 'DismissAlertPayload', 'ErrorDetails', 'ErrorResponse', 'ErrorResponseException', 'Export', + 'ExportDataset', + 'ExportDatasetConfiguration', + 'ExportDefinition', 'ExportDeliveryDestination', 'ExportDeliveryInfo', 'ExportExecution', @@ -88,8 +162,14 @@ 'ExportListResult', 'ExportRecurrencePeriod', 'ExportSchedule', + 'ExportTimePeriod', + 'ForecastDataset', + 'ForecastDefinition', + 'KpiProperties', 'Operation', 'OperationDisplay', + 'PivotProperties', + 'ProxyResource', 'QueryAggregation', 'QueryColumn', 'QueryComparisonExpression', @@ -100,16 +180,45 @@ 'QueryGrouping', 'QueryResult', 'QueryTimePeriod', + 'ReportConfigAggregation', + 'ReportConfigComparisonExpression', + 'ReportConfigDataset', + 'ReportConfigDatasetConfiguration', + 'ReportConfigFilter', + 'ReportConfigGrouping', + 'ReportConfigSorting', + 'ReportConfigTimePeriod', 'Resource', + 'View', + 'ViewPaged', 'DimensionPaged', 'OperationPaged', + 'ReportTimeframeType', + 'ReportGranularityType', + 'ReportConfigColumnType', + 'OperatorType', + 'ChartType', + 'AccumulatedType', + 'MetricType', + 'KpiTypeType', + 'PivotTypeType', + 'AlertType', + 'AlertCategory', + 'AlertCriteria', + 'AlertSource', + 'AlertTimeGrainType', + 'AlertOperator', + 'AlertStatus', + 'ForecastType', + 'ForecastTimeframeType', + 'GranularityType', 'ExportType', 'TimeframeType', - 'GranularityType', 'QueryColumnType', 'StatusType', 'RecurrenceType', 'FormatType', 'ExecutionType', 'ExecutionStatus', + 'ExternalCloudProviderType', ] diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_cost_management_client_enums.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_cost_management_client_enums.py index d447d84449086..a8381825a493a 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_cost_management_client_enums.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_cost_management_client_enums.py @@ -12,14 +12,147 @@ from enum import Enum -class ExportType(str, Enum): +class ReportTimeframeType(str, Enum): + + week_to_date = "WeekToDate" + month_to_date = "MonthToDate" + year_to_date = "YearToDate" + custom = "Custom" + + +class ReportGranularityType(str, Enum): + + daily = "Daily" + monthly = "Monthly" + + +class ReportConfigColumnType(str, Enum): + + tag = "Tag" + dimension = "Dimension" + + +class OperatorType(str, Enum): + + in_enum = "In" + contains = "Contains" + + +class ChartType(str, Enum): + + area = "Area" + line = "Line" + stacked_column = "StackedColumn" + grouped_column = "GroupedColumn" + table = "Table" + + +class AccumulatedType(str, Enum): + + true = "true" + false = "false" + + +class MetricType(str, Enum): + + actual_cost = "ActualCost" + amortized_cost = "AmortizedCost" + ahub = "AHUB" + + +class KpiTypeType(str, Enum): + + forecast = "Forecast" + budget = "Budget" + + +class PivotTypeType(str, Enum): + + dimension = "Dimension" + tag_key = "TagKey" + + +class AlertType(str, Enum): + + budget = "Budget" + invoice = "Invoice" + credit = "Credit" + quota = "Quota" + general = "General" + x_cloud = "xCloud" + budget_forecast = "BudgetForecast" + + +class AlertCategory(str, Enum): + + cost = "Cost" + usage = "Usage" + billing = "Billing" + system = "System" + + +class AlertCriteria(str, Enum): + + cost_threshold_exceeded = "CostThresholdExceeded" + usage_threshold_exceeded = "UsageThresholdExceeded" + credit_threshold_approaching = "CreditThresholdApproaching" + credit_threshold_reached = "CreditThresholdReached" + quota_threshold_approaching = "QuotaThresholdApproaching" + quota_threshold_reached = "QuotaThresholdReached" + multi_currency = "MultiCurrency" + forecast_cost_threshold_exceeded = "ForecastCostThresholdExceeded" + forecast_usage_threshold_exceeded = "ForecastUsageThresholdExceeded" + invoice_due_date_approaching = "InvoiceDueDateApproaching" + invoice_due_date_reached = "InvoiceDueDateReached" + cross_cloud_new_data_available = "CrossCloudNewDataAvailable" + cross_cloud_collection_error = "CrossCloudCollectionError" + general_threshold_error = "GeneralThresholdError" + + +class AlertSource(str, Enum): + + preset = "Preset" + user = "User" + + +class AlertTimeGrainType(str, Enum): + + none = "None" + monthly = "Monthly" + quarterly = "Quarterly" + annually = "Annually" + billing_month = "BillingMonth" + billing_quarter = "BillingQuarter" + billing_annual = "BillingAnnual" + + +class AlertOperator(str, Enum): + + none = "None" + equal_to = "EqualTo" + greater_than = "GreaterThan" + greater_than_or_equal_to = "GreaterThanOrEqualTo" + less_than = "LessThan" + less_than_or_equal_to = "LessThanOrEqualTo" + + +class AlertStatus(str, Enum): + + none = "None" + active = "Active" + overridden = "Overridden" + resolved = "Resolved" + dismissed = "Dismissed" + + +class ForecastType(str, Enum): usage = "Usage" actual_cost = "ActualCost" amortized_cost = "AmortizedCost" -class TimeframeType(str, Enum): +class ForecastTimeframeType(str, Enum): month_to_date = "MonthToDate" billing_month_to_date = "BillingMonthToDate" @@ -34,6 +167,23 @@ class GranularityType(str, Enum): daily = "Daily" +class ExportType(str, Enum): + + usage = "Usage" + actual_cost = "ActualCost" + amortized_cost = "AmortizedCost" + + +class TimeframeType(str, Enum): + + month_to_date = "MonthToDate" + billing_month_to_date = "BillingMonthToDate" + the_last_month = "TheLastMonth" + the_last_billing_month = "TheLastBillingMonth" + week_to_date = "WeekToDate" + custom = "Custom" + + class QueryColumnType(str, Enum): tag = "Tag" @@ -74,3 +224,9 @@ class ExecutionStatus(str, Enum): timeout = "Timeout" new_data_not_available = "NewDataNotAvailable" data_not_available = "DataNotAvailable" + + +class ExternalCloudProviderType(str, Enum): + + external_subscriptions = "externalSubscriptions" + external_billing_accounts = "externalBillingAccounts" diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_models.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_models.py index b06344b3295c3..e0ac146064877 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_models.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_models.py @@ -13,48 +13,46 @@ from msrest.exceptions import HttpOperationError -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } - - -class CommonExportProperties(Model): - """The common properties of the export. +class Resource(Model): + """The Resource model definition. - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when + sending a request. - :param format: The format of the export being delivered. Possible values - include: 'Csv' - :type format: str or ~azure.mgmt.costmanagement.models.FormatType - :param delivery_info: Required. Has delivery information for the export. - :type delivery_info: ~azure.mgmt.costmanagement.models.ExportDeliveryInfo - :param definition: Required. Has definition for the export. - :type definition: ~azure.mgmt.costmanagement.models.QueryDefinition + :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] """ _validation = { - 'delivery_info': {'required': True}, - 'definition': {'required': True}, + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'tags': {'readonly': True}, } _attribute_map = { - 'format': {'key': 'format', 'type': 'str'}, - 'delivery_info': {'key': 'deliveryInfo', 'type': 'ExportDeliveryInfo'}, - 'definition': {'key': 'definition', 'type': 'QueryDefinition'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, } def __init__(self, **kwargs): - super(CommonExportProperties, self).__init__(**kwargs) - self.format = kwargs.get('format', None) - self.delivery_info = kwargs.get('delivery_info', None) - self.definition = kwargs.get('definition', None) + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.tags = None -class Resource(Model): - """The Resource model definition. +class Alert(Resource): + """An individual alert. Variables are only populated by the server, and will be ignored when sending a request. @@ -67,6 +65,31 @@ class Resource(Model): :vartype type: str :ivar tags: Resource tags. :vartype tags: dict[str, str] + :param definition: defines the type of alert + :type definition: + ~azure.mgmt.costmanagement.models.AlertPropertiesDefinition + :param description: Alert description + :type description: str + :param source: Source of alert. Possible values include: 'Preset', 'User' + :type source: str or ~azure.mgmt.costmanagement.models.AlertSource + :param details: Alert details + :type details: ~azure.mgmt.costmanagement.models.AlertPropertiesDetails + :param cost_entity_id: related budget + :type cost_entity_id: str + :param status: alert status. Possible values include: 'None', 'Active', + 'Overridden', 'Resolved', 'Dismissed' + :type status: str or ~azure.mgmt.costmanagement.models.AlertStatus + :param creation_time: dateTime in which alert was created + :type creation_time: str + :param close_time: dateTime in which alert was closed + :type close_time: str + :param modification_time: dateTime in which alert was last modified + :type modification_time: str + :param status_modification_user_name: + :type status_modification_user_name: str + :param status_modification_time: dateTime in which the alert status was + last modified + :type status_modification_time: str """ _validation = { @@ -81,14 +104,231 @@ class Resource(Model): 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, + 'definition': {'key': 'properties.definition', 'type': 'AlertPropertiesDefinition'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'source': {'key': 'properties.source', 'type': 'str'}, + 'details': {'key': 'properties.details', 'type': 'AlertPropertiesDetails'}, + 'cost_entity_id': {'key': 'properties.costEntityId', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'creation_time': {'key': 'properties.creationTime', 'type': 'str'}, + 'close_time': {'key': 'properties.closeTime', 'type': 'str'}, + 'modification_time': {'key': 'properties.modificationTime', 'type': 'str'}, + 'status_modification_user_name': {'key': 'properties.statusModificationUserName', 'type': 'str'}, + 'status_modification_time': {'key': 'properties.statusModificationTime', 'type': 'str'}, } def __init__(self, **kwargs): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.tags = None + super(Alert, self).__init__(**kwargs) + self.definition = kwargs.get('definition', None) + self.description = kwargs.get('description', None) + self.source = kwargs.get('source', None) + self.details = kwargs.get('details', None) + self.cost_entity_id = kwargs.get('cost_entity_id', None) + self.status = kwargs.get('status', None) + self.creation_time = kwargs.get('creation_time', None) + self.close_time = kwargs.get('close_time', None) + self.modification_time = kwargs.get('modification_time', None) + self.status_modification_user_name = kwargs.get('status_modification_user_name', None) + self.status_modification_time = kwargs.get('status_modification_time', None) + + +class AlertPropertiesDefinition(Model): + """defines the type of alert. + + :param type: type of alert. Possible values include: 'Budget', 'Invoice', + 'Credit', 'Quota', 'General', 'xCloud', 'BudgetForecast' + :type type: str or ~azure.mgmt.costmanagement.models.AlertType + :param category: Alert category. Possible values include: 'Cost', 'Usage', + 'Billing', 'System' + :type category: str or ~azure.mgmt.costmanagement.models.AlertCategory + :param criteria: Criteria that triggered alert. Possible values include: + 'CostThresholdExceeded', 'UsageThresholdExceeded', + 'CreditThresholdApproaching', 'CreditThresholdReached', + 'QuotaThresholdApproaching', 'QuotaThresholdReached', 'MultiCurrency', + 'ForecastCostThresholdExceeded', 'ForecastUsageThresholdExceeded', + 'InvoiceDueDateApproaching', 'InvoiceDueDateReached', + 'CrossCloudNewDataAvailable', 'CrossCloudCollectionError', + 'GeneralThresholdError' + :type criteria: str or ~azure.mgmt.costmanagement.models.AlertCriteria + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'category': {'key': 'category', 'type': 'str'}, + 'criteria': {'key': 'criteria', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(AlertPropertiesDefinition, self).__init__(**kwargs) + self.type = kwargs.get('type', None) + self.category = kwargs.get('category', None) + self.criteria = kwargs.get('criteria', None) + + +class AlertPropertiesDetails(Model): + """Alert details. + + :param time_grain_type: Type of timegrain cadence. Possible values + include: 'None', 'Monthly', 'Quarterly', 'Annually', 'BillingMonth', + 'BillingQuarter', 'BillingAnnual' + :type time_grain_type: str or + ~azure.mgmt.costmanagement.models.AlertTimeGrainType + :param period_start_date: datetime of periodStartDate + :type period_start_date: str + :param triggered_by: notificationId that triggered this alert + :type triggered_by: str + :param resource_group_filter: array of resourceGroups to filter by + :type resource_group_filter: list[object] + :param resource_filter: array of resources to filter by + :type resource_filter: list[object] + :param meter_filter: array of meters to filter by + :type meter_filter: list[object] + :param tag_filter: tags to filter by + :type tag_filter: object + :param threshold: notification threshold percentage as a decimal which + activated this alert + :type threshold: decimal.Decimal + :param operator: operator used to compare currentSpend with amount. + Possible values include: 'None', 'EqualTo', 'GreaterThan', + 'GreaterThanOrEqualTo', 'LessThan', 'LessThanOrEqualTo' + :type operator: str or ~azure.mgmt.costmanagement.models.AlertOperator + :param amount: budget threshold amount + :type amount: decimal.Decimal + :param unit: unit of currency being used + :type unit: str + :param current_spend: current spend + :type current_spend: decimal.Decimal + :param contact_emails: list of emails to contact + :type contact_emails: list[str] + :param contact_groups: list of action groups to broadcast to + :type contact_groups: list[str] + :param contact_roles: list of contact roles + :type contact_roles: list[str] + :param overriding_alert: overriding alert + :type overriding_alert: str + """ + + _attribute_map = { + 'time_grain_type': {'key': 'timeGrainType', 'type': 'str'}, + 'period_start_date': {'key': 'periodStartDate', 'type': 'str'}, + 'triggered_by': {'key': 'triggeredBy', 'type': 'str'}, + 'resource_group_filter': {'key': 'resourceGroupFilter', 'type': '[object]'}, + 'resource_filter': {'key': 'resourceFilter', 'type': '[object]'}, + 'meter_filter': {'key': 'meterFilter', 'type': '[object]'}, + 'tag_filter': {'key': 'tagFilter', 'type': 'object'}, + 'threshold': {'key': 'threshold', 'type': 'decimal'}, + 'operator': {'key': 'operator', 'type': 'str'}, + 'amount': {'key': 'amount', 'type': 'decimal'}, + 'unit': {'key': 'unit', 'type': 'str'}, + 'current_spend': {'key': 'currentSpend', 'type': 'decimal'}, + 'contact_emails': {'key': 'contactEmails', 'type': '[str]'}, + 'contact_groups': {'key': 'contactGroups', 'type': '[str]'}, + 'contact_roles': {'key': 'contactRoles', 'type': '[str]'}, + 'overriding_alert': {'key': 'overridingAlert', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(AlertPropertiesDetails, self).__init__(**kwargs) + self.time_grain_type = kwargs.get('time_grain_type', None) + self.period_start_date = kwargs.get('period_start_date', None) + self.triggered_by = kwargs.get('triggered_by', None) + self.resource_group_filter = kwargs.get('resource_group_filter', None) + self.resource_filter = kwargs.get('resource_filter', None) + self.meter_filter = kwargs.get('meter_filter', None) + self.tag_filter = kwargs.get('tag_filter', None) + self.threshold = kwargs.get('threshold', None) + self.operator = kwargs.get('operator', None) + self.amount = kwargs.get('amount', None) + self.unit = kwargs.get('unit', None) + self.current_spend = kwargs.get('current_spend', None) + self.contact_emails = kwargs.get('contact_emails', None) + self.contact_groups = kwargs.get('contact_groups', None) + self.contact_roles = kwargs.get('contact_roles', None) + self.overriding_alert = kwargs.get('overriding_alert', None) + + +class AlertsResult(Model): + """Result of alerts. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar value: List of alerts. + :vartype value: list[~azure.mgmt.costmanagement.models.Alert] + :ivar next_link: URL to get the next set of alerts results if there are + any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Alert]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(AlertsResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class CloudError(Model): + """CloudError. + """ + + _attribute_map = { + } + + +class CommonExportProperties(Model): + """The common properties of the export. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param format: The format of the export being delivered. Currently only + 'Csv' is supported. Possible values include: 'Csv' + :type format: str or ~azure.mgmt.costmanagement.models.FormatType + :param delivery_info: Required. Has delivery information for the export. + :type delivery_info: ~azure.mgmt.costmanagement.models.ExportDeliveryInfo + :param definition: Required. Has the definition for the export. + :type definition: ~azure.mgmt.costmanagement.models.ExportDefinition + :param run_history: If requested, has the most recent execution history + for the export. + :type run_history: + ~azure.mgmt.costmanagement.models.ExportExecutionListResult + :ivar next_run_time_estimate: If the export has an active schedule, + provides an estimate of the next execution time. + :vartype next_run_time_estimate: datetime + """ + + _validation = { + 'delivery_info': {'required': True}, + 'definition': {'required': True}, + 'next_run_time_estimate': {'readonly': True}, + } + + _attribute_map = { + 'format': {'key': 'format', 'type': 'str'}, + 'delivery_info': {'key': 'deliveryInfo', 'type': 'ExportDeliveryInfo'}, + 'definition': {'key': 'definition', 'type': 'ExportDefinition'}, + 'run_history': {'key': 'runHistory', 'type': 'ExportExecutionListResult'}, + 'next_run_time_estimate': {'key': 'nextRunTimeEstimate', 'type': 'iso-8601'}, + } + + def __init__(self, **kwargs): + super(CommonExportProperties, self).__init__(**kwargs) + self.format = kwargs.get('format', None) + self.delivery_info = kwargs.get('delivery_info', None) + self.definition = kwargs.get('definition', None) + self.run_history = kwargs.get('run_history', None) + self.next_run_time_estimate = None class Dimension(Resource): @@ -169,6 +409,65 @@ def __init__(self, **kwargs): self.next_link = None +class DismissAlertPayload(Model): + """The request payload to update an alert. + + :param definition: defines the type of alert + :type definition: + ~azure.mgmt.costmanagement.models.AlertPropertiesDefinition + :param description: Alert description + :type description: str + :param source: Source of alert. Possible values include: 'Preset', 'User' + :type source: str or ~azure.mgmt.costmanagement.models.AlertSource + :param details: Alert details + :type details: ~azure.mgmt.costmanagement.models.AlertPropertiesDetails + :param cost_entity_id: related budget + :type cost_entity_id: str + :param status: alert status. Possible values include: 'None', 'Active', + 'Overridden', 'Resolved', 'Dismissed' + :type status: str or ~azure.mgmt.costmanagement.models.AlertStatus + :param creation_time: dateTime in which alert was created + :type creation_time: str + :param close_time: dateTime in which alert was closed + :type close_time: str + :param modification_time: dateTime in which alert was last modified + :type modification_time: str + :param status_modification_user_name: + :type status_modification_user_name: str + :param status_modification_time: dateTime in which the alert status was + last modified + :type status_modification_time: str + """ + + _attribute_map = { + 'definition': {'key': 'properties.definition', 'type': 'AlertPropertiesDefinition'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'source': {'key': 'properties.source', 'type': 'str'}, + 'details': {'key': 'properties.details', 'type': 'AlertPropertiesDetails'}, + 'cost_entity_id': {'key': 'properties.costEntityId', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'creation_time': {'key': 'properties.creationTime', 'type': 'str'}, + 'close_time': {'key': 'properties.closeTime', 'type': 'str'}, + 'modification_time': {'key': 'properties.modificationTime', 'type': 'str'}, + 'status_modification_user_name': {'key': 'properties.statusModificationUserName', 'type': 'str'}, + 'status_modification_time': {'key': 'properties.statusModificationTime', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(DismissAlertPayload, self).__init__(**kwargs) + self.definition = kwargs.get('definition', None) + self.description = kwargs.get('description', None) + self.source = kwargs.get('source', None) + self.details = kwargs.get('details', None) + self.cost_entity_id = kwargs.get('cost_entity_id', None) + self.status = kwargs.get('status', None) + self.creation_time = kwargs.get('creation_time', None) + self.close_time = kwargs.get('close_time', None) + self.modification_time = kwargs.get('modification_time', None) + self.status_modification_user_name = kwargs.get('status_modification_user_name', None) + self.status_modification_time = kwargs.get('status_modification_time', None) + + class ErrorDetails(Model): """The details of the error. @@ -200,6 +499,12 @@ def __init__(self, **kwargs): class ErrorResponse(Model): """Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message. + Some Error responses: + * 429 TooManyRequests - Request is throttled. Retry after waiting for the + time specified in the "x-ms-ratelimit-microsoft.consumption-retry-after" + header. + * 503 ServiceUnavailable - Service is temporarily unavailable. Retry after + waiting for the time specified in the "Retry-After" header. :param error: The details of the error. :type error: ~azure.mgmt.costmanagement.models.ErrorDetails @@ -226,8 +531,47 @@ def __init__(self, deserialize, response, *args): super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) -class Export(Resource): - """A export resource. +class ProxyResource(Model): + """The Resource model definition. + + 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 scenario, + this field will be used to determine whether the user is updating the + latest version or not. + :type e_tag: str + """ + + _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'}, + } + + def __init__(self, **kwargs): + super(ProxyResource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.e_tag = kwargs.get('e_tag', None) + + +class Export(ProxyResource): + """An export resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -240,15 +584,24 @@ class Export(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :param format: The format of the export being delivered. Possible values - include: 'Csv' + :param e_tag: eTag of the resource. To handle concurrent update scenario, + this field will be used to determine whether the user is updating the + latest version or not. + :type e_tag: str + :param format: The format of the export being delivered. Currently only + 'Csv' is supported. Possible values include: 'Csv' :type format: str or ~azure.mgmt.costmanagement.models.FormatType :param delivery_info: Required. Has delivery information for the export. :type delivery_info: ~azure.mgmt.costmanagement.models.ExportDeliveryInfo - :param definition: Required. Has definition for the export. - :type definition: ~azure.mgmt.costmanagement.models.QueryDefinition + :param definition: Required. Has the definition for the export. + :type definition: ~azure.mgmt.costmanagement.models.ExportDefinition + :param run_history: If requested, has the most recent execution history + for the export. + :type run_history: + ~azure.mgmt.costmanagement.models.ExportExecutionListResult + :ivar next_run_time_estimate: If the export has an active schedule, + provides an estimate of the next execution time. + :vartype next_run_time_estimate: datetime :param schedule: Has schedule information for the export. :type schedule: ~azure.mgmt.costmanagement.models.ExportSchedule """ @@ -257,19 +610,21 @@ class Export(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'tags': {'readonly': True}, 'delivery_info': {'required': True}, 'definition': {'required': True}, + 'next_run_time_estimate': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, 'format': {'key': 'properties.format', 'type': 'str'}, 'delivery_info': {'key': 'properties.deliveryInfo', 'type': 'ExportDeliveryInfo'}, - 'definition': {'key': 'properties.definition', 'type': 'QueryDefinition'}, + 'definition': {'key': 'properties.definition', 'type': 'ExportDefinition'}, + 'run_history': {'key': 'properties.runHistory', 'type': 'ExportExecutionListResult'}, + 'next_run_time_estimate': {'key': 'properties.nextRunTimeEstimate', 'type': 'iso-8601'}, 'schedule': {'key': 'properties.schedule', 'type': 'ExportSchedule'}, } @@ -278,9 +633,94 @@ def __init__(self, **kwargs): self.format = kwargs.get('format', None) self.delivery_info = kwargs.get('delivery_info', None) self.definition = kwargs.get('definition', None) + self.run_history = kwargs.get('run_history', None) + self.next_run_time_estimate = None self.schedule = kwargs.get('schedule', None) +class ExportDataset(Model): + """The definition for data in the export. + + :param granularity: The granularity of rows in the export. Currently only + 'Daily' is supported. Possible values include: 'Daily' + :type granularity: str or + ~azure.mgmt.costmanagement.models.GranularityType + :param configuration: The export dataset configuration. + :type configuration: + ~azure.mgmt.costmanagement.models.ExportDatasetConfiguration + """ + + _attribute_map = { + 'granularity': {'key': 'granularity', 'type': 'str'}, + 'configuration': {'key': 'configuration', 'type': 'ExportDatasetConfiguration'}, + } + + def __init__(self, **kwargs): + super(ExportDataset, self).__init__(**kwargs) + self.granularity = kwargs.get('granularity', None) + self.configuration = kwargs.get('configuration', None) + + +class ExportDatasetConfiguration(Model): + """The export dataset configuration. Allows columns to be selected for the + export. If not provided then the export will include all available columns. + + :param columns: Array of column names to be included in the export. If not + provided then the export will include all available columns. The available + columns can vary by customer channel (see examples). + :type columns: list[str] + """ + + _attribute_map = { + 'columns': {'key': 'columns', 'type': '[str]'}, + } + + def __init__(self, **kwargs): + super(ExportDatasetConfiguration, self).__init__(**kwargs) + self.columns = kwargs.get('columns', None) + + +class ExportDefinition(Model): + """The definition of an export. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. The type of the export. Note that 'Usage' is + equivalent to 'ActualCost' and is applicable to exports that do not yet + provide data for charges or amortization for service reservations. + Possible values include: 'Usage', 'ActualCost', 'AmortizedCost' + :type type: str or ~azure.mgmt.costmanagement.models.ExportType + :param timeframe: Required. The time frame for pulling data for the + export. If custom, then a specific time period must be provided. Possible + values include: 'MonthToDate', 'BillingMonthToDate', 'TheLastMonth', + 'TheLastBillingMonth', 'WeekToDate', 'Custom' + :type timeframe: str or ~azure.mgmt.costmanagement.models.TimeframeType + :param time_period: Has time period for pulling data for the export. + :type time_period: ~azure.mgmt.costmanagement.models.ExportTimePeriod + :param data_set: The definition for data in the export. + :type data_set: ~azure.mgmt.costmanagement.models.ExportDataset + """ + + _validation = { + 'type': {'required': True}, + 'timeframe': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'timeframe': {'key': 'timeframe', 'type': 'str'}, + 'time_period': {'key': 'timePeriod', 'type': 'ExportTimePeriod'}, + 'data_set': {'key': 'dataSet', 'type': 'ExportDataset'}, + } + + def __init__(self, **kwargs): + super(ExportDefinition, self).__init__(**kwargs) + self.type = kwargs.get('type', None) + self.timeframe = kwargs.get('timeframe', None) + self.time_period = kwargs.get('time_period', None) + self.data_set = kwargs.get('data_set', None) + + class ExportDeliveryDestination(Model): """The destination information for the delivery of the export. To allow access to a storage account, you must register the account's subscription with the @@ -346,8 +786,8 @@ def __init__(self, **kwargs): self.destination = kwargs.get('destination', None) -class ExportExecution(Resource): - """A export execution. +class ExportExecution(ProxyResource): + """An export execution. Variables are only populated by the server, and will be ignored when sending a request. @@ -358,46 +798,50 @@ class ExportExecution(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] + :param e_tag: eTag of the resource. To handle concurrent update scenario, + this field will be used to determine whether the user is updating the + latest version or not. + :type e_tag: str :param execution_type: The type of the export execution. Possible values include: 'OnDemand', 'Scheduled' :type execution_type: str or ~azure.mgmt.costmanagement.models.ExecutionType - :param status: The status of the export execution. Possible values - include: 'Queued', 'InProgress', 'Completed', 'Failed', 'Timeout', + :param status: The last known status of the export execution. Possible + values include: 'Queued', 'InProgress', 'Completed', 'Failed', 'Timeout', 'NewDataNotAvailable', 'DataNotAvailable' :type status: str or ~azure.mgmt.costmanagement.models.ExecutionStatus :param submitted_by: The identifier for the entity that executed the - export. For OnDemand executions, it is the email id. For Scheduled - executions, it is the constant value - System. + export. For OnDemand executions it is the user email. For scheduled + executions it is 'System'. :type submitted_by: str :param submitted_time: The time when export was queued to be executed. :type submitted_time: datetime :param processing_start_time: The time when export was picked up to be executed. :type processing_start_time: datetime - :param processing_end_time: The time when export execution finished. + :param processing_end_time: The time when the export execution finished. :type processing_end_time: datetime - :param file_name: The name of the file export got written to. + :param file_name: The name of the exported file. :type file_name: str - :param run_settings: + :param run_settings: The export settings that were in effect for this + execution. :type run_settings: ~azure.mgmt.costmanagement.models.CommonExportProperties + :param error: The details of any error. + :type error: ~azure.mgmt.costmanagement.models.ErrorDetails """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'tags': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, 'execution_type': {'key': 'properties.executionType', 'type': 'str'}, 'status': {'key': 'properties.status', 'type': 'str'}, 'submitted_by': {'key': 'properties.submittedBy', 'type': 'str'}, @@ -406,6 +850,7 @@ class ExportExecution(Resource): 'processing_end_time': {'key': 'properties.processingEndTime', 'type': 'iso-8601'}, 'file_name': {'key': 'properties.fileName', 'type': 'str'}, 'run_settings': {'key': 'properties.runSettings', 'type': 'CommonExportProperties'}, + 'error': {'key': 'properties.error', 'type': 'ErrorDetails'}, } def __init__(self, **kwargs): @@ -418,15 +863,16 @@ def __init__(self, **kwargs): self.processing_end_time = kwargs.get('processing_end_time', None) self.file_name = kwargs.get('file_name', None) self.run_settings = kwargs.get('run_settings', None) + self.error = kwargs.get('error', None) class ExportExecutionListResult(Model): - """Result of listing exports execution history of a export by name. + """Result of listing the execution history of an export. Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: The list of export executions. + :ivar value: A list of export executions. :vartype value: list[~azure.mgmt.costmanagement.models.ExportExecution] """ @@ -494,16 +940,13 @@ def __init__(self, **kwargs): class ExportSchedule(Model): - """The schedule associated with a export. - - All required parameters must be populated in order to send to Azure. + """The schedule associated with the export. - :param status: The status of the schedule. Whether active or not. If - inactive, the export's scheduled execution is paused. Possible values - include: 'Active', 'Inactive' + :param status: The status of the export's schedule. If 'Inactive', the + export's schedule is paused. Possible values include: 'Active', 'Inactive' :type status: str or ~azure.mgmt.costmanagement.models.StatusType - :param recurrence: Required. The schedule recurrence. Possible values - include: 'Daily', 'Weekly', 'Monthly', 'Annually' + :param recurrence: The schedule recurrence. Possible values include: + 'Daily', 'Weekly', 'Monthly', 'Annually' :type recurrence: str or ~azure.mgmt.costmanagement.models.RecurrenceType :param recurrence_period: Has start and end date of the recurrence. The start date must be in future. If present, the end date must be greater @@ -512,10 +955,6 @@ class ExportSchedule(Model): ~azure.mgmt.costmanagement.models.ExportRecurrencePeriod """ - _validation = { - 'recurrence': {'required': True}, - } - _attribute_map = { 'status': {'key': 'status', 'type': 'str'}, 'recurrence': {'key': 'recurrence', 'type': 'str'}, @@ -529,25 +968,164 @@ def __init__(self, **kwargs): self.recurrence_period = kwargs.get('recurrence_period', None) -class Operation(Model): - """A Cost management REST API operation. +class ExportTimePeriod(Model): + """The date range for data in the export. This should only be specified with + timeFrame set to 'Custom'. The maximum date range is 3 months. - Variables are only populated by the server, and will be ignored when - sending a request. + All required parameters must be populated in order to send to Azure. - :ivar name: Operation name: {provider}/{resource}/{operation}. - :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.costmanagement.models.OperationDisplay + :param from_property: Required. The start date for export data. + :type from_property: datetime + :param to: Required. The end date for export data. + :type to: datetime """ _validation = { - 'name': {'readonly': True}, + 'from_property': {'required': True}, + 'to': {'required': True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'from_property': {'key': 'from', 'type': 'iso-8601'}, + 'to': {'key': 'to', 'type': 'iso-8601'}, + } + + def __init__(self, **kwargs): + super(ExportTimePeriod, self).__init__(**kwargs) + self.from_property = kwargs.get('from_property', None) + self.to = kwargs.get('to', None) + + +class ForecastDataset(Model): + """The definition of data present in the forecast. + + :param granularity: The granularity of rows in the forecast. Possible + values include: 'Daily' + :type granularity: str or + ~azure.mgmt.costmanagement.models.GranularityType + :param configuration: Has configuration information for the data in the + export. The configuration will be ignored if aggregation and grouping are + provided. + :type configuration: + ~azure.mgmt.costmanagement.models.QueryDatasetConfiguration + :param aggregation: Dictionary of aggregation expression to use in the + forecast. The key of each item in the dictionary is the alias for the + aggregated column. forecast can have up to 2 aggregation clauses. + :type aggregation: dict[str, + ~azure.mgmt.costmanagement.models.QueryAggregation] + :param filter: Has filter expression to use in the forecast. + :type filter: ~azure.mgmt.costmanagement.models.QueryFilter + """ + + _attribute_map = { + 'granularity': {'key': 'granularity', 'type': 'str'}, + 'configuration': {'key': 'configuration', 'type': 'QueryDatasetConfiguration'}, + 'aggregation': {'key': 'aggregation', 'type': '{QueryAggregation}'}, + 'filter': {'key': 'filter', 'type': 'QueryFilter'}, + } + + def __init__(self, **kwargs): + super(ForecastDataset, self).__init__(**kwargs) + self.granularity = kwargs.get('granularity', None) + self.configuration = kwargs.get('configuration', None) + self.aggregation = kwargs.get('aggregation', None) + self.filter = kwargs.get('filter', None) + + +class ForecastDefinition(Model): + """The definition of a forecast. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. The type of the forecast. Possible values include: + 'Usage', 'ActualCost', 'AmortizedCost' + :type type: str or ~azure.mgmt.costmanagement.models.ForecastType + :param timeframe: Required. The time frame for pulling data for the + forecast. If custom, then a specific time period must be provided. + Possible values include: 'MonthToDate', 'BillingMonthToDate', + 'TheLastMonth', 'TheLastBillingMonth', 'WeekToDate', 'Custom' + :type timeframe: str or + ~azure.mgmt.costmanagement.models.ForecastTimeframeType + :param time_period: Has time period for pulling data for the forecast. + :type time_period: ~azure.mgmt.costmanagement.models.QueryTimePeriod + :param dataset: Has definition for data in this forecast. + :type dataset: ~azure.mgmt.costmanagement.models.ForecastDataset + :param include_actual_cost: a boolean determining if actualCost will be + included + :type include_actual_cost: bool + :param include_fresh_partial_cost: a boolean determining if + FreshPartialCost will be included + :type include_fresh_partial_cost: bool + """ + + _validation = { + 'type': {'required': True}, + 'timeframe': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'timeframe': {'key': 'timeframe', 'type': 'str'}, + 'time_period': {'key': 'timePeriod', 'type': 'QueryTimePeriod'}, + 'dataset': {'key': 'dataset', 'type': 'ForecastDataset'}, + 'include_actual_cost': {'key': 'includeActualCost', 'type': 'bool'}, + 'include_fresh_partial_cost': {'key': 'includeFreshPartialCost', 'type': 'bool'}, + } + + def __init__(self, **kwargs): + super(ForecastDefinition, self).__init__(**kwargs) + self.type = kwargs.get('type', None) + self.timeframe = kwargs.get('timeframe', None) + self.time_period = kwargs.get('time_period', None) + self.dataset = kwargs.get('dataset', None) + self.include_actual_cost = kwargs.get('include_actual_cost', None) + self.include_fresh_partial_cost = kwargs.get('include_fresh_partial_cost', None) + + +class KpiProperties(Model): + """Each KPI must contain a 'type' and 'enabled' key. + + :param type: KPI type (Forecast, Budget). Possible values include: + 'Forecast', 'Budget' + :type type: str or ~azure.mgmt.costmanagement.models.KpiTypeType + :param id: ID of resource related to metric (budget). + :type id: str + :param enabled: show the KPI in the UI? + :type enabled: bool + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'enabled': {'key': 'enabled', 'type': 'bool'}, + } + + def __init__(self, **kwargs): + super(KpiProperties, self).__init__(**kwargs) + self.type = kwargs.get('type', None) + self.id = kwargs.get('id', None) + self.enabled = kwargs.get('enabled', None) + + +class Operation(Model): + """A Cost management REST API operation. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :param display: The object that represents the operation. + :type display: ~azure.mgmt.costmanagement.models.OperationDisplay + """ + + _validation = { + 'name': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, } def __init__(self, **kwargs): @@ -590,6 +1168,27 @@ def __init__(self, **kwargs): self.operation = None +class PivotProperties(Model): + """Each pivot must contain a 'type' and 'name'. + + :param type: Data type to show in view. Possible values include: + 'Dimension', 'TagKey' + :type type: str or ~azure.mgmt.costmanagement.models.PivotTypeType + :param name: Data field to show in view. + :type name: str + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(PivotProperties, self).__init__(**kwargs) + self.type = kwargs.get('type', None) + self.name = kwargs.get('name', None) + + class QueryAggregation(Model): """The aggregation expression to be used in the query. @@ -921,3 +1520,388 @@ def __init__(self, **kwargs): super(QueryTimePeriod, self).__init__(**kwargs) self.from_property = kwargs.get('from_property', None) self.to = kwargs.get('to', None) + + +class ReportConfigAggregation(Model): + """The aggregation expression to be used in the report. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. The name of the column to aggregate. + :type name: str + :ivar function: Required. The name of the aggregation function to use. + Default value: "Sum" . + :vartype function: str + """ + + _validation = { + 'name': {'required': True}, + 'function': {'required': True, 'constant': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'function': {'key': 'function', 'type': 'str'}, + } + + function = "Sum" + + def __init__(self, **kwargs): + super(ReportConfigAggregation, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + + +class ReportConfigComparisonExpression(Model): + """The comparison expression to be used in the report. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. The name of the column to use in comparison. + :type name: str + :param operator: Required. The operator to use for comparison. Possible + values include: 'In', 'Contains' + :type operator: str or ~azure.mgmt.costmanagement.models.OperatorType + :param values: Required. Array of values to use for comparison + :type values: list[str] + """ + + _validation = { + 'name': {'required': True}, + 'operator': {'required': True}, + 'values': {'required': True, 'min_items': 1}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'operator': {'key': 'operator', 'type': 'str'}, + 'values': {'key': 'values', 'type': '[str]'}, + } + + def __init__(self, **kwargs): + super(ReportConfigComparisonExpression, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.operator = kwargs.get('operator', None) + self.values = kwargs.get('values', None) + + +class ReportConfigDataset(Model): + """The definition of data present in the report. + + :param granularity: The granularity of rows in the report. Possible values + include: 'Daily', 'Monthly' + :type granularity: str or + ~azure.mgmt.costmanagement.models.ReportGranularityType + :param configuration: Has configuration information for the data in the + report. The configuration will be ignored if aggregation and grouping are + provided. + :type configuration: + ~azure.mgmt.costmanagement.models.ReportConfigDatasetConfiguration + :param aggregation: Dictionary of aggregation expression to use in the + report. The key of each item in the dictionary is the alias for the + aggregated column. Report can have up to 2 aggregation clauses. + :type aggregation: dict[str, + ~azure.mgmt.costmanagement.models.ReportConfigAggregation] + :param grouping: Array of group by expression to use in the report. Report + can have up to 2 group by clauses. + :type grouping: + list[~azure.mgmt.costmanagement.models.ReportConfigGrouping] + :param sorting: Array of order by expression to use in the report. + :type sorting: list[~azure.mgmt.costmanagement.models.ReportConfigSorting] + :param filter: Has filter expression to use in the report. + :type filter: ~azure.mgmt.costmanagement.models.ReportConfigFilter + """ + + _validation = { + 'grouping': {'max_items': 2}, + } + + _attribute_map = { + 'granularity': {'key': 'granularity', 'type': 'str'}, + 'configuration': {'key': 'configuration', 'type': 'ReportConfigDatasetConfiguration'}, + 'aggregation': {'key': 'aggregation', 'type': '{ReportConfigAggregation}'}, + 'grouping': {'key': 'grouping', 'type': '[ReportConfigGrouping]'}, + 'sorting': {'key': 'sorting', 'type': '[ReportConfigSorting]'}, + 'filter': {'key': 'filter', 'type': 'ReportConfigFilter'}, + } + + def __init__(self, **kwargs): + super(ReportConfigDataset, self).__init__(**kwargs) + self.granularity = kwargs.get('granularity', None) + self.configuration = kwargs.get('configuration', None) + self.aggregation = kwargs.get('aggregation', None) + self.grouping = kwargs.get('grouping', None) + self.sorting = kwargs.get('sorting', None) + self.filter = kwargs.get('filter', None) + + +class ReportConfigDatasetConfiguration(Model): + """The configuration of dataset in the report. + + :param columns: Array of column names to be included in the report. Any + valid report column name is allowed. If not provided, then report includes + all columns. + :type columns: list[str] + """ + + _attribute_map = { + 'columns': {'key': 'columns', 'type': '[str]'}, + } + + def __init__(self, **kwargs): + super(ReportConfigDatasetConfiguration, self).__init__(**kwargs) + self.columns = kwargs.get('columns', None) + + +class ReportConfigFilter(Model): + """The filter expression to be used in the report. + + :param and_property: The logical "AND" expression. Must have at least 2 + items. + :type and_property: + list[~azure.mgmt.costmanagement.models.ReportConfigFilter] + :param or_property: The logical "OR" expression. Must have at least 2 + items. + :type or_property: + list[~azure.mgmt.costmanagement.models.ReportConfigFilter] + :param not_property: The logical "NOT" expression. + :type not_property: ~azure.mgmt.costmanagement.models.ReportConfigFilter + :param dimension: Has comparison expression for a dimension + :type dimension: + ~azure.mgmt.costmanagement.models.ReportConfigComparisonExpression + :param tag: Has comparison expression for a tag + :type tag: + ~azure.mgmt.costmanagement.models.ReportConfigComparisonExpression + """ + + _validation = { + 'and_property': {'min_items': 2}, + 'or_property': {'min_items': 2}, + } + + _attribute_map = { + 'and_property': {'key': 'and', 'type': '[ReportConfigFilter]'}, + 'or_property': {'key': 'or', 'type': '[ReportConfigFilter]'}, + 'not_property': {'key': 'not', 'type': 'ReportConfigFilter'}, + 'dimension': {'key': 'dimension', 'type': 'ReportConfigComparisonExpression'}, + 'tag': {'key': 'tag', 'type': 'ReportConfigComparisonExpression'}, + } + + def __init__(self, **kwargs): + super(ReportConfigFilter, self).__init__(**kwargs) + self.and_property = kwargs.get('and_property', None) + self.or_property = kwargs.get('or_property', None) + self.not_property = kwargs.get('not_property', None) + self.dimension = kwargs.get('dimension', None) + self.tag = kwargs.get('tag', None) + + +class ReportConfigGrouping(Model): + """The group by expression to be used in the report. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. Has type of the column to group. Possible values + include: 'Tag', 'Dimension' + :type type: str or + ~azure.mgmt.costmanagement.models.ReportConfigColumnType + :param name: Required. The name of the column to group. This version + supports subscription lowest possible grain. + :type name: str + """ + + _validation = { + 'type': {'required': True}, + 'name': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ReportConfigGrouping, self).__init__(**kwargs) + self.type = kwargs.get('type', None) + self.name = kwargs.get('name', None) + + +class ReportConfigSorting(Model): + """The order by expression to be used in the report. + + All required parameters must be populated in order to send to Azure. + + :param direction: Direction of sort. Possible values include: 'Ascending', + 'Descending' + :type direction: str or ~azure.mgmt.costmanagement.models.enum + :param name: Required. The name of the column to sort. + :type name: str + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'direction': {'key': 'direction', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ReportConfigSorting, self).__init__(**kwargs) + self.direction = kwargs.get('direction', None) + self.name = kwargs.get('name', None) + + +class ReportConfigTimePeriod(Model): + """The start and end date for pulling data for the report. + + All required parameters must be populated in order to send to Azure. + + :param from_property: Required. The start date to pull data from. + :type from_property: datetime + :param to: Required. The end date to pull data to. + :type to: datetime + """ + + _validation = { + 'from_property': {'required': True}, + 'to': {'required': True}, + } + + _attribute_map = { + 'from_property': {'key': 'from', 'type': 'iso-8601'}, + 'to': {'key': 'to', 'type': 'iso-8601'}, + } + + def __init__(self, **kwargs): + super(ReportConfigTimePeriod, self).__init__(**kwargs) + self.from_property = kwargs.get('from_property', None) + self.to = kwargs.get('to', None) + + +class View(ProxyResource): + """States and configurations of Cost Analysis. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :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 scenario, + this field will be used to determine whether the user is updating the + latest version or not. + :type e_tag: str + :param display_name: User input name of the view. Required. + :type display_name: str + :param scope: Cost Management scope to save the view on. This includes + 'subscriptions/{subscriptionId}' for subscription scope, + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + resourceGroup scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + Billing Account scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + for Department scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + for EnrollmentAccount scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + for BillingProfile scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + for InvoiceSection scope, + 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for + Management Group scope, + '/providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + for ExternalBillingAccount scope, and + '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + for ExternalSubscription scope. + :type scope: str + :ivar created_on: Date the user created this view. + :vartype created_on: datetime + :ivar modified_on: Date when the user last modified this view. + :vartype modified_on: datetime + :ivar view_type: Required. The type of the report. Usage represents actual + usage, forecast represents forecasted data and UsageAndForecast represents + both usage and forecasted data. Actual usage and forecasted data can be + differentiated based on dates. Default value: "Usage" . + :vartype view_type: str + :param timeframe: Required. The time frame for pulling data for the + report. If custom, then a specific time period must be provided. Possible + values include: 'WeekToDate', 'MonthToDate', 'YearToDate', 'Custom' + :type timeframe: str or + ~azure.mgmt.costmanagement.models.ReportTimeframeType + :param time_period: Has time period for pulling data for the report. + :type time_period: + ~azure.mgmt.costmanagement.models.ReportConfigTimePeriod + :param dataset: Has definition for data in this report config. + :type dataset: ~azure.mgmt.costmanagement.models.ReportConfigDataset + :param chart: Chart type of the main view in Cost Analysis. Required. + Possible values include: 'Area', 'Line', 'StackedColumn', 'GroupedColumn', + 'Table' + :type chart: str or ~azure.mgmt.costmanagement.models.ChartType + :param accumulated: Show costs accumulated over time. Possible values + include: 'true', 'false' + :type accumulated: str or + ~azure.mgmt.costmanagement.models.AccumulatedType + :param metric: Metric to use when displaying costs. Possible values + include: 'ActualCost', 'AmortizedCost', 'AHUB' + :type metric: str or ~azure.mgmt.costmanagement.models.MetricType + :param kpis: List of KPIs to show in Cost Analysis UI. + :type kpis: list[~azure.mgmt.costmanagement.models.KpiProperties] + :param pivots: Configuration of 3 sub-views in the Cost Analysis UI. + :type pivots: list[~azure.mgmt.costmanagement.models.PivotProperties] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'created_on': {'readonly': True}, + 'modified_on': {'readonly': True}, + 'view_type': {'required': True, 'constant': True}, + 'timeframe': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'str'}, + 'created_on': {'key': 'properties.createdOn', 'type': 'iso-8601'}, + 'modified_on': {'key': 'properties.modifiedOn', 'type': 'iso-8601'}, + 'view_type': {'key': 'properties.query.type', 'type': 'str'}, + 'timeframe': {'key': 'properties.query.timeframe', 'type': 'str'}, + 'time_period': {'key': 'properties.query.timePeriod', 'type': 'ReportConfigTimePeriod'}, + 'dataset': {'key': 'properties.query.dataset', 'type': 'ReportConfigDataset'}, + 'chart': {'key': 'properties.chart', 'type': 'str'}, + 'accumulated': {'key': 'properties.accumulated', 'type': 'str'}, + 'metric': {'key': 'properties.metric', 'type': 'str'}, + 'kpis': {'key': 'properties.kpis', 'type': '[KpiProperties]'}, + 'pivots': {'key': 'properties.pivots', 'type': '[PivotProperties]'}, + } + + view_type = "Usage" + + def __init__(self, **kwargs): + super(View, self).__init__(**kwargs) + self.display_name = kwargs.get('display_name', None) + self.scope = kwargs.get('scope', None) + self.created_on = None + self.modified_on = None + self.timeframe = kwargs.get('timeframe', None) + self.time_period = kwargs.get('time_period', None) + self.dataset = kwargs.get('dataset', None) + self.chart = kwargs.get('chart', None) + self.accumulated = kwargs.get('accumulated', None) + self.metric = kwargs.get('metric', None) + self.kpis = kwargs.get('kpis', None) + self.pivots = kwargs.get('pivots', None) diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_models_py3.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_models_py3.py index 01cef7145aece..ce339dc1bc97b 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_models_py3.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_models_py3.py @@ -13,48 +13,46 @@ from msrest.exceptions import HttpOperationError -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } - - -class CommonExportProperties(Model): - """The common properties of the export. +class Resource(Model): + """The Resource model definition. - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when + sending a request. - :param format: The format of the export being delivered. Possible values - include: 'Csv' - :type format: str or ~azure.mgmt.costmanagement.models.FormatType - :param delivery_info: Required. Has delivery information for the export. - :type delivery_info: ~azure.mgmt.costmanagement.models.ExportDeliveryInfo - :param definition: Required. Has definition for the export. - :type definition: ~azure.mgmt.costmanagement.models.QueryDefinition + :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] """ _validation = { - 'delivery_info': {'required': True}, - 'definition': {'required': True}, + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'tags': {'readonly': True}, } _attribute_map = { - 'format': {'key': 'format', 'type': 'str'}, - 'delivery_info': {'key': 'deliveryInfo', 'type': 'ExportDeliveryInfo'}, - 'definition': {'key': 'definition', 'type': 'QueryDefinition'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, delivery_info, definition, format=None, **kwargs) -> None: - super(CommonExportProperties, self).__init__(**kwargs) - self.format = format - self.delivery_info = delivery_info - self.definition = definition + def __init__(self, **kwargs) -> None: + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.tags = None -class Resource(Model): - """The Resource model definition. +class Alert(Resource): + """An individual alert. Variables are only populated by the server, and will be ignored when sending a request. @@ -67,6 +65,31 @@ class Resource(Model): :vartype type: str :ivar tags: Resource tags. :vartype tags: dict[str, str] + :param definition: defines the type of alert + :type definition: + ~azure.mgmt.costmanagement.models.AlertPropertiesDefinition + :param description: Alert description + :type description: str + :param source: Source of alert. Possible values include: 'Preset', 'User' + :type source: str or ~azure.mgmt.costmanagement.models.AlertSource + :param details: Alert details + :type details: ~azure.mgmt.costmanagement.models.AlertPropertiesDetails + :param cost_entity_id: related budget + :type cost_entity_id: str + :param status: alert status. Possible values include: 'None', 'Active', + 'Overridden', 'Resolved', 'Dismissed' + :type status: str or ~azure.mgmt.costmanagement.models.AlertStatus + :param creation_time: dateTime in which alert was created + :type creation_time: str + :param close_time: dateTime in which alert was closed + :type close_time: str + :param modification_time: dateTime in which alert was last modified + :type modification_time: str + :param status_modification_user_name: + :type status_modification_user_name: str + :param status_modification_time: dateTime in which the alert status was + last modified + :type status_modification_time: str """ _validation = { @@ -81,14 +104,231 @@ class Resource(Model): 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, + 'definition': {'key': 'properties.definition', 'type': 'AlertPropertiesDefinition'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'source': {'key': 'properties.source', 'type': 'str'}, + 'details': {'key': 'properties.details', 'type': 'AlertPropertiesDetails'}, + 'cost_entity_id': {'key': 'properties.costEntityId', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'creation_time': {'key': 'properties.creationTime', 'type': 'str'}, + 'close_time': {'key': 'properties.closeTime', 'type': 'str'}, + 'modification_time': {'key': 'properties.modificationTime', 'type': 'str'}, + 'status_modification_user_name': {'key': 'properties.statusModificationUserName', 'type': 'str'}, + 'status_modification_time': {'key': 'properties.statusModificationTime', 'type': 'str'}, + } + + def __init__(self, *, definition=None, description: str=None, source=None, details=None, cost_entity_id: str=None, status=None, creation_time: str=None, close_time: str=None, modification_time: str=None, status_modification_user_name: str=None, status_modification_time: str=None, **kwargs) -> None: + super(Alert, self).__init__(**kwargs) + self.definition = definition + self.description = description + self.source = source + self.details = details + self.cost_entity_id = cost_entity_id + self.status = status + self.creation_time = creation_time + self.close_time = close_time + self.modification_time = modification_time + self.status_modification_user_name = status_modification_user_name + self.status_modification_time = status_modification_time + + +class AlertPropertiesDefinition(Model): + """defines the type of alert. + + :param type: type of alert. Possible values include: 'Budget', 'Invoice', + 'Credit', 'Quota', 'General', 'xCloud', 'BudgetForecast' + :type type: str or ~azure.mgmt.costmanagement.models.AlertType + :param category: Alert category. Possible values include: 'Cost', 'Usage', + 'Billing', 'System' + :type category: str or ~azure.mgmt.costmanagement.models.AlertCategory + :param criteria: Criteria that triggered alert. Possible values include: + 'CostThresholdExceeded', 'UsageThresholdExceeded', + 'CreditThresholdApproaching', 'CreditThresholdReached', + 'QuotaThresholdApproaching', 'QuotaThresholdReached', 'MultiCurrency', + 'ForecastCostThresholdExceeded', 'ForecastUsageThresholdExceeded', + 'InvoiceDueDateApproaching', 'InvoiceDueDateReached', + 'CrossCloudNewDataAvailable', 'CrossCloudCollectionError', + 'GeneralThresholdError' + :type criteria: str or ~azure.mgmt.costmanagement.models.AlertCriteria + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'category': {'key': 'category', 'type': 'str'}, + 'criteria': {'key': 'criteria', 'type': 'str'}, + } + + def __init__(self, *, type=None, category=None, criteria=None, **kwargs) -> None: + super(AlertPropertiesDefinition, self).__init__(**kwargs) + self.type = type + self.category = category + self.criteria = criteria + + +class AlertPropertiesDetails(Model): + """Alert details. + + :param time_grain_type: Type of timegrain cadence. Possible values + include: 'None', 'Monthly', 'Quarterly', 'Annually', 'BillingMonth', + 'BillingQuarter', 'BillingAnnual' + :type time_grain_type: str or + ~azure.mgmt.costmanagement.models.AlertTimeGrainType + :param period_start_date: datetime of periodStartDate + :type period_start_date: str + :param triggered_by: notificationId that triggered this alert + :type triggered_by: str + :param resource_group_filter: array of resourceGroups to filter by + :type resource_group_filter: list[object] + :param resource_filter: array of resources to filter by + :type resource_filter: list[object] + :param meter_filter: array of meters to filter by + :type meter_filter: list[object] + :param tag_filter: tags to filter by + :type tag_filter: object + :param threshold: notification threshold percentage as a decimal which + activated this alert + :type threshold: decimal.Decimal + :param operator: operator used to compare currentSpend with amount. + Possible values include: 'None', 'EqualTo', 'GreaterThan', + 'GreaterThanOrEqualTo', 'LessThan', 'LessThanOrEqualTo' + :type operator: str or ~azure.mgmt.costmanagement.models.AlertOperator + :param amount: budget threshold amount + :type amount: decimal.Decimal + :param unit: unit of currency being used + :type unit: str + :param current_spend: current spend + :type current_spend: decimal.Decimal + :param contact_emails: list of emails to contact + :type contact_emails: list[str] + :param contact_groups: list of action groups to broadcast to + :type contact_groups: list[str] + :param contact_roles: list of contact roles + :type contact_roles: list[str] + :param overriding_alert: overriding alert + :type overriding_alert: str + """ + + _attribute_map = { + 'time_grain_type': {'key': 'timeGrainType', 'type': 'str'}, + 'period_start_date': {'key': 'periodStartDate', 'type': 'str'}, + 'triggered_by': {'key': 'triggeredBy', 'type': 'str'}, + 'resource_group_filter': {'key': 'resourceGroupFilter', 'type': '[object]'}, + 'resource_filter': {'key': 'resourceFilter', 'type': '[object]'}, + 'meter_filter': {'key': 'meterFilter', 'type': '[object]'}, + 'tag_filter': {'key': 'tagFilter', 'type': 'object'}, + 'threshold': {'key': 'threshold', 'type': 'decimal'}, + 'operator': {'key': 'operator', 'type': 'str'}, + 'amount': {'key': 'amount', 'type': 'decimal'}, + 'unit': {'key': 'unit', 'type': 'str'}, + 'current_spend': {'key': 'currentSpend', 'type': 'decimal'}, + 'contact_emails': {'key': 'contactEmails', 'type': '[str]'}, + 'contact_groups': {'key': 'contactGroups', 'type': '[str]'}, + 'contact_roles': {'key': 'contactRoles', 'type': '[str]'}, + 'overriding_alert': {'key': 'overridingAlert', 'type': 'str'}, + } + + def __init__(self, *, time_grain_type=None, period_start_date: str=None, triggered_by: str=None, resource_group_filter=None, resource_filter=None, meter_filter=None, tag_filter=None, threshold=None, operator=None, amount=None, unit: str=None, current_spend=None, contact_emails=None, contact_groups=None, contact_roles=None, overriding_alert: str=None, **kwargs) -> None: + super(AlertPropertiesDetails, self).__init__(**kwargs) + self.time_grain_type = time_grain_type + self.period_start_date = period_start_date + self.triggered_by = triggered_by + self.resource_group_filter = resource_group_filter + self.resource_filter = resource_filter + self.meter_filter = meter_filter + self.tag_filter = tag_filter + self.threshold = threshold + self.operator = operator + self.amount = amount + self.unit = unit + self.current_spend = current_spend + self.contact_emails = contact_emails + self.contact_groups = contact_groups + self.contact_roles = contact_roles + self.overriding_alert = overriding_alert + + +class AlertsResult(Model): + """Result of alerts. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar value: List of alerts. + :vartype value: list[~azure.mgmt.costmanagement.models.Alert] + :ivar next_link: URL to get the next set of alerts results if there are + any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Alert]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } def __init__(self, **kwargs) -> None: - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.tags = None + super(AlertsResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class CloudError(Model): + """CloudError. + """ + + _attribute_map = { + } + + +class CommonExportProperties(Model): + """The common properties of the export. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param format: The format of the export being delivered. Currently only + 'Csv' is supported. Possible values include: 'Csv' + :type format: str or ~azure.mgmt.costmanagement.models.FormatType + :param delivery_info: Required. Has delivery information for the export. + :type delivery_info: ~azure.mgmt.costmanagement.models.ExportDeliveryInfo + :param definition: Required. Has the definition for the export. + :type definition: ~azure.mgmt.costmanagement.models.ExportDefinition + :param run_history: If requested, has the most recent execution history + for the export. + :type run_history: + ~azure.mgmt.costmanagement.models.ExportExecutionListResult + :ivar next_run_time_estimate: If the export has an active schedule, + provides an estimate of the next execution time. + :vartype next_run_time_estimate: datetime + """ + + _validation = { + 'delivery_info': {'required': True}, + 'definition': {'required': True}, + 'next_run_time_estimate': {'readonly': True}, + } + + _attribute_map = { + 'format': {'key': 'format', 'type': 'str'}, + 'delivery_info': {'key': 'deliveryInfo', 'type': 'ExportDeliveryInfo'}, + 'definition': {'key': 'definition', 'type': 'ExportDefinition'}, + 'run_history': {'key': 'runHistory', 'type': 'ExportExecutionListResult'}, + 'next_run_time_estimate': {'key': 'nextRunTimeEstimate', 'type': 'iso-8601'}, + } + + def __init__(self, *, delivery_info, definition, format=None, run_history=None, **kwargs) -> None: + super(CommonExportProperties, self).__init__(**kwargs) + self.format = format + self.delivery_info = delivery_info + self.definition = definition + self.run_history = run_history + self.next_run_time_estimate = None class Dimension(Resource): @@ -169,6 +409,65 @@ def __init__(self, *, data=None, **kwargs) -> None: self.next_link = None +class DismissAlertPayload(Model): + """The request payload to update an alert. + + :param definition: defines the type of alert + :type definition: + ~azure.mgmt.costmanagement.models.AlertPropertiesDefinition + :param description: Alert description + :type description: str + :param source: Source of alert. Possible values include: 'Preset', 'User' + :type source: str or ~azure.mgmt.costmanagement.models.AlertSource + :param details: Alert details + :type details: ~azure.mgmt.costmanagement.models.AlertPropertiesDetails + :param cost_entity_id: related budget + :type cost_entity_id: str + :param status: alert status. Possible values include: 'None', 'Active', + 'Overridden', 'Resolved', 'Dismissed' + :type status: str or ~azure.mgmt.costmanagement.models.AlertStatus + :param creation_time: dateTime in which alert was created + :type creation_time: str + :param close_time: dateTime in which alert was closed + :type close_time: str + :param modification_time: dateTime in which alert was last modified + :type modification_time: str + :param status_modification_user_name: + :type status_modification_user_name: str + :param status_modification_time: dateTime in which the alert status was + last modified + :type status_modification_time: str + """ + + _attribute_map = { + 'definition': {'key': 'properties.definition', 'type': 'AlertPropertiesDefinition'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'source': {'key': 'properties.source', 'type': 'str'}, + 'details': {'key': 'properties.details', 'type': 'AlertPropertiesDetails'}, + 'cost_entity_id': {'key': 'properties.costEntityId', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'creation_time': {'key': 'properties.creationTime', 'type': 'str'}, + 'close_time': {'key': 'properties.closeTime', 'type': 'str'}, + 'modification_time': {'key': 'properties.modificationTime', 'type': 'str'}, + 'status_modification_user_name': {'key': 'properties.statusModificationUserName', 'type': 'str'}, + 'status_modification_time': {'key': 'properties.statusModificationTime', 'type': 'str'}, + } + + def __init__(self, *, definition=None, description: str=None, source=None, details=None, cost_entity_id: str=None, status=None, creation_time: str=None, close_time: str=None, modification_time: str=None, status_modification_user_name: str=None, status_modification_time: str=None, **kwargs) -> None: + super(DismissAlertPayload, self).__init__(**kwargs) + self.definition = definition + self.description = description + self.source = source + self.details = details + self.cost_entity_id = cost_entity_id + self.status = status + self.creation_time = creation_time + self.close_time = close_time + self.modification_time = modification_time + self.status_modification_user_name = status_modification_user_name + self.status_modification_time = status_modification_time + + class ErrorDetails(Model): """The details of the error. @@ -200,6 +499,12 @@ def __init__(self, **kwargs) -> None: class ErrorResponse(Model): """Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message. + Some Error responses: + * 429 TooManyRequests - Request is throttled. Retry after waiting for the + time specified in the "x-ms-ratelimit-microsoft.consumption-retry-after" + header. + * 503 ServiceUnavailable - Service is temporarily unavailable. Retry after + waiting for the time specified in the "Retry-After" header. :param error: The details of the error. :type error: ~azure.mgmt.costmanagement.models.ErrorDetails @@ -226,8 +531,47 @@ def __init__(self, deserialize, response, *args): super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) -class Export(Resource): - """A export resource. +class ProxyResource(Model): + """The Resource model definition. + + 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 scenario, + this field will be used to determine whether the user is updating the + latest version or not. + :type e_tag: str + """ + + _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'}, + } + + def __init__(self, *, e_tag: str=None, **kwargs) -> None: + super(ProxyResource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.e_tag = e_tag + + +class Export(ProxyResource): + """An export resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -240,15 +584,24 @@ class Export(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :param format: The format of the export being delivered. Possible values - include: 'Csv' + :param e_tag: eTag of the resource. To handle concurrent update scenario, + this field will be used to determine whether the user is updating the + latest version or not. + :type e_tag: str + :param format: The format of the export being delivered. Currently only + 'Csv' is supported. Possible values include: 'Csv' :type format: str or ~azure.mgmt.costmanagement.models.FormatType :param delivery_info: Required. Has delivery information for the export. :type delivery_info: ~azure.mgmt.costmanagement.models.ExportDeliveryInfo - :param definition: Required. Has definition for the export. - :type definition: ~azure.mgmt.costmanagement.models.QueryDefinition + :param definition: Required. Has the definition for the export. + :type definition: ~azure.mgmt.costmanagement.models.ExportDefinition + :param run_history: If requested, has the most recent execution history + for the export. + :type run_history: + ~azure.mgmt.costmanagement.models.ExportExecutionListResult + :ivar next_run_time_estimate: If the export has an active schedule, + provides an estimate of the next execution time. + :vartype next_run_time_estimate: datetime :param schedule: Has schedule information for the export. :type schedule: ~azure.mgmt.costmanagement.models.ExportSchedule """ @@ -257,30 +610,117 @@ class Export(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'tags': {'readonly': True}, 'delivery_info': {'required': True}, 'definition': {'required': True}, + 'next_run_time_estimate': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, 'format': {'key': 'properties.format', 'type': 'str'}, 'delivery_info': {'key': 'properties.deliveryInfo', 'type': 'ExportDeliveryInfo'}, - 'definition': {'key': 'properties.definition', 'type': 'QueryDefinition'}, + 'definition': {'key': 'properties.definition', 'type': 'ExportDefinition'}, + 'run_history': {'key': 'properties.runHistory', 'type': 'ExportExecutionListResult'}, + 'next_run_time_estimate': {'key': 'properties.nextRunTimeEstimate', 'type': 'iso-8601'}, 'schedule': {'key': 'properties.schedule', 'type': 'ExportSchedule'}, } - def __init__(self, *, delivery_info, definition, format=None, schedule=None, **kwargs) -> None: - super(Export, self).__init__(**kwargs) + def __init__(self, *, delivery_info, definition, e_tag: str=None, format=None, run_history=None, schedule=None, **kwargs) -> None: + super(Export, self).__init__(e_tag=e_tag, **kwargs) self.format = format self.delivery_info = delivery_info self.definition = definition + self.run_history = run_history + self.next_run_time_estimate = None self.schedule = schedule +class ExportDataset(Model): + """The definition for data in the export. + + :param granularity: The granularity of rows in the export. Currently only + 'Daily' is supported. Possible values include: 'Daily' + :type granularity: str or + ~azure.mgmt.costmanagement.models.GranularityType + :param configuration: The export dataset configuration. + :type configuration: + ~azure.mgmt.costmanagement.models.ExportDatasetConfiguration + """ + + _attribute_map = { + 'granularity': {'key': 'granularity', 'type': 'str'}, + 'configuration': {'key': 'configuration', 'type': 'ExportDatasetConfiguration'}, + } + + def __init__(self, *, granularity=None, configuration=None, **kwargs) -> None: + super(ExportDataset, self).__init__(**kwargs) + self.granularity = granularity + self.configuration = configuration + + +class ExportDatasetConfiguration(Model): + """The export dataset configuration. Allows columns to be selected for the + export. If not provided then the export will include all available columns. + + :param columns: Array of column names to be included in the export. If not + provided then the export will include all available columns. The available + columns can vary by customer channel (see examples). + :type columns: list[str] + """ + + _attribute_map = { + 'columns': {'key': 'columns', 'type': '[str]'}, + } + + def __init__(self, *, columns=None, **kwargs) -> None: + super(ExportDatasetConfiguration, self).__init__(**kwargs) + self.columns = columns + + +class ExportDefinition(Model): + """The definition of an export. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. The type of the export. Note that 'Usage' is + equivalent to 'ActualCost' and is applicable to exports that do not yet + provide data for charges or amortization for service reservations. + Possible values include: 'Usage', 'ActualCost', 'AmortizedCost' + :type type: str or ~azure.mgmt.costmanagement.models.ExportType + :param timeframe: Required. The time frame for pulling data for the + export. If custom, then a specific time period must be provided. Possible + values include: 'MonthToDate', 'BillingMonthToDate', 'TheLastMonth', + 'TheLastBillingMonth', 'WeekToDate', 'Custom' + :type timeframe: str or ~azure.mgmt.costmanagement.models.TimeframeType + :param time_period: Has time period for pulling data for the export. + :type time_period: ~azure.mgmt.costmanagement.models.ExportTimePeriod + :param data_set: The definition for data in the export. + :type data_set: ~azure.mgmt.costmanagement.models.ExportDataset + """ + + _validation = { + 'type': {'required': True}, + 'timeframe': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'timeframe': {'key': 'timeframe', 'type': 'str'}, + 'time_period': {'key': 'timePeriod', 'type': 'ExportTimePeriod'}, + 'data_set': {'key': 'dataSet', 'type': 'ExportDataset'}, + } + + def __init__(self, *, type, timeframe, time_period=None, data_set=None, **kwargs) -> None: + super(ExportDefinition, self).__init__(**kwargs) + self.type = type + self.timeframe = timeframe + self.time_period = time_period + self.data_set = data_set + + class ExportDeliveryDestination(Model): """The destination information for the delivery of the export. To allow access to a storage account, you must register the account's subscription with the @@ -346,8 +786,8 @@ def __init__(self, *, destination, **kwargs) -> None: self.destination = destination -class ExportExecution(Resource): - """A export execution. +class ExportExecution(ProxyResource): + """An export execution. Variables are only populated by the server, and will be ignored when sending a request. @@ -358,46 +798,50 @@ class ExportExecution(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] + :param e_tag: eTag of the resource. To handle concurrent update scenario, + this field will be used to determine whether the user is updating the + latest version or not. + :type e_tag: str :param execution_type: The type of the export execution. Possible values include: 'OnDemand', 'Scheduled' :type execution_type: str or ~azure.mgmt.costmanagement.models.ExecutionType - :param status: The status of the export execution. Possible values - include: 'Queued', 'InProgress', 'Completed', 'Failed', 'Timeout', + :param status: The last known status of the export execution. Possible + values include: 'Queued', 'InProgress', 'Completed', 'Failed', 'Timeout', 'NewDataNotAvailable', 'DataNotAvailable' :type status: str or ~azure.mgmt.costmanagement.models.ExecutionStatus :param submitted_by: The identifier for the entity that executed the - export. For OnDemand executions, it is the email id. For Scheduled - executions, it is the constant value - System. + export. For OnDemand executions it is the user email. For scheduled + executions it is 'System'. :type submitted_by: str :param submitted_time: The time when export was queued to be executed. :type submitted_time: datetime :param processing_start_time: The time when export was picked up to be executed. :type processing_start_time: datetime - :param processing_end_time: The time when export execution finished. + :param processing_end_time: The time when the export execution finished. :type processing_end_time: datetime - :param file_name: The name of the file export got written to. + :param file_name: The name of the exported file. :type file_name: str - :param run_settings: + :param run_settings: The export settings that were in effect for this + execution. :type run_settings: ~azure.mgmt.costmanagement.models.CommonExportProperties + :param error: The details of any error. + :type error: ~azure.mgmt.costmanagement.models.ErrorDetails """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'tags': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, 'execution_type': {'key': 'properties.executionType', 'type': 'str'}, 'status': {'key': 'properties.status', 'type': 'str'}, 'submitted_by': {'key': 'properties.submittedBy', 'type': 'str'}, @@ -406,10 +850,11 @@ class ExportExecution(Resource): 'processing_end_time': {'key': 'properties.processingEndTime', 'type': 'iso-8601'}, 'file_name': {'key': 'properties.fileName', 'type': 'str'}, 'run_settings': {'key': 'properties.runSettings', 'type': 'CommonExportProperties'}, + 'error': {'key': 'properties.error', 'type': 'ErrorDetails'}, } - def __init__(self, *, execution_type=None, status=None, submitted_by: str=None, submitted_time=None, processing_start_time=None, processing_end_time=None, file_name: str=None, run_settings=None, **kwargs) -> None: - super(ExportExecution, self).__init__(**kwargs) + def __init__(self, *, e_tag: str=None, execution_type=None, status=None, submitted_by: str=None, submitted_time=None, processing_start_time=None, processing_end_time=None, file_name: str=None, run_settings=None, error=None, **kwargs) -> None: + super(ExportExecution, self).__init__(e_tag=e_tag, **kwargs) self.execution_type = execution_type self.status = status self.submitted_by = submitted_by @@ -418,15 +863,16 @@ def __init__(self, *, execution_type=None, status=None, submitted_by: str=None, self.processing_end_time = processing_end_time self.file_name = file_name self.run_settings = run_settings + self.error = error class ExportExecutionListResult(Model): - """Result of listing exports execution history of a export by name. + """Result of listing the execution history of an export. Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: The list of export executions. + :ivar value: A list of export executions. :vartype value: list[~azure.mgmt.costmanagement.models.ExportExecution] """ @@ -494,16 +940,13 @@ def __init__(self, *, from_property, to=None, **kwargs) -> None: class ExportSchedule(Model): - """The schedule associated with a export. - - All required parameters must be populated in order to send to Azure. + """The schedule associated with the export. - :param status: The status of the schedule. Whether active or not. If - inactive, the export's scheduled execution is paused. Possible values - include: 'Active', 'Inactive' + :param status: The status of the export's schedule. If 'Inactive', the + export's schedule is paused. Possible values include: 'Active', 'Inactive' :type status: str or ~azure.mgmt.costmanagement.models.StatusType - :param recurrence: Required. The schedule recurrence. Possible values - include: 'Daily', 'Weekly', 'Monthly', 'Annually' + :param recurrence: The schedule recurrence. Possible values include: + 'Daily', 'Weekly', 'Monthly', 'Annually' :type recurrence: str or ~azure.mgmt.costmanagement.models.RecurrenceType :param recurrence_period: Has start and end date of the recurrence. The start date must be in future. If present, the end date must be greater @@ -512,48 +955,183 @@ class ExportSchedule(Model): ~azure.mgmt.costmanagement.models.ExportRecurrencePeriod """ - _validation = { - 'recurrence': {'required': True}, - } - _attribute_map = { 'status': {'key': 'status', 'type': 'str'}, 'recurrence': {'key': 'recurrence', 'type': 'str'}, 'recurrence_period': {'key': 'recurrencePeriod', 'type': 'ExportRecurrencePeriod'}, } - def __init__(self, *, recurrence, status=None, recurrence_period=None, **kwargs) -> None: + def __init__(self, *, status=None, recurrence=None, recurrence_period=None, **kwargs) -> None: super(ExportSchedule, self).__init__(**kwargs) self.status = status self.recurrence = recurrence self.recurrence_period = recurrence_period -class Operation(Model): - """A Cost management REST API operation. +class ExportTimePeriod(Model): + """The date range for data in the export. This should only be specified with + timeFrame set to 'Custom'. The maximum date range is 3 months. - Variables are only populated by the server, and will be ignored when - sending a request. + All required parameters must be populated in order to send to Azure. - :ivar name: Operation name: {provider}/{resource}/{operation}. - :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.costmanagement.models.OperationDisplay + :param from_property: Required. The start date for export data. + :type from_property: datetime + :param to: Required. The end date for export data. + :type to: datetime """ _validation = { - 'name': {'readonly': True}, + 'from_property': {'required': True}, + 'to': {'required': True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'from_property': {'key': 'from', 'type': 'iso-8601'}, + 'to': {'key': 'to', 'type': 'iso-8601'}, } - def __init__(self, *, display=None, **kwargs) -> None: - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = display + def __init__(self, *, from_property, to, **kwargs) -> None: + super(ExportTimePeriod, self).__init__(**kwargs) + self.from_property = from_property + self.to = to + + +class ForecastDataset(Model): + """The definition of data present in the forecast. + + :param granularity: The granularity of rows in the forecast. Possible + values include: 'Daily' + :type granularity: str or + ~azure.mgmt.costmanagement.models.GranularityType + :param configuration: Has configuration information for the data in the + export. The configuration will be ignored if aggregation and grouping are + provided. + :type configuration: + ~azure.mgmt.costmanagement.models.QueryDatasetConfiguration + :param aggregation: Dictionary of aggregation expression to use in the + forecast. The key of each item in the dictionary is the alias for the + aggregated column. forecast can have up to 2 aggregation clauses. + :type aggregation: dict[str, + ~azure.mgmt.costmanagement.models.QueryAggregation] + :param filter: Has filter expression to use in the forecast. + :type filter: ~azure.mgmt.costmanagement.models.QueryFilter + """ + + _attribute_map = { + 'granularity': {'key': 'granularity', 'type': 'str'}, + 'configuration': {'key': 'configuration', 'type': 'QueryDatasetConfiguration'}, + 'aggregation': {'key': 'aggregation', 'type': '{QueryAggregation}'}, + 'filter': {'key': 'filter', 'type': 'QueryFilter'}, + } + + def __init__(self, *, granularity=None, configuration=None, aggregation=None, filter=None, **kwargs) -> None: + super(ForecastDataset, self).__init__(**kwargs) + self.granularity = granularity + self.configuration = configuration + self.aggregation = aggregation + self.filter = filter + + +class ForecastDefinition(Model): + """The definition of a forecast. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. The type of the forecast. Possible values include: + 'Usage', 'ActualCost', 'AmortizedCost' + :type type: str or ~azure.mgmt.costmanagement.models.ForecastType + :param timeframe: Required. The time frame for pulling data for the + forecast. If custom, then a specific time period must be provided. + Possible values include: 'MonthToDate', 'BillingMonthToDate', + 'TheLastMonth', 'TheLastBillingMonth', 'WeekToDate', 'Custom' + :type timeframe: str or + ~azure.mgmt.costmanagement.models.ForecastTimeframeType + :param time_period: Has time period for pulling data for the forecast. + :type time_period: ~azure.mgmt.costmanagement.models.QueryTimePeriod + :param dataset: Has definition for data in this forecast. + :type dataset: ~azure.mgmt.costmanagement.models.ForecastDataset + :param include_actual_cost: a boolean determining if actualCost will be + included + :type include_actual_cost: bool + :param include_fresh_partial_cost: a boolean determining if + FreshPartialCost will be included + :type include_fresh_partial_cost: bool + """ + + _validation = { + 'type': {'required': True}, + 'timeframe': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'timeframe': {'key': 'timeframe', 'type': 'str'}, + 'time_period': {'key': 'timePeriod', 'type': 'QueryTimePeriod'}, + 'dataset': {'key': 'dataset', 'type': 'ForecastDataset'}, + 'include_actual_cost': {'key': 'includeActualCost', 'type': 'bool'}, + 'include_fresh_partial_cost': {'key': 'includeFreshPartialCost', 'type': 'bool'}, + } + + def __init__(self, *, type, timeframe, time_period=None, dataset=None, include_actual_cost: bool=None, include_fresh_partial_cost: bool=None, **kwargs) -> None: + super(ForecastDefinition, self).__init__(**kwargs) + self.type = type + self.timeframe = timeframe + self.time_period = time_period + self.dataset = dataset + self.include_actual_cost = include_actual_cost + self.include_fresh_partial_cost = include_fresh_partial_cost + + +class KpiProperties(Model): + """Each KPI must contain a 'type' and 'enabled' key. + + :param type: KPI type (Forecast, Budget). Possible values include: + 'Forecast', 'Budget' + :type type: str or ~azure.mgmt.costmanagement.models.KpiTypeType + :param id: ID of resource related to metric (budget). + :type id: str + :param enabled: show the KPI in the UI? + :type enabled: bool + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'enabled': {'key': 'enabled', 'type': 'bool'}, + } + + def __init__(self, *, type=None, id: str=None, enabled: bool=None, **kwargs) -> None: + super(KpiProperties, self).__init__(**kwargs) + self.type = type + self.id = id + self.enabled = enabled + + +class Operation(Model): + """A Cost management REST API operation. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :param display: The object that represents the operation. + :type display: ~azure.mgmt.costmanagement.models.OperationDisplay + """ + + _validation = { + 'name': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + } + + def __init__(self, *, display=None, **kwargs) -> None: + super(Operation, self).__init__(**kwargs) + self.name = None + self.display = display class OperationDisplay(Model): @@ -590,6 +1168,27 @@ def __init__(self, **kwargs) -> None: self.operation = None +class PivotProperties(Model): + """Each pivot must contain a 'type' and 'name'. + + :param type: Data type to show in view. Possible values include: + 'Dimension', 'TagKey' + :type type: str or ~azure.mgmt.costmanagement.models.PivotTypeType + :param name: Data field to show in view. + :type name: str + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__(self, *, type=None, name: str=None, **kwargs) -> None: + super(PivotProperties, self).__init__(**kwargs) + self.type = type + self.name = name + + class QueryAggregation(Model): """The aggregation expression to be used in the query. @@ -921,3 +1520,388 @@ def __init__(self, *, from_property, to, **kwargs) -> None: super(QueryTimePeriod, self).__init__(**kwargs) self.from_property = from_property self.to = to + + +class ReportConfigAggregation(Model): + """The aggregation expression to be used in the report. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. The name of the column to aggregate. + :type name: str + :ivar function: Required. The name of the aggregation function to use. + Default value: "Sum" . + :vartype function: str + """ + + _validation = { + 'name': {'required': True}, + 'function': {'required': True, 'constant': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'function': {'key': 'function', 'type': 'str'}, + } + + function = "Sum" + + def __init__(self, *, name: str, **kwargs) -> None: + super(ReportConfigAggregation, self).__init__(**kwargs) + self.name = name + + +class ReportConfigComparisonExpression(Model): + """The comparison expression to be used in the report. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. The name of the column to use in comparison. + :type name: str + :param operator: Required. The operator to use for comparison. Possible + values include: 'In', 'Contains' + :type operator: str or ~azure.mgmt.costmanagement.models.OperatorType + :param values: Required. Array of values to use for comparison + :type values: list[str] + """ + + _validation = { + 'name': {'required': True}, + 'operator': {'required': True}, + 'values': {'required': True, 'min_items': 1}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'operator': {'key': 'operator', 'type': 'str'}, + 'values': {'key': 'values', 'type': '[str]'}, + } + + def __init__(self, *, name: str, operator, values, **kwargs) -> None: + super(ReportConfigComparisonExpression, self).__init__(**kwargs) + self.name = name + self.operator = operator + self.values = values + + +class ReportConfigDataset(Model): + """The definition of data present in the report. + + :param granularity: The granularity of rows in the report. Possible values + include: 'Daily', 'Monthly' + :type granularity: str or + ~azure.mgmt.costmanagement.models.ReportGranularityType + :param configuration: Has configuration information for the data in the + report. The configuration will be ignored if aggregation and grouping are + provided. + :type configuration: + ~azure.mgmt.costmanagement.models.ReportConfigDatasetConfiguration + :param aggregation: Dictionary of aggregation expression to use in the + report. The key of each item in the dictionary is the alias for the + aggregated column. Report can have up to 2 aggregation clauses. + :type aggregation: dict[str, + ~azure.mgmt.costmanagement.models.ReportConfigAggregation] + :param grouping: Array of group by expression to use in the report. Report + can have up to 2 group by clauses. + :type grouping: + list[~azure.mgmt.costmanagement.models.ReportConfigGrouping] + :param sorting: Array of order by expression to use in the report. + :type sorting: list[~azure.mgmt.costmanagement.models.ReportConfigSorting] + :param filter: Has filter expression to use in the report. + :type filter: ~azure.mgmt.costmanagement.models.ReportConfigFilter + """ + + _validation = { + 'grouping': {'max_items': 2}, + } + + _attribute_map = { + 'granularity': {'key': 'granularity', 'type': 'str'}, + 'configuration': {'key': 'configuration', 'type': 'ReportConfigDatasetConfiguration'}, + 'aggregation': {'key': 'aggregation', 'type': '{ReportConfigAggregation}'}, + 'grouping': {'key': 'grouping', 'type': '[ReportConfigGrouping]'}, + 'sorting': {'key': 'sorting', 'type': '[ReportConfigSorting]'}, + 'filter': {'key': 'filter', 'type': 'ReportConfigFilter'}, + } + + def __init__(self, *, granularity=None, configuration=None, aggregation=None, grouping=None, sorting=None, filter=None, **kwargs) -> None: + super(ReportConfigDataset, self).__init__(**kwargs) + self.granularity = granularity + self.configuration = configuration + self.aggregation = aggregation + self.grouping = grouping + self.sorting = sorting + self.filter = filter + + +class ReportConfigDatasetConfiguration(Model): + """The configuration of dataset in the report. + + :param columns: Array of column names to be included in the report. Any + valid report column name is allowed. If not provided, then report includes + all columns. + :type columns: list[str] + """ + + _attribute_map = { + 'columns': {'key': 'columns', 'type': '[str]'}, + } + + def __init__(self, *, columns=None, **kwargs) -> None: + super(ReportConfigDatasetConfiguration, self).__init__(**kwargs) + self.columns = columns + + +class ReportConfigFilter(Model): + """The filter expression to be used in the report. + + :param and_property: The logical "AND" expression. Must have at least 2 + items. + :type and_property: + list[~azure.mgmt.costmanagement.models.ReportConfigFilter] + :param or_property: The logical "OR" expression. Must have at least 2 + items. + :type or_property: + list[~azure.mgmt.costmanagement.models.ReportConfigFilter] + :param not_property: The logical "NOT" expression. + :type not_property: ~azure.mgmt.costmanagement.models.ReportConfigFilter + :param dimension: Has comparison expression for a dimension + :type dimension: + ~azure.mgmt.costmanagement.models.ReportConfigComparisonExpression + :param tag: Has comparison expression for a tag + :type tag: + ~azure.mgmt.costmanagement.models.ReportConfigComparisonExpression + """ + + _validation = { + 'and_property': {'min_items': 2}, + 'or_property': {'min_items': 2}, + } + + _attribute_map = { + 'and_property': {'key': 'and', 'type': '[ReportConfigFilter]'}, + 'or_property': {'key': 'or', 'type': '[ReportConfigFilter]'}, + 'not_property': {'key': 'not', 'type': 'ReportConfigFilter'}, + 'dimension': {'key': 'dimension', 'type': 'ReportConfigComparisonExpression'}, + 'tag': {'key': 'tag', 'type': 'ReportConfigComparisonExpression'}, + } + + def __init__(self, *, and_property=None, or_property=None, not_property=None, dimension=None, tag=None, **kwargs) -> None: + super(ReportConfigFilter, self).__init__(**kwargs) + self.and_property = and_property + self.or_property = or_property + self.not_property = not_property + self.dimension = dimension + self.tag = tag + + +class ReportConfigGrouping(Model): + """The group by expression to be used in the report. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. Has type of the column to group. Possible values + include: 'Tag', 'Dimension' + :type type: str or + ~azure.mgmt.costmanagement.models.ReportConfigColumnType + :param name: Required. The name of the column to group. This version + supports subscription lowest possible grain. + :type name: str + """ + + _validation = { + 'type': {'required': True}, + 'name': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__(self, *, type, name: str, **kwargs) -> None: + super(ReportConfigGrouping, self).__init__(**kwargs) + self.type = type + self.name = name + + +class ReportConfigSorting(Model): + """The order by expression to be used in the report. + + All required parameters must be populated in order to send to Azure. + + :param direction: Direction of sort. Possible values include: 'Ascending', + 'Descending' + :type direction: str or ~azure.mgmt.costmanagement.models.enum + :param name: Required. The name of the column to sort. + :type name: str + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'direction': {'key': 'direction', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__(self, *, name: str, direction=None, **kwargs) -> None: + super(ReportConfigSorting, self).__init__(**kwargs) + self.direction = direction + self.name = name + + +class ReportConfigTimePeriod(Model): + """The start and end date for pulling data for the report. + + All required parameters must be populated in order to send to Azure. + + :param from_property: Required. The start date to pull data from. + :type from_property: datetime + :param to: Required. The end date to pull data to. + :type to: datetime + """ + + _validation = { + 'from_property': {'required': True}, + 'to': {'required': True}, + } + + _attribute_map = { + 'from_property': {'key': 'from', 'type': 'iso-8601'}, + 'to': {'key': 'to', 'type': 'iso-8601'}, + } + + def __init__(self, *, from_property, to, **kwargs) -> None: + super(ReportConfigTimePeriod, self).__init__(**kwargs) + self.from_property = from_property + self.to = to + + +class View(ProxyResource): + """States and configurations of Cost Analysis. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :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 scenario, + this field will be used to determine whether the user is updating the + latest version or not. + :type e_tag: str + :param display_name: User input name of the view. Required. + :type display_name: str + :param scope: Cost Management scope to save the view on. This includes + 'subscriptions/{subscriptionId}' for subscription scope, + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for + resourceGroup scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + Billing Account scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + for Department scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + for EnrollmentAccount scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + for BillingProfile scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + for InvoiceSection scope, + 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for + Management Group scope, + '/providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + for ExternalBillingAccount scope, and + '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + for ExternalSubscription scope. + :type scope: str + :ivar created_on: Date the user created this view. + :vartype created_on: datetime + :ivar modified_on: Date when the user last modified this view. + :vartype modified_on: datetime + :ivar view_type: Required. The type of the report. Usage represents actual + usage, forecast represents forecasted data and UsageAndForecast represents + both usage and forecasted data. Actual usage and forecasted data can be + differentiated based on dates. Default value: "Usage" . + :vartype view_type: str + :param timeframe: Required. The time frame for pulling data for the + report. If custom, then a specific time period must be provided. Possible + values include: 'WeekToDate', 'MonthToDate', 'YearToDate', 'Custom' + :type timeframe: str or + ~azure.mgmt.costmanagement.models.ReportTimeframeType + :param time_period: Has time period for pulling data for the report. + :type time_period: + ~azure.mgmt.costmanagement.models.ReportConfigTimePeriod + :param dataset: Has definition for data in this report config. + :type dataset: ~azure.mgmt.costmanagement.models.ReportConfigDataset + :param chart: Chart type of the main view in Cost Analysis. Required. + Possible values include: 'Area', 'Line', 'StackedColumn', 'GroupedColumn', + 'Table' + :type chart: str or ~azure.mgmt.costmanagement.models.ChartType + :param accumulated: Show costs accumulated over time. Possible values + include: 'true', 'false' + :type accumulated: str or + ~azure.mgmt.costmanagement.models.AccumulatedType + :param metric: Metric to use when displaying costs. Possible values + include: 'ActualCost', 'AmortizedCost', 'AHUB' + :type metric: str or ~azure.mgmt.costmanagement.models.MetricType + :param kpis: List of KPIs to show in Cost Analysis UI. + :type kpis: list[~azure.mgmt.costmanagement.models.KpiProperties] + :param pivots: Configuration of 3 sub-views in the Cost Analysis UI. + :type pivots: list[~azure.mgmt.costmanagement.models.PivotProperties] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'created_on': {'readonly': True}, + 'modified_on': {'readonly': True}, + 'view_type': {'required': True, 'constant': True}, + 'timeframe': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'str'}, + 'created_on': {'key': 'properties.createdOn', 'type': 'iso-8601'}, + 'modified_on': {'key': 'properties.modifiedOn', 'type': 'iso-8601'}, + 'view_type': {'key': 'properties.query.type', 'type': 'str'}, + 'timeframe': {'key': 'properties.query.timeframe', 'type': 'str'}, + 'time_period': {'key': 'properties.query.timePeriod', 'type': 'ReportConfigTimePeriod'}, + 'dataset': {'key': 'properties.query.dataset', 'type': 'ReportConfigDataset'}, + 'chart': {'key': 'properties.chart', 'type': 'str'}, + 'accumulated': {'key': 'properties.accumulated', 'type': 'str'}, + 'metric': {'key': 'properties.metric', 'type': 'str'}, + 'kpis': {'key': 'properties.kpis', 'type': '[KpiProperties]'}, + 'pivots': {'key': 'properties.pivots', 'type': '[PivotProperties]'}, + } + + view_type = "Usage" + + def __init__(self, *, timeframe, e_tag: str=None, display_name: str=None, scope: str=None, time_period=None, dataset=None, chart=None, accumulated=None, metric=None, kpis=None, pivots=None, **kwargs) -> None: + super(View, self).__init__(e_tag=e_tag, **kwargs) + self.display_name = display_name + self.scope = scope + self.created_on = None + self.modified_on = None + self.timeframe = timeframe + self.time_period = time_period + self.dataset = dataset + self.chart = chart + self.accumulated = accumulated + self.metric = metric + self.kpis = kpis + self.pivots = pivots diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_paged_models.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_paged_models.py index 7f38fa6457678..66bd6b250254a 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_paged_models.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_paged_models.py @@ -12,6 +12,19 @@ from msrest.paging import Paged +class ViewPaged(Paged): + """ + A paging container for iterating over a list of :class:`View ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[View]'} + } + + def __init__(self, *args, **kwargs): + + super(ViewPaged, self).__init__(*args, **kwargs) class DimensionPaged(Paged): """ A paging container for iterating over a list of :class:`Dimension ` object diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/__init__.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/__init__.py index ed3adf92c621f..9b84a0ecd4732 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/__init__.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/__init__.py @@ -9,14 +9,20 @@ # regenerated. # -------------------------------------------------------------------------- +from ._views_operations import ViewsOperations +from ._alerts_operations import AlertsOperations +from ._forecast_operations import ForecastOperations from ._dimensions_operations import DimensionsOperations from ._query_operations import QueryOperations -from ._exports_operations import ExportsOperations from ._operations import Operations +from ._exports_operations import ExportsOperations __all__ = [ + 'ViewsOperations', + 'AlertsOperations', + 'ForecastOperations', 'DimensionsOperations', 'QueryOperations', - 'ExportsOperations', 'Operations', + 'ExportsOperations', ] diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_alerts_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_alerts_operations.py new file mode 100644 index 0000000000000..bc155a8c57d99 --- /dev/null +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_alerts_operations.py @@ -0,0 +1,338 @@ +# 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 AlertsOperations(object): + """AlertsOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :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 2020-06-01. Constant value: "2020-06-01". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2020-06-01" + + self.config = config + + def list( + self, scope, custom_headers=None, raw=False, **operation_config): + """Lists the alerts for scope defined. + + :param scope: The scope associated with alerts operations. This + includes '/subscriptions/{subscriptionId}/' for subscription scope, + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + for resourceGroup scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + Billing Account scope and + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + for Department scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + for EnrollmentAccount scope, + '/providers/Microsoft.Management/managementGroups/{managementGroupId} + for Management Group scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + for billingProfile scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + for invoiceSection scope, and + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + specific for partners. + :type scope: 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: AlertsResult or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.costmanagement.models.AlertsResult or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.list.metadata['url'] + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True) + } + 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('AlertsResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/alerts'} + + def get( + self, scope, alert_id, custom_headers=None, raw=False, **operation_config): + """Gets the alert for the scope by alert ID. + + :param scope: The scope associated with alerts operations. This + includes '/subscriptions/{subscriptionId}/' for subscription scope, + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + for resourceGroup scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + Billing Account scope and + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + for Department scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + for EnrollmentAccount scope, + '/providers/Microsoft.Management/managementGroups/{managementGroupId} + for Management Group scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + for billingProfile scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + for invoiceSection scope, and + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + specific for partners. + :type scope: str + :param alert_id: Alert ID + :type alert_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: Alert or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.costmanagement.models.Alert or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'alertId': self._serialize.url("alert_id", alert_id, 'str', skip_quote=True) + } + 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('Alert', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/alerts/{alertId}'} + + def dismiss( + self, scope, alert_id, parameters, custom_headers=None, raw=False, **operation_config): + """Dismisses the specified alert. + + :param scope: The scope associated with alerts operations. This + includes '/subscriptions/{subscriptionId}/' for subscription scope, + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + for resourceGroup scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + Billing Account scope and + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + for Department scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + for EnrollmentAccount scope, + '/providers/Microsoft.Management/managementGroups/{managementGroupId} + for Management Group scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + for billingProfile scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + for invoiceSection scope, and + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + specific for partners. + :type scope: str + :param alert_id: Alert ID + :type alert_id: str + :param parameters: Parameters supplied to the Dismiss Alert operation. + :type parameters: + ~azure.mgmt.costmanagement.models.DismissAlertPayload + :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: Alert or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.costmanagement.models.Alert or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.dismiss.metadata['url'] + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'alertId': self._serialize.url("alert_id", alert_id, 'str', skip_quote=True) + } + 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' + 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, 'DismissAlertPayload') + + # Construct and send request + request = self._client.patch(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) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Alert', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + dismiss.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/alerts/{alertId}'} + + def list_external( + self, external_cloud_provider_type, external_cloud_provider_id, custom_headers=None, raw=False, **operation_config): + """Lists the Alerts for external cloud provider type defined. + + :param external_cloud_provider_type: The external cloud provider type + associated with dimension/query operations. This includes + 'externalSubscriptions' for linked account and + 'externalBillingAccounts' for consolidated account. Possible values + include: 'externalSubscriptions', 'externalBillingAccounts' + :type external_cloud_provider_type: str or + ~azure.mgmt.costmanagement.models.ExternalCloudProviderType + :param external_cloud_provider_id: This can be + '{externalSubscriptionId}' for linked account or + '{externalBillingAccountId}' for consolidated account used with + dimension/query operations. + :type external_cloud_provider_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: AlertsResult or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.costmanagement.models.AlertsResult or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.list_external.metadata['url'] + path_format_arguments = { + 'externalCloudProviderType': self._serialize.url("external_cloud_provider_type", external_cloud_provider_type, 'str'), + 'externalCloudProviderId': self._serialize.url("external_cloud_provider_id", external_cloud_provider_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('AlertsResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list_external.metadata = {'url': '/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/alerts'} diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_dimensions_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_dimensions_operations.py index a753fb553a79f..49ffa497eb13b 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_dimensions_operations.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_dimensions_operations.py @@ -24,7 +24,7 @@ class DimensionsOperations(object): :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 2019-11-01. Constant value: "2019-11-01". + :ivar api_version: Version of the API to be used with the client request. The current version is 2020-06-01. Constant value: "2020-06-01". """ models = models @@ -34,7 +34,7 @@ def __init__(self, client, config, serializer, deserializer): self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-11-01" + self.api_version = "2020-06-01" self.config = config @@ -145,3 +145,105 @@ def internal_paging(next_link=None): return deserialized list.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/dimensions'} + + def by_external_cloud_provider_type( + self, external_cloud_provider_type, external_cloud_provider_id, filter=None, expand=None, skiptoken=None, top=None, custom_headers=None, raw=False, **operation_config): + """Lists the dimensions by the external cloud provider type. + + :param external_cloud_provider_type: The external cloud provider type + associated with dimension/query operations. This includes + 'externalSubscriptions' for linked account and + 'externalBillingAccounts' for consolidated account. Possible values + include: 'externalSubscriptions', 'externalBillingAccounts' + :type external_cloud_provider_type: str or + ~azure.mgmt.costmanagement.models.ExternalCloudProviderType + :param external_cloud_provider_id: This can be + '{externalSubscriptionId}' for linked account or + '{externalBillingAccountId}' for consolidated account used with + dimension/query operations. + :type external_cloud_provider_id: str + :param filter: May be used to filter dimensions by + properties/category, properties/usageStart, properties/usageEnd. + Supported operators are 'eq','lt', 'gt', 'le', 'ge'. + :type filter: str + :param expand: May be used to expand the properties/data within a + dimension category. By default, data is not included when listing + dimensions. + :type expand: str + :param skiptoken: Skiptoken is only used if a previous operation + returned a partial result. If a previous response contains a nextLink + element, the value of the nextLink element will include a skiptoken + parameter that specifies a starting point to use for subsequent calls. + :type skiptoken: str + :param top: May be used to limit the number of results to the most + recent N dimension data. + :type top: int + :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: An iterator like instance of Dimension + :rtype: + ~azure.mgmt.costmanagement.models.DimensionPaged[~azure.mgmt.costmanagement.models.Dimension] + :raises: + :class:`ErrorResponseException` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.by_external_cloud_provider_type.metadata['url'] + path_format_arguments = { + 'externalCloudProviderType': self._serialize.url("external_cloud_provider_type", external_cloud_provider_type, 'str'), + 'externalCloudProviderId': self._serialize.url("external_cloud_provider_id", external_cloud_provider_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') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + if skiptoken is not None: + query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + + else: + url = next_link + query_parameters = {} + + # 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) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + 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 + header_dict = None + if raw: + header_dict = {} + deserialized = models.DimensionPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + by_external_cloud_provider_type.metadata = {'url': '/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/dimensions'} diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_exports_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_exports_operations.py index 73edeb5069613..03ff569a5ac4d 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_exports_operations.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_exports_operations.py @@ -24,7 +24,7 @@ class ExportsOperations(object): :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 2019-11-01. Constant value: "2019-11-01". + :ivar api_version: Version of the API to be used with the client request. The current version is 2020-06-01. Constant value: "2020-06-01". """ models = models @@ -34,17 +34,16 @@ def __init__(self, client, config, serializer, deserializer): self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-11-01" + self.api_version = "2020-06-01" self.config = config def list( - self, scope, custom_headers=None, raw=False, **operation_config): + self, scope, expand=None, custom_headers=None, raw=False, **operation_config): """The operation to list all exports at the given scope. - :param scope: The scope associated with query and export operations. - This includes '/subscriptions/{subscriptionId}/' for subscription - scope, + :param scope: The scope associated with export operations. This + includes '/subscriptions/{subscriptionId}/' for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for @@ -62,6 +61,10 @@ def list( '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. :type scope: str + :param expand: May be used to expand the properties within an export. + Currently only 'runHistory' is supported and will return information + for the last execution of each export. + :type expand: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -83,6 +86,8 @@ def list( # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') # Construct headers header_parameters = {} @@ -113,12 +118,11 @@ def list( list.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/exports'} def get( - self, scope, export_name, custom_headers=None, raw=False, **operation_config): + self, scope, export_name, expand=None, custom_headers=None, raw=False, **operation_config): """The operation to get the export for the defined scope by export name. - :param scope: The scope associated with query and export operations. - This includes '/subscriptions/{subscriptionId}/' for subscription - scope, + :param scope: The scope associated with export operations. This + includes '/subscriptions/{subscriptionId}/' for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for @@ -138,6 +142,10 @@ def get( :type scope: str :param export_name: Export Name. :type export_name: str + :param expand: May be used to expand the properties within an export. + Currently only 'runHistory' is supported and will return information + for the last 10 executions of the export. + :type expand: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -160,6 +168,8 @@ def get( # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') # Construct headers header_parameters = {} @@ -195,9 +205,8 @@ def create_or_update( latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag. - :param scope: The scope associated with query and export operations. - This includes '/subscriptions/{subscriptionId}/' for subscription - scope, + :param scope: The scope associated with export operations. This + includes '/subscriptions/{subscriptionId}/' for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for @@ -281,9 +290,8 @@ def delete( self, scope, export_name, custom_headers=None, raw=False, **operation_config): """The operation to delete a export. - :param scope: The scope associated with query and export operations. - This includes '/subscriptions/{subscriptionId}/' for subscription - scope, + :param scope: The scope associated with export operations. This + includes '/subscriptions/{subscriptionId}/' for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for @@ -348,11 +356,10 @@ def delete( def execute( self, scope, export_name, custom_headers=None, raw=False, **operation_config): - """The operation to execute a export. + """The operation to execute an export. - :param scope: The scope associated with query and export operations. - This includes '/subscriptions/{subscriptionId}/' for subscription - scope, + :param scope: The scope associated with export operations. This + includes '/subscriptions/{subscriptionId}/' for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for @@ -418,11 +425,10 @@ def execute( def get_execution_history( self, scope, export_name, custom_headers=None, raw=False, **operation_config): """The operation to get the execution history of an export for the defined - scope by export name. + scope and export name. - :param scope: The scope associated with query and export operations. - This includes '/subscriptions/{subscriptionId}/' for subscription - scope, + :param scope: The scope associated with export operations. This + includes '/subscriptions/{subscriptionId}/' for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_forecast_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_forecast_operations.py new file mode 100644 index 0000000000000..0ce8b67ba9b78 --- /dev/null +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_forecast_operations.py @@ -0,0 +1,207 @@ +# 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 ForecastOperations(object): + """ForecastOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :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 2020-06-01. Constant value: "2020-06-01". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2020-06-01" + + self.config = config + + def usage( + self, scope, parameters, filter=None, custom_headers=None, raw=False, **operation_config): + """Lists the forecast charges for scope defined. + + :param scope: The scope associated with forecast operations. This + includes '/subscriptions/{subscriptionId}/' for subscription scope, + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + for resourceGroup scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + Billing Account scope and + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + for Department scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + for EnrollmentAccount scope, + '/providers/Microsoft.Management/managementGroups/{managementGroupId} + for Management Group scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + for billingProfile scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + for invoiceSection scope, and + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + specific for partners. + :type scope: str + :param parameters: Parameters supplied to the CreateOrUpdate Forecast + Config operation. + :type parameters: ~azure.mgmt.costmanagement.models.ForecastDefinition + :param filter: May be used to filter forecasts by properties/usageDate + (Utc time), properties/chargeType or properties/grain. The filter + supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + currently support 'ne', 'or', or 'not'. + :type filter: 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: QueryResult or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.costmanagement.models.QueryResult or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.usage.metadata['url'] + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # 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, 'ForecastDefinition') + + # 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) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('QueryResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + usage.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/forecast'} + + def external_cloud_provider_usage( + self, external_cloud_provider_type, external_cloud_provider_id, parameters, filter=None, custom_headers=None, raw=False, **operation_config): + """Lists the forecast charges for external cloud provider type defined. + + :param external_cloud_provider_type: The external cloud provider type + associated with dimension/query operations. This includes + 'externalSubscriptions' for linked account and + 'externalBillingAccounts' for consolidated account. Possible values + include: 'externalSubscriptions', 'externalBillingAccounts' + :type external_cloud_provider_type: str or + ~azure.mgmt.costmanagement.models.ExternalCloudProviderType + :param external_cloud_provider_id: This can be + '{externalSubscriptionId}' for linked account or + '{externalBillingAccountId}' for consolidated account used with + dimension/query operations. + :type external_cloud_provider_id: str + :param parameters: Parameters supplied to the CreateOrUpdate Forecast + Config operation. + :type parameters: ~azure.mgmt.costmanagement.models.ForecastDefinition + :param filter: May be used to filter forecasts by properties/usageDate + (Utc time), properties/chargeType or properties/grain. The filter + supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not + currently support 'ne', 'or', or 'not'. + :type filter: 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: QueryResult or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.costmanagement.models.QueryResult or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.external_cloud_provider_usage.metadata['url'] + path_format_arguments = { + 'externalCloudProviderType': self._serialize.url("external_cloud_provider_type", external_cloud_provider_type, 'str'), + 'externalCloudProviderId': self._serialize.url("external_cloud_provider_id", external_cloud_provider_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # 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, 'ForecastDefinition') + + # 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) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('QueryResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + external_cloud_provider_usage.metadata = {'url': '/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/forecast'} diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_operations.py index 9b8e7a21167b8..5074c5a490b8e 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_operations.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_operations.py @@ -24,7 +24,7 @@ class Operations(object): :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 2019-11-01. Constant value: "2019-11-01". + :ivar api_version: Version of the API to be used with the client request. The current version is 2020-06-01. Constant value: "2020-06-01". """ models = models @@ -34,7 +34,7 @@ def __init__(self, client, config, serializer, deserializer): self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-11-01" + self.api_version = "2020-06-01" self.config = config diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_query_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_query_operations.py index 00191d7f0ddf6..fdc4919a741a1 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_query_operations.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_query_operations.py @@ -24,7 +24,7 @@ class QueryOperations(object): :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 2019-11-01. Constant value: "2019-11-01". + :ivar api_version: Version of the API to be used with the client request. The current version is 2020-06-01. Constant value: "2020-06-01". """ models = models @@ -34,7 +34,7 @@ def __init__(self, client, config, serializer, deserializer): self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-11-01" + self.api_version = "2020-06-01" self.config = config @@ -118,3 +118,77 @@ def usage( return deserialized usage.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/query'} + + def usage_by_external_cloud_provider_type( + self, external_cloud_provider_type, external_cloud_provider_id, parameters, custom_headers=None, raw=False, **operation_config): + """Query the usage data for external cloud provider type defined. + + :param external_cloud_provider_type: The external cloud provider type + associated with dimension/query operations. This includes + 'externalSubscriptions' for linked account and + 'externalBillingAccounts' for consolidated account. Possible values + include: 'externalSubscriptions', 'externalBillingAccounts' + :type external_cloud_provider_type: str or + ~azure.mgmt.costmanagement.models.ExternalCloudProviderType + :param external_cloud_provider_id: This can be + '{externalSubscriptionId}' for linked account or + '{externalBillingAccountId}' for consolidated account used with + dimension/query operations. + :type external_cloud_provider_id: str + :param parameters: Parameters supplied to the CreateOrUpdate Query + Config operation. + :type parameters: ~azure.mgmt.costmanagement.models.QueryDefinition + :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: QueryResult or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.costmanagement.models.QueryResult or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.usage_by_external_cloud_provider_type.metadata['url'] + path_format_arguments = { + 'externalCloudProviderType': self._serialize.url("external_cloud_provider_type", external_cloud_provider_type, 'str'), + 'externalCloudProviderId': self._serialize.url("external_cloud_provider_id", external_cloud_provider_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' + 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, 'QueryDefinition') + + # 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) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('QueryResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + usage_by_external_cloud_provider_type.metadata = {'url': '/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/query'} diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_views_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_views_operations.py new file mode 100644 index 0000000000000..a198b18a3af14 --- /dev/null +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_views_operations.py @@ -0,0 +1,594 @@ +# 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 ViewsOperations(object): + """ViewsOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :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 2020-06-01. Constant value: "2020-06-01". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2020-06-01" + + self.config = config + + def list( + self, custom_headers=None, raw=False, **operation_config): + """Lists all views by tenant and object. + + :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: An iterator like instance of View + :rtype: + ~azure.mgmt.costmanagement.models.ViewPaged[~azure.mgmt.costmanagement.models.View] + :raises: + :class:`ErrorResponseException` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + + # 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' + 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) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + 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 + header_dict = None + if raw: + header_dict = {} + deserialized = models.ViewPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list.metadata = {'url': '/providers/Microsoft.CostManagement/views'} + + def list_by_scope( + self, scope, custom_headers=None, raw=False, **operation_config): + """Lists all views at the given scope. + + :param scope: The scope associated with view operations. This includes + 'subscriptions/{subscriptionId}' for subscription scope, + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + for resourceGroup scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + Billing Account scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + for Department scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + for EnrollmentAccount scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + for BillingProfile scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + for InvoiceSection scope, + 'providers/Microsoft.Management/managementGroups/{managementGroupId}' + for Management Group scope, + 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + for External Billing Account scope and + 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + for External Subscription scope. + :type scope: 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: An iterator like instance of View + :rtype: + ~azure.mgmt.costmanagement.models.ViewPaged[~azure.mgmt.costmanagement.models.View] + :raises: + :class:`ErrorResponseException` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_scope.metadata['url'] + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, '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' + 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) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + 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 + header_dict = None + if raw: + header_dict = {} + deserialized = models.ViewPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/views'} + + def get( + self, view_name, custom_headers=None, raw=False, **operation_config): + """Gets the view by view name. + + :param view_name: View name + :type view_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`. + :return: View or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.costmanagement.models.View or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'viewName': self._serialize.url("view_name", view_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('View', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/providers/Microsoft.CostManagement/views/{viewName}'} + + def create_or_update( + self, view_name, parameters, custom_headers=None, raw=False, **operation_config): + """The operation to create or update a view. Update operation requires + latest eTag to be set in the request. You may obtain the latest eTag by + performing a get operation. Create operation does not require eTag. + + :param view_name: View name + :type view_name: str + :param parameters: Parameters supplied to the CreateOrUpdate View + operation. + :type parameters: ~azure.mgmt.costmanagement.models.View + :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: View or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.costmanagement.models.View or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.create_or_update.metadata['url'] + path_format_arguments = { + 'viewName': self._serialize.url("view_name", view_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' + 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, 'View') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, 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('View', response) + if response.status_code == 201: + deserialized = self._deserialize('View', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + create_or_update.metadata = {'url': '/providers/Microsoft.CostManagement/views/{viewName}'} + + def delete( + self, view_name, custom_headers=None, raw=False, **operation_config): + """The operation to delete a view. + + :param view_name: View name + :type view_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`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.delete.metadata['url'] + path_format_arguments = { + 'viewName': self._serialize.url("view_name", view_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 = {} + 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.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 204]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete.metadata = {'url': '/providers/Microsoft.CostManagement/views/{viewName}'} + + def get_by_scope( + self, scope, view_name, custom_headers=None, raw=False, **operation_config): + """Gets the view for the defined scope by view name. + + :param scope: The scope associated with view operations. This includes + 'subscriptions/{subscriptionId}' for subscription scope, + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + for resourceGroup scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + Billing Account scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + for Department scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + for EnrollmentAccount scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + for BillingProfile scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + for InvoiceSection scope, + 'providers/Microsoft.Management/managementGroups/{managementGroupId}' + for Management Group scope, + 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + for External Billing Account scope and + 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + for External Subscription scope. + :type scope: str + :param view_name: View name + :type view_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`. + :return: View or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.costmanagement.models.View or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get_by_scope.metadata['url'] + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str'), + 'viewName': self._serialize.url("view_name", view_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('View', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/views/{viewName}'} + + def create_or_update_by_scope( + self, scope, view_name, parameters, custom_headers=None, raw=False, **operation_config): + """The operation to create or update a view. Update operation requires + latest eTag to be set in the request. You may obtain the latest eTag by + performing a get operation. Create operation does not require eTag. + + :param scope: The scope associated with view operations. This includes + 'subscriptions/{subscriptionId}' for subscription scope, + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + for resourceGroup scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + Billing Account scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + for Department scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + for EnrollmentAccount scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + for BillingProfile scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + for InvoiceSection scope, + 'providers/Microsoft.Management/managementGroups/{managementGroupId}' + for Management Group scope, + 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + for External Billing Account scope and + 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + for External Subscription scope. + :type scope: str + :param view_name: View name + :type view_name: str + :param parameters: Parameters supplied to the CreateOrUpdate View + operation. + :type parameters: ~azure.mgmt.costmanagement.models.View + :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: View or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.costmanagement.models.View or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.create_or_update_by_scope.metadata['url'] + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str'), + 'viewName': self._serialize.url("view_name", view_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' + 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, 'View') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, 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('View', response) + if response.status_code == 201: + deserialized = self._deserialize('View', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + create_or_update_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/views/{viewName}'} + + def delete_by_scope( + self, scope, view_name, custom_headers=None, raw=False, **operation_config): + """The operation to delete a view. + + :param scope: The scope associated with view operations. This includes + 'subscriptions/{subscriptionId}' for subscription scope, + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + for resourceGroup scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for + Billing Account scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + for Department scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + for EnrollmentAccount scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + for BillingProfile scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + for InvoiceSection scope, + 'providers/Microsoft.Management/managementGroups/{managementGroupId}' + for Management Group scope, + 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' + for External Billing Account scope and + 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + for External Subscription scope. + :type scope: str + :param view_name: View name + :type view_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`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.delete_by_scope.metadata['url'] + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str'), + 'viewName': self._serialize.url("view_name", view_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 = {} + 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.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 204]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/views/{viewName}'}