diff --git a/sdk/commerce/azure-mgmt-commerce/_meta.json b/sdk/commerce/azure-mgmt-commerce/_meta.json new file mode 100644 index 000000000000..c1e3d76c3480 --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.13.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "543b2ebf5fd46bc7c5f9c59f67a254da1dd53009", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/commerce/resource-manager/readme.md --multiapi --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/commerce/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/__init__.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/__init__.py index e9cde45fd2ff..f2fa1647514f 100644 --- a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/__init__.py +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/__init__.py @@ -7,9 +7,6 @@ # -------------------------------------------------------------------------- from ._usage_management_client import UsageManagementClient -from ._version import VERSION - -__version__ = VERSION __all__ = ['UsageManagementClient'] try: diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/_configuration.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/_configuration.py index e46fff482645..1b6b0e6f83c3 100644 --- a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/_configuration.py +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/_configuration.py @@ -1,16 +1,18 @@ # 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. +# 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. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. # -------------------------------------------------------------------------- - from typing import TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -20,7 +22,6 @@ from azure.core.credentials import TokenCredential - class UsageManagementClientConfiguration(Configuration): """Configuration for UsageManagementClient. @@ -48,9 +49,8 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2015-06-01-preview" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-commerce/{}'.format(VERSION)) + kwargs.setdefault('sdk_moniker', 'azure-mgmt-commerce/{}'.format(VERSION)) self._configure(**kwargs) def _configure( @@ -68,4 +68,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/_usage_management_client.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/_usage_management_client.py index 6fb8240918f6..bc026c688491 100644 --- a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/_usage_management_client.py +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/_usage_management_client.py @@ -1,74 +1,130 @@ # 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. +# 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. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. # -------------------------------------------------------------------------- from typing import TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from azure.mgmt.core import ARMPipelineClient +from azure.profiles import KnownProfiles, ProfileDefinition +from azure.profiles.multiapiclient import MultiApiClientMixin + +from ._configuration import UsageManagementClientConfiguration + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential -from ._configuration import UsageManagementClientConfiguration -from .operations import UsageAggregatesOperations -from .operations import RateCardOperations -from . import models - +class _SDKClient(object): + def __init__(self, *args, **kwargs): + """This is a fake class to support current implemetation of MultiApiClientMixin." + Will be removed in final version of multiapi azure-core based client + """ + pass -class UsageManagementClient(object): +class UsageManagementClient(MultiApiClientMixin, _SDKClient): """UsageManagementClient. - :ivar usage_aggregates: UsageAggregatesOperations operations - :vartype usage_aggregates: azure.mgmt.commerce.operations.UsageAggregatesOperations - :ivar rate_card: RateCardOperations operations - :vartype rate_card: azure.mgmt.commerce.operations.RateCardOperations + This ready contains multiple API versions, to help you deal with all of the Azure clouds + (Azure Stack, Azure Government, Azure China, etc.). + By default, it uses the latest API version available on public Azure. + For production, you should stick to a particular api-version and/or profile. + The profile sets a mapping between an operation group and its API version. + The api-version parameter sets the default API version if the operation + group is not described in the profile. + :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: It uniquely identifies Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL + :param api_version: API version to use if no profile is provided, or if missing in profile. + :type api_version: str + :param base_url: Service URL + :type base_url: str + :param profile: A profile definition, from KnownProfiles to dict. + :type profile: azure.profiles.KnownProfiles """ + DEFAULT_API_VERSION = '2015-06-01-preview' + _PROFILE_TAG = "azure.mgmt.commerce.UsageManagementClient" + LATEST_PROFILE = ProfileDefinition({ + _PROFILE_TAG: { + None: DEFAULT_API_VERSION, + }}, + _PROFILE_TAG + " latest" + ) + def __init__( self, credential, # type: "TokenCredential" subscription_id, # type: str - base_url=None, # type: Optional[str] + api_version=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str + profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' self._config = UsageManagementClientConfiguration(credential, subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + super(UsageManagementClient, self).__init__( + api_version=api_version, + profile=profile + ) + + @classmethod + def _models_dict(cls, api_version): + return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} + + @classmethod + def models(cls, api_version=DEFAULT_API_VERSION): + """Module depends on the API version: + + * 2015-06-01-preview: :mod:`v2015_06_01_preview.models` + """ + if api_version == '2015-06-01-preview': + from .v2015_06_01_preview import models + return models + raise ValueError("API version {} is not available".format(api_version)) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) + @property + def rate_card(self): + """Instance depends on the API version: - self.usage_aggregates = UsageAggregatesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.rate_card = RateCardOperations( - self._client, self._config, self._serialize, self._deserialize) + * 2015-06-01-preview: :class:`RateCardOperations` + """ + api_version = self._get_api_version('rate_card') + if api_version == '2015-06-01-preview': + from .v2015_06_01_preview.operations import RateCardOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'rate_card'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def usage_aggregates(self): + """Instance depends on the API version: + + * 2015-06-01-preview: :class:`UsageAggregatesOperations` + """ + api_version = self._get_api_version('usage_aggregates') + if api_version == '2015-06-01-preview': + from .v2015_06_01_preview.operations import UsageAggregatesOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'usage_aggregates'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) def close(self): - # type: () -> None self._client.close() - def __enter__(self): - # type: () -> UsageManagementClient self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None self._client.__exit__(*exc_details) diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/aio/_configuration.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/aio/_configuration.py index a47bc64a21c4..5a1f9157feeb 100644 --- a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/aio/_configuration.py +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/aio/_configuration.py @@ -1,16 +1,18 @@ # 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. +# 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. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. # -------------------------------------------------------------------------- - from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -18,7 +20,6 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential - class UsageManagementClientConfiguration(Configuration): """Configuration for UsageManagementClient. @@ -35,7 +36,7 @@ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - **kwargs: Any + **kwargs # type: Any ) -> None: if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -45,9 +46,8 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2015-06-01-preview" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-commerce/{}'.format(VERSION)) + kwargs.setdefault('sdk_moniker', 'azure-mgmt-commerce/{}'.format(VERSION)) self._configure(**kwargs) def _configure( @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/aio/_usage_management_client.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/aio/_usage_management_client.py index 0cda7e356a96..22795b3cb7f2 100644 --- a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/aio/_usage_management_client.py +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/aio/_usage_management_client.py @@ -1,68 +1,129 @@ # 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. +# 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. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. # -------------------------------------------------------------------------- from typing import Any, Optional, TYPE_CHECKING -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from azure.mgmt.core import AsyncARMPipelineClient +from azure.profiles import KnownProfiles, ProfileDefinition +from azure.profiles.multiapiclient import MultiApiClientMixin + +from ._configuration import UsageManagementClientConfiguration + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import UsageManagementClientConfiguration -from .operations import UsageAggregatesOperations -from .operations import RateCardOperations -from .. import models - +class _SDKClient(object): + def __init__(self, *args, **kwargs): + """This is a fake class to support current implemetation of MultiApiClientMixin." + Will be removed in final version of multiapi azure-core based client + """ + pass -class UsageManagementClient(object): +class UsageManagementClient(MultiApiClientMixin, _SDKClient): """UsageManagementClient. - :ivar usage_aggregates: UsageAggregatesOperations operations - :vartype usage_aggregates: azure.mgmt.commerce.aio.operations.UsageAggregatesOperations - :ivar rate_card: RateCardOperations operations - :vartype rate_card: azure.mgmt.commerce.aio.operations.RateCardOperations + This ready contains multiple API versions, to help you deal with all of the Azure clouds + (Azure Stack, Azure Government, Azure China, etc.). + By default, it uses the latest API version available on public Azure. + For production, you should stick to a particular api-version and/or profile. + The profile sets a mapping between an operation group and its API version. + The api-version parameter sets the default API version if the operation + group is not described in the profile. + :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: It uniquely identifies Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL + :param api_version: API version to use if no profile is provided, or if missing in profile. + :type api_version: str + :param base_url: Service URL + :type base_url: str + :param profile: A profile definition, from KnownProfiles to dict. + :type profile: azure.profiles.KnownProfiles """ + DEFAULT_API_VERSION = '2015-06-01-preview' + _PROFILE_TAG = "azure.mgmt.commerce.UsageManagementClient" + LATEST_PROFILE = ProfileDefinition({ + _PROFILE_TAG: { + None: DEFAULT_API_VERSION, + }}, + _PROFILE_TAG + " latest" + ) + def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, - **kwargs: Any + api_version: Optional[str] = None, + base_url: str = "https://management.azure.com", + profile: KnownProfiles = KnownProfiles.default, + **kwargs # type: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' self._config = UsageManagementClientConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + super(UsageManagementClient, self).__init__( + api_version=api_version, + profile=profile + ) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) + @classmethod + def _models_dict(cls, api_version): + return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} - self.usage_aggregates = UsageAggregatesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.rate_card = RateCardOperations( - self._client, self._config, self._serialize, self._deserialize) + @classmethod + def models(cls, api_version=DEFAULT_API_VERSION): + """Module depends on the API version: - async def close(self) -> None: - await self._client.close() + * 2015-06-01-preview: :mod:`v2015_06_01_preview.models` + """ + if api_version == '2015-06-01-preview': + from ..v2015_06_01_preview import models + return models + raise ValueError("API version {} is not available".format(api_version)) + + @property + def rate_card(self): + """Instance depends on the API version: + + * 2015-06-01-preview: :class:`RateCardOperations` + """ + api_version = self._get_api_version('rate_card') + if api_version == '2015-06-01-preview': + from ..v2015_06_01_preview.aio.operations import RateCardOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'rate_card'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - async def __aenter__(self) -> "UsageManagementClient": + @property + def usage_aggregates(self): + """Instance depends on the API version: + + * 2015-06-01-preview: :class:`UsageAggregatesOperations` + """ + api_version = self._get_api_version('usage_aggregates') + if api_version == '2015-06-01-preview': + from ..v2015_06_01_preview.aio.operations import UsageAggregatesOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'usage_aggregates'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + async def close(self): + await self._client.close() + async def __aenter__(self): await self._client.__aenter__() return self - - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details): await self._client.__aexit__(*exc_details) diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models.py new file mode 100644 index 000000000000..86bbf97fc224 --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models.py @@ -0,0 +1,7 @@ +# 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. +# -------------------------------------------------------------------------- +from .v2015_06_01_preview.models import * diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/__init__.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/__init__.py deleted file mode 100644 index 413db278aed0..000000000000 --- a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/__init__.py +++ /dev/null @@ -1,53 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- - -try: - from ._models_py3 import ErrorResponse - from ._models_py3 import InfoField - from ._models_py3 import MeterInfo - from ._models_py3 import MonetaryCommitment - from ._models_py3 import MonetaryCredit - from ._models_py3 import OfferTermInfo - from ._models_py3 import RateCardQueryParameters - from ._models_py3 import RecurringCharge - from ._models_py3 import ResourceRateCardInfo - from ._models_py3 import UsageAggregation - from ._models_py3 import UsageAggregationListResult -except (SyntaxError, ImportError): - from ._models import ErrorResponse # type: ignore - from ._models import InfoField # type: ignore - from ._models import MeterInfo # type: ignore - from ._models import MonetaryCommitment # type: ignore - from ._models import MonetaryCredit # type: ignore - from ._models import OfferTermInfo # type: ignore - from ._models import RateCardQueryParameters # type: ignore - from ._models import RecurringCharge # type: ignore - from ._models import ResourceRateCardInfo # type: ignore - from ._models import UsageAggregation # type: ignore - from ._models import UsageAggregationListResult # type: ignore - -from ._usage_management_client_enums import ( - AggregationGranularity, - OfferTermInfoEnum, -) - -__all__ = [ - 'ErrorResponse', - 'InfoField', - 'MeterInfo', - 'MonetaryCommitment', - 'MonetaryCredit', - 'OfferTermInfo', - 'RateCardQueryParameters', - 'RecurringCharge', - 'ResourceRateCardInfo', - 'UsageAggregation', - 'UsageAggregationListResult', - 'AggregationGranularity', - 'OfferTermInfoEnum', -] diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/_models.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/_models.py deleted file mode 100644 index 41e0c7e54fa7..000000000000 --- a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/_models.py +++ /dev/null @@ -1,434 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class ErrorResponse(msrest.serialization.Model): - """Describes the format of Error response. - - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class InfoField(msrest.serialization.Model): - """Key-value pairs of instance details in the legacy format. - - :param project: Identifies the name of the instance provisioned by the user. - :type project: str - """ - - _attribute_map = { - 'project': {'key': 'project', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(InfoField, self).__init__(**kwargs) - self.project = kwargs.get('project', None) - - -class MeterInfo(msrest.serialization.Model): - """Detailed information about the meter. - - :param meter_id: The unique identifier of the resource. - :type meter_id: str - :param meter_name: The name of the meter, within the given meter category. - :type meter_name: str - :param meter_category: The category of the meter, e.g., 'Cloud services', 'Networking', etc.. - :type meter_category: str - :param meter_sub_category: The subcategory of the meter, e.g., 'A6 Cloud services', - 'ExpressRoute (IXP)', etc.. - :type meter_sub_category: str - :param unit: The unit in which the meter consumption is charged, e.g., 'Hours', 'GB', etc. - :type unit: str - :param meter_tags: Provides additional meter data. 'Third Party' indicates a meter with no - discount. Blanks indicate First Party. - :type meter_tags: list[str] - :param meter_region: The region in which the Azure service is available. - :type meter_region: str - :param meter_rates: The list of key/value pairs for the meter rates, in the format - 'key':'value' where key = the meter quantity, and value = the corresponding price. - :type meter_rates: dict[str, float] - :param effective_date: Indicates the date from which the meter rate is effective. - :type effective_date: ~datetime.datetime - :param included_quantity: The resource quantity that is included in the offer at no cost. - Consumption beyond this quantity will be charged. - :type included_quantity: float - """ - - _attribute_map = { - 'meter_id': {'key': 'MeterId', 'type': 'str'}, - 'meter_name': {'key': 'MeterName', 'type': 'str'}, - 'meter_category': {'key': 'MeterCategory', 'type': 'str'}, - 'meter_sub_category': {'key': 'MeterSubCategory', 'type': 'str'}, - 'unit': {'key': 'Unit', 'type': 'str'}, - 'meter_tags': {'key': 'MeterTags', 'type': '[str]'}, - 'meter_region': {'key': 'MeterRegion', 'type': 'str'}, - 'meter_rates': {'key': 'MeterRates', 'type': '{float}'}, - 'effective_date': {'key': 'EffectiveDate', 'type': 'iso-8601'}, - 'included_quantity': {'key': 'IncludedQuantity', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(MeterInfo, self).__init__(**kwargs) - self.meter_id = kwargs.get('meter_id', None) - self.meter_name = kwargs.get('meter_name', None) - self.meter_category = kwargs.get('meter_category', None) - self.meter_sub_category = kwargs.get('meter_sub_category', None) - self.unit = kwargs.get('unit', None) - self.meter_tags = kwargs.get('meter_tags', None) - self.meter_region = kwargs.get('meter_region', None) - self.meter_rates = kwargs.get('meter_rates', None) - self.effective_date = kwargs.get('effective_date', None) - self.included_quantity = kwargs.get('included_quantity', None) - - -class OfferTermInfo(msrest.serialization.Model): - """Describes the offer term. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: MonetaryCommitment, MonetaryCredit, RecurringCharge. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Name of the offer term.Constant filled by server. Possible values - include: "Recurring Charge", "Monetary Commitment", "Monetary Credit". - :type name: str or ~azure.mgmt.commerce.models.OfferTermInfoEnum - :param effective_date: Indicates the date from which the offer term is effective. - :type effective_date: ~datetime.datetime - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'Name', 'type': 'str'}, - 'effective_date': {'key': 'EffectiveDate', 'type': 'iso-8601'}, - } - - _subtype_map = { - 'name': {'Monetary Commitment': 'MonetaryCommitment', 'Monetary Credit': 'MonetaryCredit', 'Recurring Charge': 'RecurringCharge'} - } - - def __init__( - self, - **kwargs - ): - super(OfferTermInfo, self).__init__(**kwargs) - self.name = None # type: Optional[str] - self.effective_date = kwargs.get('effective_date', None) - - -class MonetaryCommitment(OfferTermInfo): - """Indicates that a monetary commitment is required for this offer. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Name of the offer term.Constant filled by server. Possible values - include: "Recurring Charge", "Monetary Commitment", "Monetary Credit". - :type name: str or ~azure.mgmt.commerce.models.OfferTermInfoEnum - :param effective_date: Indicates the date from which the offer term is effective. - :type effective_date: ~datetime.datetime - :param tiered_discount: The list of key/value pairs for the tiered meter rates, in the format - 'key':'value' where key = price, and value = the corresponding discount percentage. This field - is used only by offer terms of type 'Monetary Commitment'. - :type tiered_discount: dict[str, float] - :param excluded_meter_ids: An array of meter ids that are excluded from the given offer terms. - :type excluded_meter_ids: list[str] - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'Name', 'type': 'str'}, - 'effective_date': {'key': 'EffectiveDate', 'type': 'iso-8601'}, - 'tiered_discount': {'key': 'TieredDiscount', 'type': '{float}'}, - 'excluded_meter_ids': {'key': 'ExcludedMeterIds', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(MonetaryCommitment, self).__init__(**kwargs) - self.name = 'Monetary Commitment' # type: str - self.tiered_discount = kwargs.get('tiered_discount', None) - self.excluded_meter_ids = kwargs.get('excluded_meter_ids', None) - - -class MonetaryCredit(OfferTermInfo): - """Indicates that this is a monetary credit offer. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Name of the offer term.Constant filled by server. Possible values - include: "Recurring Charge", "Monetary Commitment", "Monetary Credit". - :type name: str or ~azure.mgmt.commerce.models.OfferTermInfoEnum - :param effective_date: Indicates the date from which the offer term is effective. - :type effective_date: ~datetime.datetime - :param credit: The amount of credit provided under the terms of the given offer level. - :type credit: float - :param excluded_meter_ids: An array of meter ids that are excluded from the given offer terms. - :type excluded_meter_ids: list[str] - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'Name', 'type': 'str'}, - 'effective_date': {'key': 'EffectiveDate', 'type': 'iso-8601'}, - 'credit': {'key': 'Credit', 'type': 'float'}, - 'excluded_meter_ids': {'key': 'ExcludedMeterIds', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(MonetaryCredit, self).__init__(**kwargs) - self.name = 'Monetary Credit' # type: str - self.credit = kwargs.get('credit', None) - self.excluded_meter_ids = kwargs.get('excluded_meter_ids', None) - - -class RateCardQueryParameters(msrest.serialization.Model): - """Parameters that are used in the odata $filter query parameter for providing RateCard information. - - All required parameters must be populated in order to send to Azure. - - :param offer_durable_id: Required. The Offer ID parameter consists of the 'MS-AZR-' prefix, - plus the Offer ID number (e.g., MS-AZR-0026P). See https://azure.microsoft.com/en- - us/support/legal/offer-details/ for more information on the list of available Offer IDs, - country/region availability, and billing currency. - :type offer_durable_id: str - :param currency: Required. The currency in which the rates need to be provided. - :type currency: str - :param locale: Required. The culture in which the resource metadata needs to be localized. - :type locale: str - :param region_info: Required. 2 letter ISO code where the offer was purchased. - :type region_info: str - """ - - _validation = { - 'offer_durable_id': {'required': True, 'pattern': r'^MS-AZR-\d{4}P(-\d{4}P)*$'}, - 'currency': {'required': True}, - 'locale': {'required': True}, - 'region_info': {'required': True}, - } - - _attribute_map = { - 'offer_durable_id': {'key': 'OfferDurableId', 'type': 'str'}, - 'currency': {'key': 'Currency', 'type': 'str'}, - 'locale': {'key': 'Locale', 'type': 'str'}, - 'region_info': {'key': 'RegionInfo', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RateCardQueryParameters, self).__init__(**kwargs) - self.offer_durable_id = kwargs['offer_durable_id'] - self.currency = kwargs['currency'] - self.locale = kwargs['locale'] - self.region_info = kwargs['region_info'] - - -class RecurringCharge(OfferTermInfo): - """Indicates a recurring charge is present for this offer. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Name of the offer term.Constant filled by server. Possible values - include: "Recurring Charge", "Monetary Commitment", "Monetary Credit". - :type name: str or ~azure.mgmt.commerce.models.OfferTermInfoEnum - :param effective_date: Indicates the date from which the offer term is effective. - :type effective_date: ~datetime.datetime - :param recurring_charge: The amount of recurring charge as per the offer term. - :type recurring_charge: int - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'Name', 'type': 'str'}, - 'effective_date': {'key': 'EffectiveDate', 'type': 'iso-8601'}, - 'recurring_charge': {'key': 'RecurringCharge', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(RecurringCharge, self).__init__(**kwargs) - self.name = 'Recurring Charge' # type: str - self.recurring_charge = kwargs.get('recurring_charge', None) - - -class ResourceRateCardInfo(msrest.serialization.Model): - """Price and Metadata information for resources. - - :param currency: The currency in which the rates are provided. - :type currency: str - :param locale: The culture in which the resource information is localized. - :type locale: str - :param is_tax_included: All rates are pretax, so this will always be returned as 'false'. - :type is_tax_included: bool - :param offer_terms: A list of offer terms. - :type offer_terms: list[~azure.mgmt.commerce.models.OfferTermInfo] - :param meters: A list of meters. - :type meters: list[~azure.mgmt.commerce.models.MeterInfo] - """ - - _attribute_map = { - 'currency': {'key': 'Currency', 'type': 'str'}, - 'locale': {'key': 'Locale', 'type': 'str'}, - 'is_tax_included': {'key': 'IsTaxIncluded', 'type': 'bool'}, - 'offer_terms': {'key': 'OfferTerms', 'type': '[OfferTermInfo]'}, - 'meters': {'key': 'Meters', 'type': '[MeterInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceRateCardInfo, self).__init__(**kwargs) - self.currency = kwargs.get('currency', None) - self.locale = kwargs.get('locale', None) - self.is_tax_included = kwargs.get('is_tax_included', None) - self.offer_terms = kwargs.get('offer_terms', None) - self.meters = kwargs.get('meters', None) - - -class UsageAggregation(msrest.serialization.Model): - """Describes the usageAggregation. - - :param id: Unique Id for the usage aggregate. - :type id: str - :param name: Name of the usage aggregate. - :type name: str - :param type: Type of the resource being returned. - :type type: str - :param subscription_id: The subscription identifier for the Azure user. - :type subscription_id: str - :param meter_id: Unique ID for the resource that was consumed (aka ResourceID). - :type meter_id: str - :param usage_start_time: UTC start time for the usage bucket to which this usage aggregate - belongs. - :type usage_start_time: ~datetime.datetime - :param usage_end_time: UTC end time for the usage bucket to which this usage aggregate belongs. - :type usage_end_time: ~datetime.datetime - :param quantity: The amount of the resource consumption that occurred in this time frame. - :type quantity: float - :param unit: The unit in which the usage for this resource is being counted, e.g. Hours, GB. - :type unit: str - :param meter_name: Friendly name of the resource being consumed. - :type meter_name: str - :param meter_category: Category of the consumed resource. - :type meter_category: str - :param meter_sub_category: Sub-category of the consumed resource. - :type meter_sub_category: str - :param meter_region: Region of the meterId used for billing purposes. - :type meter_region: str - :param info_fields: Key-value pairs of instance details (legacy format). - :type info_fields: ~azure.mgmt.commerce.models.InfoField - :param instance_data: Key-value pairs of instance details represented as a string. - :type instance_data: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'subscription_id': {'key': 'properties.subscriptionId', 'type': 'str'}, - 'meter_id': {'key': 'properties.meterId', 'type': 'str'}, - 'usage_start_time': {'key': 'properties.usageStartTime', 'type': 'iso-8601'}, - 'usage_end_time': {'key': 'properties.usageEndTime', 'type': 'iso-8601'}, - 'quantity': {'key': 'properties.quantity', 'type': 'float'}, - 'unit': {'key': 'properties.unit', 'type': 'str'}, - 'meter_name': {'key': 'properties.meterName', 'type': 'str'}, - 'meter_category': {'key': 'properties.meterCategory', 'type': 'str'}, - 'meter_sub_category': {'key': 'properties.meterSubCategory', 'type': 'str'}, - 'meter_region': {'key': 'properties.meterRegion', 'type': 'str'}, - 'info_fields': {'key': 'properties.infoFields', 'type': 'InfoField'}, - 'instance_data': {'key': 'properties.instanceData', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UsageAggregation, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - self.subscription_id = kwargs.get('subscription_id', None) - self.meter_id = kwargs.get('meter_id', None) - self.usage_start_time = kwargs.get('usage_start_time', None) - self.usage_end_time = kwargs.get('usage_end_time', None) - self.quantity = kwargs.get('quantity', None) - self.unit = kwargs.get('unit', None) - self.meter_name = kwargs.get('meter_name', None) - self.meter_category = kwargs.get('meter_category', None) - self.meter_sub_category = kwargs.get('meter_sub_category', None) - self.meter_region = kwargs.get('meter_region', None) - self.info_fields = kwargs.get('info_fields', None) - self.instance_data = kwargs.get('instance_data', None) - - -class UsageAggregationListResult(msrest.serialization.Model): - """The Get UsageAggregates operation response. - - :param value: Gets or sets details for the requested aggregation. - :type value: list[~azure.mgmt.commerce.models.UsageAggregation] - :param next_link: Gets or sets the link to the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[UsageAggregation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UsageAggregationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/_models_py3.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/_models_py3.py deleted file mode 100644 index fb0c50841d5b..000000000000 --- a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/_models_py3.py +++ /dev/null @@ -1,496 +0,0 @@ -# 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 datetime -from typing import Dict, List, Optional - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class ErrorResponse(msrest.serialization.Model): - """Describes the format of Error response. - - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = code - self.message = message - - -class InfoField(msrest.serialization.Model): - """Key-value pairs of instance details in the legacy format. - - :param project: Identifies the name of the instance provisioned by the user. - :type project: str - """ - - _attribute_map = { - 'project': {'key': 'project', 'type': 'str'}, - } - - def __init__( - self, - *, - project: Optional[str] = None, - **kwargs - ): - super(InfoField, self).__init__(**kwargs) - self.project = project - - -class MeterInfo(msrest.serialization.Model): - """Detailed information about the meter. - - :param meter_id: The unique identifier of the resource. - :type meter_id: str - :param meter_name: The name of the meter, within the given meter category. - :type meter_name: str - :param meter_category: The category of the meter, e.g., 'Cloud services', 'Networking', etc.. - :type meter_category: str - :param meter_sub_category: The subcategory of the meter, e.g., 'A6 Cloud services', - 'ExpressRoute (IXP)', etc.. - :type meter_sub_category: str - :param unit: The unit in which the meter consumption is charged, e.g., 'Hours', 'GB', etc. - :type unit: str - :param meter_tags: Provides additional meter data. 'Third Party' indicates a meter with no - discount. Blanks indicate First Party. - :type meter_tags: list[str] - :param meter_region: The region in which the Azure service is available. - :type meter_region: str - :param meter_rates: The list of key/value pairs for the meter rates, in the format - 'key':'value' where key = the meter quantity, and value = the corresponding price. - :type meter_rates: dict[str, float] - :param effective_date: Indicates the date from which the meter rate is effective. - :type effective_date: ~datetime.datetime - :param included_quantity: The resource quantity that is included in the offer at no cost. - Consumption beyond this quantity will be charged. - :type included_quantity: float - """ - - _attribute_map = { - 'meter_id': {'key': 'MeterId', 'type': 'str'}, - 'meter_name': {'key': 'MeterName', 'type': 'str'}, - 'meter_category': {'key': 'MeterCategory', 'type': 'str'}, - 'meter_sub_category': {'key': 'MeterSubCategory', 'type': 'str'}, - 'unit': {'key': 'Unit', 'type': 'str'}, - 'meter_tags': {'key': 'MeterTags', 'type': '[str]'}, - 'meter_region': {'key': 'MeterRegion', 'type': 'str'}, - 'meter_rates': {'key': 'MeterRates', 'type': '{float}'}, - 'effective_date': {'key': 'EffectiveDate', 'type': 'iso-8601'}, - 'included_quantity': {'key': 'IncludedQuantity', 'type': 'float'}, - } - - def __init__( - self, - *, - meter_id: Optional[str] = None, - meter_name: Optional[str] = None, - meter_category: Optional[str] = None, - meter_sub_category: Optional[str] = None, - unit: Optional[str] = None, - meter_tags: Optional[List[str]] = None, - meter_region: Optional[str] = None, - meter_rates: Optional[Dict[str, float]] = None, - effective_date: Optional[datetime.datetime] = None, - included_quantity: Optional[float] = None, - **kwargs - ): - super(MeterInfo, self).__init__(**kwargs) - self.meter_id = meter_id - self.meter_name = meter_name - self.meter_category = meter_category - self.meter_sub_category = meter_sub_category - self.unit = unit - self.meter_tags = meter_tags - self.meter_region = meter_region - self.meter_rates = meter_rates - self.effective_date = effective_date - self.included_quantity = included_quantity - - -class OfferTermInfo(msrest.serialization.Model): - """Describes the offer term. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: MonetaryCommitment, MonetaryCredit, RecurringCharge. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Name of the offer term.Constant filled by server. Possible values - include: "Recurring Charge", "Monetary Commitment", "Monetary Credit". - :type name: str or ~azure.mgmt.commerce.models.OfferTermInfoEnum - :param effective_date: Indicates the date from which the offer term is effective. - :type effective_date: ~datetime.datetime - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'Name', 'type': 'str'}, - 'effective_date': {'key': 'EffectiveDate', 'type': 'iso-8601'}, - } - - _subtype_map = { - 'name': {'Monetary Commitment': 'MonetaryCommitment', 'Monetary Credit': 'MonetaryCredit', 'Recurring Charge': 'RecurringCharge'} - } - - def __init__( - self, - *, - effective_date: Optional[datetime.datetime] = None, - **kwargs - ): - super(OfferTermInfo, self).__init__(**kwargs) - self.name = None # type: Optional[str] - self.effective_date = effective_date - - -class MonetaryCommitment(OfferTermInfo): - """Indicates that a monetary commitment is required for this offer. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Name of the offer term.Constant filled by server. Possible values - include: "Recurring Charge", "Monetary Commitment", "Monetary Credit". - :type name: str or ~azure.mgmt.commerce.models.OfferTermInfoEnum - :param effective_date: Indicates the date from which the offer term is effective. - :type effective_date: ~datetime.datetime - :param tiered_discount: The list of key/value pairs for the tiered meter rates, in the format - 'key':'value' where key = price, and value = the corresponding discount percentage. This field - is used only by offer terms of type 'Monetary Commitment'. - :type tiered_discount: dict[str, float] - :param excluded_meter_ids: An array of meter ids that are excluded from the given offer terms. - :type excluded_meter_ids: list[str] - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'Name', 'type': 'str'}, - 'effective_date': {'key': 'EffectiveDate', 'type': 'iso-8601'}, - 'tiered_discount': {'key': 'TieredDiscount', 'type': '{float}'}, - 'excluded_meter_ids': {'key': 'ExcludedMeterIds', 'type': '[str]'}, - } - - def __init__( - self, - *, - effective_date: Optional[datetime.datetime] = None, - tiered_discount: Optional[Dict[str, float]] = None, - excluded_meter_ids: Optional[List[str]] = None, - **kwargs - ): - super(MonetaryCommitment, self).__init__(effective_date=effective_date, **kwargs) - self.name = 'Monetary Commitment' # type: str - self.tiered_discount = tiered_discount - self.excluded_meter_ids = excluded_meter_ids - - -class MonetaryCredit(OfferTermInfo): - """Indicates that this is a monetary credit offer. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Name of the offer term.Constant filled by server. Possible values - include: "Recurring Charge", "Monetary Commitment", "Monetary Credit". - :type name: str or ~azure.mgmt.commerce.models.OfferTermInfoEnum - :param effective_date: Indicates the date from which the offer term is effective. - :type effective_date: ~datetime.datetime - :param credit: The amount of credit provided under the terms of the given offer level. - :type credit: float - :param excluded_meter_ids: An array of meter ids that are excluded from the given offer terms. - :type excluded_meter_ids: list[str] - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'Name', 'type': 'str'}, - 'effective_date': {'key': 'EffectiveDate', 'type': 'iso-8601'}, - 'credit': {'key': 'Credit', 'type': 'float'}, - 'excluded_meter_ids': {'key': 'ExcludedMeterIds', 'type': '[str]'}, - } - - def __init__( - self, - *, - effective_date: Optional[datetime.datetime] = None, - credit: Optional[float] = None, - excluded_meter_ids: Optional[List[str]] = None, - **kwargs - ): - super(MonetaryCredit, self).__init__(effective_date=effective_date, **kwargs) - self.name = 'Monetary Credit' # type: str - self.credit = credit - self.excluded_meter_ids = excluded_meter_ids - - -class RateCardQueryParameters(msrest.serialization.Model): - """Parameters that are used in the odata $filter query parameter for providing RateCard information. - - All required parameters must be populated in order to send to Azure. - - :param offer_durable_id: Required. The Offer ID parameter consists of the 'MS-AZR-' prefix, - plus the Offer ID number (e.g., MS-AZR-0026P). See https://azure.microsoft.com/en- - us/support/legal/offer-details/ for more information on the list of available Offer IDs, - country/region availability, and billing currency. - :type offer_durable_id: str - :param currency: Required. The currency in which the rates need to be provided. - :type currency: str - :param locale: Required. The culture in which the resource metadata needs to be localized. - :type locale: str - :param region_info: Required. 2 letter ISO code where the offer was purchased. - :type region_info: str - """ - - _validation = { - 'offer_durable_id': {'required': True, 'pattern': r'^MS-AZR-\d{4}P(-\d{4}P)*$'}, - 'currency': {'required': True}, - 'locale': {'required': True}, - 'region_info': {'required': True}, - } - - _attribute_map = { - 'offer_durable_id': {'key': 'OfferDurableId', 'type': 'str'}, - 'currency': {'key': 'Currency', 'type': 'str'}, - 'locale': {'key': 'Locale', 'type': 'str'}, - 'region_info': {'key': 'RegionInfo', 'type': 'str'}, - } - - def __init__( - self, - *, - offer_durable_id: str, - currency: str, - locale: str, - region_info: str, - **kwargs - ): - super(RateCardQueryParameters, self).__init__(**kwargs) - self.offer_durable_id = offer_durable_id - self.currency = currency - self.locale = locale - self.region_info = region_info - - -class RecurringCharge(OfferTermInfo): - """Indicates a recurring charge is present for this offer. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Name of the offer term.Constant filled by server. Possible values - include: "Recurring Charge", "Monetary Commitment", "Monetary Credit". - :type name: str or ~azure.mgmt.commerce.models.OfferTermInfoEnum - :param effective_date: Indicates the date from which the offer term is effective. - :type effective_date: ~datetime.datetime - :param recurring_charge: The amount of recurring charge as per the offer term. - :type recurring_charge: int - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'Name', 'type': 'str'}, - 'effective_date': {'key': 'EffectiveDate', 'type': 'iso-8601'}, - 'recurring_charge': {'key': 'RecurringCharge', 'type': 'int'}, - } - - def __init__( - self, - *, - effective_date: Optional[datetime.datetime] = None, - recurring_charge: Optional[int] = None, - **kwargs - ): - super(RecurringCharge, self).__init__(effective_date=effective_date, **kwargs) - self.name = 'Recurring Charge' # type: str - self.recurring_charge = recurring_charge - - -class ResourceRateCardInfo(msrest.serialization.Model): - """Price and Metadata information for resources. - - :param currency: The currency in which the rates are provided. - :type currency: str - :param locale: The culture in which the resource information is localized. - :type locale: str - :param is_tax_included: All rates are pretax, so this will always be returned as 'false'. - :type is_tax_included: bool - :param offer_terms: A list of offer terms. - :type offer_terms: list[~azure.mgmt.commerce.models.OfferTermInfo] - :param meters: A list of meters. - :type meters: list[~azure.mgmt.commerce.models.MeterInfo] - """ - - _attribute_map = { - 'currency': {'key': 'Currency', 'type': 'str'}, - 'locale': {'key': 'Locale', 'type': 'str'}, - 'is_tax_included': {'key': 'IsTaxIncluded', 'type': 'bool'}, - 'offer_terms': {'key': 'OfferTerms', 'type': '[OfferTermInfo]'}, - 'meters': {'key': 'Meters', 'type': '[MeterInfo]'}, - } - - def __init__( - self, - *, - currency: Optional[str] = None, - locale: Optional[str] = None, - is_tax_included: Optional[bool] = None, - offer_terms: Optional[List["OfferTermInfo"]] = None, - meters: Optional[List["MeterInfo"]] = None, - **kwargs - ): - super(ResourceRateCardInfo, self).__init__(**kwargs) - self.currency = currency - self.locale = locale - self.is_tax_included = is_tax_included - self.offer_terms = offer_terms - self.meters = meters - - -class UsageAggregation(msrest.serialization.Model): - """Describes the usageAggregation. - - :param id: Unique Id for the usage aggregate. - :type id: str - :param name: Name of the usage aggregate. - :type name: str - :param type: Type of the resource being returned. - :type type: str - :param subscription_id: The subscription identifier for the Azure user. - :type subscription_id: str - :param meter_id: Unique ID for the resource that was consumed (aka ResourceID). - :type meter_id: str - :param usage_start_time: UTC start time for the usage bucket to which this usage aggregate - belongs. - :type usage_start_time: ~datetime.datetime - :param usage_end_time: UTC end time for the usage bucket to which this usage aggregate belongs. - :type usage_end_time: ~datetime.datetime - :param quantity: The amount of the resource consumption that occurred in this time frame. - :type quantity: float - :param unit: The unit in which the usage for this resource is being counted, e.g. Hours, GB. - :type unit: str - :param meter_name: Friendly name of the resource being consumed. - :type meter_name: str - :param meter_category: Category of the consumed resource. - :type meter_category: str - :param meter_sub_category: Sub-category of the consumed resource. - :type meter_sub_category: str - :param meter_region: Region of the meterId used for billing purposes. - :type meter_region: str - :param info_fields: Key-value pairs of instance details (legacy format). - :type info_fields: ~azure.mgmt.commerce.models.InfoField - :param instance_data: Key-value pairs of instance details represented as a string. - :type instance_data: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'subscription_id': {'key': 'properties.subscriptionId', 'type': 'str'}, - 'meter_id': {'key': 'properties.meterId', 'type': 'str'}, - 'usage_start_time': {'key': 'properties.usageStartTime', 'type': 'iso-8601'}, - 'usage_end_time': {'key': 'properties.usageEndTime', 'type': 'iso-8601'}, - 'quantity': {'key': 'properties.quantity', 'type': 'float'}, - 'unit': {'key': 'properties.unit', 'type': 'str'}, - 'meter_name': {'key': 'properties.meterName', 'type': 'str'}, - 'meter_category': {'key': 'properties.meterCategory', 'type': 'str'}, - 'meter_sub_category': {'key': 'properties.meterSubCategory', 'type': 'str'}, - 'meter_region': {'key': 'properties.meterRegion', 'type': 'str'}, - 'info_fields': {'key': 'properties.infoFields', 'type': 'InfoField'}, - 'instance_data': {'key': 'properties.instanceData', 'type': 'str'}, - } - - def __init__( - self, - *, - id: Optional[str] = None, - name: Optional[str] = None, - type: Optional[str] = None, - subscription_id: Optional[str] = None, - meter_id: Optional[str] = None, - usage_start_time: Optional[datetime.datetime] = None, - usage_end_time: Optional[datetime.datetime] = None, - quantity: Optional[float] = None, - unit: Optional[str] = None, - meter_name: Optional[str] = None, - meter_category: Optional[str] = None, - meter_sub_category: Optional[str] = None, - meter_region: Optional[str] = None, - info_fields: Optional["InfoField"] = None, - instance_data: Optional[str] = None, - **kwargs - ): - super(UsageAggregation, self).__init__(**kwargs) - self.id = id - self.name = name - self.type = type - self.subscription_id = subscription_id - self.meter_id = meter_id - self.usage_start_time = usage_start_time - self.usage_end_time = usage_end_time - self.quantity = quantity - self.unit = unit - self.meter_name = meter_name - self.meter_category = meter_category - self.meter_sub_category = meter_sub_category - self.meter_region = meter_region - self.info_fields = info_fields - self.instance_data = instance_data - - -class UsageAggregationListResult(msrest.serialization.Model): - """The Get UsageAggregates operation response. - - :param value: Gets or sets details for the requested aggregation. - :type value: list[~azure.mgmt.commerce.models.UsageAggregation] - :param next_link: Gets or sets the link to the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[UsageAggregation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - *, - value: Optional[List["UsageAggregation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): - super(UsageAggregationListResult, self).__init__(**kwargs) - self.value = value - self.next_link = next_link diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/_usage_management_client_enums.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/_usage_management_client_enums.py deleted file mode 100644 index 8e2f2a240e22..000000000000 --- a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/_usage_management_client_enums.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AggregationGranularity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - - DAILY = "Daily" - HOURLY = "Hourly" - -class OfferTermInfoEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Name of the offer term - """ - - RECURRING_CHARGE = "Recurring Charge" - MONETARY_COMMITMENT = "Monetary Commitment" - MONETARY_CREDIT = "Monetary Credit" diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/operations/_usage_aggregates_operations.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/operations/_usage_aggregates_operations.py deleted file mode 100644 index deac3eb71da6..000000000000 --- a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/operations/_usage_aggregates_operations.py +++ /dev/null @@ -1,145 +0,0 @@ -# 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 datetime -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class UsageAggregatesOperations(object): - """UsageAggregatesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.commerce.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - reported_start_time, # type: datetime.datetime - reported_end_time, # type: datetime.datetime - show_details=None, # type: Optional[bool] - aggregation_granularity="Daily", # type: Optional[Union[str, "_models.AggregationGranularity"]] - continuation_token_parameter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.UsageAggregationListResult"] - """Query aggregated Azure subscription consumption data for a date range. - - :param reported_start_time: The start of the time range to retrieve data for. - :type reported_start_time: ~datetime.datetime - :param reported_end_time: The end of the time range to retrieve data for. - :type reported_end_time: ~datetime.datetime - :param show_details: ``True`` returns usage data in instance-level detail, ``false`` causes - server-side aggregation with fewer details. For example, if you have 3 website instances, by - default you will get 3 line items for website consumption. If you specify showDetails = false, - the data will be aggregated as a single line item for website consumption within the time - period (for the given subscriptionId, meterId, usageStartTime and usageEndTime). - :type show_details: bool - :param aggregation_granularity: ``Daily`` (default) returns the data in daily granularity, - ``Hourly`` returns the data in hourly granularity. - :type aggregation_granularity: str or ~azure.mgmt.commerce.models.AggregationGranularity - :param continuation_token_parameter: Used when a continuation token string is provided in the - response body of the previous call, enabling paging through a large result set. If not present, - the data is retrieved from the beginning of the day/hour (based on the granularity) passed in. - :type continuation_token_parameter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageAggregationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.commerce.models.UsageAggregationListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageAggregationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01-preview" - accept = "application/json, text/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['reportedStartTime'] = self._serialize.query("reported_start_time", reported_start_time, 'iso-8601') - query_parameters['reportedEndTime'] = self._serialize.query("reported_end_time", reported_end_time, 'iso-8601') - if show_details is not None: - query_parameters['showDetails'] = self._serialize.query("show_details", show_details, 'bool') - if aggregation_granularity is not None: - query_parameters['aggregationGranularity'] = self._serialize.query("aggregation_granularity", aggregation_granularity, 'str') - if continuation_token_parameter is not None: - query_parameters['continuationToken'] = self._serialize.query("continuation_token_parameter", continuation_token_parameter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('UsageAggregationListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Commerce/UsageAggregates'} # type: ignore diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/__init__.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/__init__.py new file mode 100644 index 000000000000..b95de5b7880a --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._usage_management_client import UsageManagementClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ['UsageManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/_configuration.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/_configuration.py new file mode 100644 index 000000000000..984a14d768e8 --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/_configuration.py @@ -0,0 +1,74 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class UsageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for UsageManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: It uniquely identifies Microsoft Azure subscription. The subscription + ID forms part of the URI for every service call. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2015-06-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(UsageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2015-06-01-preview") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-commerce/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/_metadata.json b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/_metadata.json new file mode 100644 index 000000000000..ebaa00857fcf --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/_metadata.json @@ -0,0 +1,103 @@ +{ + "chosen_version": "2015-06-01-preview", + "total_api_version_list": ["2015-06-01-preview"], + "client": { + "name": "UsageManagementClient", + "filename": "_usage_management_client", + "description": "UsageManagementClient.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"UsageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"UsageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "It uniquely identifies Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "It uniquely identifies Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=\"https://management.azure.com\", # type: str", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "usage_aggregates": "UsageAggregatesOperations", + "rate_card": "RateCardOperations" + } +} \ No newline at end of file diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/_patch.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/_usage_management_client.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/_usage_management_client.py new file mode 100644 index 000000000000..4038ece7716f --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/_usage_management_client.py @@ -0,0 +1,100 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +from ._configuration import UsageManagementClientConfiguration +from .operations import RateCardOperations, UsageAggregatesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class UsageManagementClient: + """UsageManagementClient. + + :ivar usage_aggregates: UsageAggregatesOperations operations + :vartype usage_aggregates: + azure.mgmt.commerce.v2015_06_01_preview.operations.UsageAggregatesOperations + :ivar rate_card: RateCardOperations operations + :vartype rate_card: azure.mgmt.commerce.v2015_06_01_preview.operations.RateCardOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: It uniquely identifies Microsoft Azure subscription. The subscription + ID forms part of the URI for every service call. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2015-06-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = UsageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.usage_aggregates = UsageAggregatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.rate_card = RateCardOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> UsageManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/_vendor.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/_version.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/_version.py @@ -0,0 +1,9 @@ +# 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. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/aio/__init__.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/aio/__init__.py new file mode 100644 index 000000000000..854b7f046ae4 --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/aio/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._usage_management_client import UsageManagementClient +__all__ = ['UsageManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/aio/_configuration.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/aio/_configuration.py new file mode 100644 index 000000000000..20f31a973c34 --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/aio/_configuration.py @@ -0,0 +1,73 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class UsageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for UsageManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: It uniquely identifies Microsoft Azure subscription. The subscription + ID forms part of the URI for every service call. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2015-06-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(UsageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2015-06-01-preview") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-commerce/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/aio/_patch.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/aio/_usage_management_client.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/aio/_usage_management_client.py new file mode 100644 index 000000000000..0c0fb640450d --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/aio/_usage_management_client.py @@ -0,0 +1,97 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +from ._configuration import UsageManagementClientConfiguration +from .operations import RateCardOperations, UsageAggregatesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class UsageManagementClient: + """UsageManagementClient. + + :ivar usage_aggregates: UsageAggregatesOperations operations + :vartype usage_aggregates: + azure.mgmt.commerce.v2015_06_01_preview.aio.operations.UsageAggregatesOperations + :ivar rate_card: RateCardOperations operations + :vartype rate_card: azure.mgmt.commerce.v2015_06_01_preview.aio.operations.RateCardOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: It uniquely identifies Microsoft Azure subscription. The subscription + ID forms part of the URI for every service call. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2015-06-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = UsageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.usage_aggregates = UsageAggregatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.rate_card = RateCardOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "UsageManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/aio/operations/__init__.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/aio/operations/__init__.py similarity index 100% rename from sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/aio/operations/__init__.py rename to sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/aio/operations/__init__.py diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/aio/operations/_rate_card_operations.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/aio/operations/_rate_card_operations.py similarity index 71% rename from sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/aio/operations/_rate_card_operations.py rename to sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/aio/operations/_rate_card_operations.py index 2ce68ff7835f..2f2de4fe658c 100644 --- a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/aio/operations/_rate_card_operations.py +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/aio/operations/_rate_card_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._rate_card_operations import build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -25,7 +28,7 @@ class RateCardOperations: instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.commerce.models + :type models: ~azure.mgmt.commerce.v2015_06_01_preview.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -40,10 +43,11 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, filter: str, - **kwargs + **kwargs: Any ) -> "_models.ResourceRateCardInfo": """Enables you to query for the resource/meter metadata and related prices used in a given subscription by Offer ID, Currency, Locale and Region. The metadata associated with the billing @@ -59,7 +63,7 @@ async def get( :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ResourceRateCardInfo, or the result of cls(response) - :rtype: ~azure.mgmt.commerce.models.ResourceRateCardInfo + :rtype: ~azure.mgmt.commerce.v2015_06_01_preview.models.ResourceRateCardInfo :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceRateCardInfo"] @@ -67,32 +71,29 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2015-06-01-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ResourceRateCardInfo', pipeline_response) @@ -101,4 +102,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Commerce/RateCard'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Commerce/RateCard"} # type: ignore + diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/aio/operations/_usage_aggregates_operations.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/aio/operations/_usage_aggregates_operations.py similarity index 62% rename from sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/aio/operations/_usage_aggregates_operations.py rename to sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/aio/operations/_usage_aggregates_operations.py index 56fb41f22d70..75f15230648b 100644 --- a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/aio/operations/_usage_aggregates_operations.py +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/aio/operations/_usage_aggregates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,17 +7,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._usage_aggregates_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -27,7 +30,7 @@ class UsageAggregatesOperations: instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.commerce.models + :type models: ~azure.mgmt.commerce.v2015_06_01_preview.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -42,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, reported_start_time: datetime.datetime, @@ -49,7 +53,7 @@ def list( show_details: Optional[bool] = None, aggregation_granularity: Optional[Union[str, "_models.AggregationGranularity"]] = "Daily", continuation_token_parameter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.UsageAggregationListResult"]: """Query aggregated Azure subscription consumption data for a date range. @@ -61,61 +65,67 @@ def list( server-side aggregation with fewer details. For example, if you have 3 website instances, by default you will get 3 line items for website consumption. If you specify showDetails = false, the data will be aggregated as a single line item for website consumption within the time - period (for the given subscriptionId, meterId, usageStartTime and usageEndTime). + period (for the given subscriptionId, meterId, usageStartTime and usageEndTime). Default value + is None. :type show_details: bool :param aggregation_granularity: ``Daily`` (default) returns the data in daily granularity, - ``Hourly`` returns the data in hourly granularity. - :type aggregation_granularity: str or ~azure.mgmt.commerce.models.AggregationGranularity + ``Hourly`` returns the data in hourly granularity. Default value is "Daily". + :type aggregation_granularity: str or + ~azure.mgmt.commerce.v2015_06_01_preview.models.AggregationGranularity :param continuation_token_parameter: Used when a continuation token string is provided in the response body of the previous call, enabling paging through a large result set. If not present, the data is retrieved from the beginning of the day/hour (based on the granularity) passed in. + Default value is None. :type continuation_token_parameter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageAggregationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.commerce.models.UsageAggregationListResult] + :return: An iterator like instance of either UsageAggregationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.commerce.v2015_06_01_preview.models.UsageAggregationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageAggregationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01-preview" - accept = "application/json, text/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['reportedStartTime'] = self._serialize.query("reported_start_time", reported_start_time, 'iso-8601') - query_parameters['reportedEndTime'] = self._serialize.query("reported_end_time", reported_end_time, 'iso-8601') - if show_details is not None: - query_parameters['showDetails'] = self._serialize.query("show_details", show_details, 'bool') - if aggregation_granularity is not None: - query_parameters['aggregationGranularity'] = self._serialize.query("aggregation_granularity", aggregation_granularity, 'str') - if continuation_token_parameter is not None: - query_parameters['continuationToken'] = self._serialize.query("continuation_token_parameter", continuation_token_parameter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + reported_start_time=reported_start_time, + reported_end_time=reported_end_time, + show_details=show_details, + aggregation_granularity=aggregation_granularity, + continuation_token_parameter=continuation_token_parameter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + reported_start_time=reported_start_time, + reported_end_time=reported_end_time, + show_details=show_details, + aggregation_granularity=aggregation_granularity, + continuation_token_parameter=continuation_token_parameter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('UsageAggregationListResult', pipeline_response) + deserialized = self._deserialize("UsageAggregationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -124,17 +134,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Commerce/UsageAggregates'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Commerce/UsageAggregates"} # type: ignore diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/models/__init__.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/models/__init__.py new file mode 100644 index 000000000000..0dfff9f7dc80 --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/models/__init__.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import ErrorResponse +from ._models_py3 import InfoField +from ._models_py3 import MeterInfo +from ._models_py3 import MonetaryCommitment +from ._models_py3 import MonetaryCredit +from ._models_py3 import OfferTermInfo +from ._models_py3 import RateCardQueryParameters +from ._models_py3 import RecurringCharge +from ._models_py3 import ResourceRateCardInfo +from ._models_py3 import UsageAggregation +from ._models_py3 import UsageAggregationListResult + + +from ._usage_management_client_enums import ( + AggregationGranularity, + OfferTermInfoEnum, +) + +__all__ = [ + 'ErrorResponse', + 'InfoField', + 'MeterInfo', + 'MonetaryCommitment', + 'MonetaryCredit', + 'OfferTermInfo', + 'RateCardQueryParameters', + 'RecurringCharge', + 'ResourceRateCardInfo', + 'UsageAggregation', + 'UsageAggregationListResult', + 'AggregationGranularity', + 'OfferTermInfoEnum', +] diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/models/_models_py3.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/models/_models_py3.py new file mode 100644 index 000000000000..0733b11a1103 --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/models/_models_py3.py @@ -0,0 +1,627 @@ +# 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 datetime +from typing import Dict, List, Optional + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + + +class ErrorResponse(msrest.serialization.Model): + """Describes the format of Error response. + + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + **kwargs + ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ + super(ErrorResponse, self).__init__(**kwargs) + self.code = code + self.message = message + + +class InfoField(msrest.serialization.Model): + """Key-value pairs of instance details in the legacy format. + + :ivar project: Identifies the name of the instance provisioned by the user. + :vartype project: str + """ + + _attribute_map = { + 'project': {'key': 'project', 'type': 'str'}, + } + + def __init__( + self, + *, + project: Optional[str] = None, + **kwargs + ): + """ + :keyword project: Identifies the name of the instance provisioned by the user. + :paramtype project: str + """ + super(InfoField, self).__init__(**kwargs) + self.project = project + + +class MeterInfo(msrest.serialization.Model): + """Detailed information about the meter. + + :ivar meter_id: The unique identifier of the resource. + :vartype meter_id: str + :ivar meter_name: The name of the meter, within the given meter category. + :vartype meter_name: str + :ivar meter_category: The category of the meter, e.g., 'Cloud services', 'Networking', etc.. + :vartype meter_category: str + :ivar meter_sub_category: The subcategory of the meter, e.g., 'A6 Cloud services', + 'ExpressRoute (IXP)', etc.. + :vartype meter_sub_category: str + :ivar unit: The unit in which the meter consumption is charged, e.g., 'Hours', 'GB', etc. + :vartype unit: str + :ivar meter_tags: Provides additional meter data. 'Third Party' indicates a meter with no + discount. Blanks indicate First Party. + :vartype meter_tags: list[str] + :ivar meter_region: The region in which the Azure service is available. + :vartype meter_region: str + :ivar meter_rates: The list of key/value pairs for the meter rates, in the format 'key':'value' + where key = the meter quantity, and value = the corresponding price. + :vartype meter_rates: dict[str, float] + :ivar effective_date: Indicates the date from which the meter rate is effective. + :vartype effective_date: ~datetime.datetime + :ivar included_quantity: The resource quantity that is included in the offer at no cost. + Consumption beyond this quantity will be charged. + :vartype included_quantity: float + """ + + _attribute_map = { + 'meter_id': {'key': 'MeterId', 'type': 'str'}, + 'meter_name': {'key': 'MeterName', 'type': 'str'}, + 'meter_category': {'key': 'MeterCategory', 'type': 'str'}, + 'meter_sub_category': {'key': 'MeterSubCategory', 'type': 'str'}, + 'unit': {'key': 'Unit', 'type': 'str'}, + 'meter_tags': {'key': 'MeterTags', 'type': '[str]'}, + 'meter_region': {'key': 'MeterRegion', 'type': 'str'}, + 'meter_rates': {'key': 'MeterRates', 'type': '{float}'}, + 'effective_date': {'key': 'EffectiveDate', 'type': 'iso-8601'}, + 'included_quantity': {'key': 'IncludedQuantity', 'type': 'float'}, + } + + def __init__( + self, + *, + meter_id: Optional[str] = None, + meter_name: Optional[str] = None, + meter_category: Optional[str] = None, + meter_sub_category: Optional[str] = None, + unit: Optional[str] = None, + meter_tags: Optional[List[str]] = None, + meter_region: Optional[str] = None, + meter_rates: Optional[Dict[str, float]] = None, + effective_date: Optional[datetime.datetime] = None, + included_quantity: Optional[float] = None, + **kwargs + ): + """ + :keyword meter_id: The unique identifier of the resource. + :paramtype meter_id: str + :keyword meter_name: The name of the meter, within the given meter category. + :paramtype meter_name: str + :keyword meter_category: The category of the meter, e.g., 'Cloud services', 'Networking', etc.. + :paramtype meter_category: str + :keyword meter_sub_category: The subcategory of the meter, e.g., 'A6 Cloud services', + 'ExpressRoute (IXP)', etc.. + :paramtype meter_sub_category: str + :keyword unit: The unit in which the meter consumption is charged, e.g., 'Hours', 'GB', etc. + :paramtype unit: str + :keyword meter_tags: Provides additional meter data. 'Third Party' indicates a meter with no + discount. Blanks indicate First Party. + :paramtype meter_tags: list[str] + :keyword meter_region: The region in which the Azure service is available. + :paramtype meter_region: str + :keyword meter_rates: The list of key/value pairs for the meter rates, in the format + 'key':'value' where key = the meter quantity, and value = the corresponding price. + :paramtype meter_rates: dict[str, float] + :keyword effective_date: Indicates the date from which the meter rate is effective. + :paramtype effective_date: ~datetime.datetime + :keyword included_quantity: The resource quantity that is included in the offer at no cost. + Consumption beyond this quantity will be charged. + :paramtype included_quantity: float + """ + super(MeterInfo, self).__init__(**kwargs) + self.meter_id = meter_id + self.meter_name = meter_name + self.meter_category = meter_category + self.meter_sub_category = meter_sub_category + self.unit = unit + self.meter_tags = meter_tags + self.meter_region = meter_region + self.meter_rates = meter_rates + self.effective_date = effective_date + self.included_quantity = included_quantity + + +class OfferTermInfo(msrest.serialization.Model): + """Describes the offer term. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: MonetaryCommitment, MonetaryCredit, RecurringCharge. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. Name of the offer term.Constant filled by server. Possible values + include: "Recurring Charge", "Monetary Commitment", "Monetary Credit". + :vartype name: str or ~azure.mgmt.commerce.v2015_06_01_preview.models.OfferTermInfoEnum + :ivar effective_date: Indicates the date from which the offer term is effective. + :vartype effective_date: ~datetime.datetime + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'Name', 'type': 'str'}, + 'effective_date': {'key': 'EffectiveDate', 'type': 'iso-8601'}, + } + + _subtype_map = { + 'name': {'Monetary Commitment': 'MonetaryCommitment', 'Monetary Credit': 'MonetaryCredit', 'Recurring Charge': 'RecurringCharge'} + } + + def __init__( + self, + *, + effective_date: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword effective_date: Indicates the date from which the offer term is effective. + :paramtype effective_date: ~datetime.datetime + """ + super(OfferTermInfo, self).__init__(**kwargs) + self.name = None # type: Optional[str] + self.effective_date = effective_date + + +class MonetaryCommitment(OfferTermInfo): + """Indicates that a monetary commitment is required for this offer. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. Name of the offer term.Constant filled by server. Possible values + include: "Recurring Charge", "Monetary Commitment", "Monetary Credit". + :vartype name: str or ~azure.mgmt.commerce.v2015_06_01_preview.models.OfferTermInfoEnum + :ivar effective_date: Indicates the date from which the offer term is effective. + :vartype effective_date: ~datetime.datetime + :ivar tiered_discount: The list of key/value pairs for the tiered meter rates, in the format + 'key':'value' where key = price, and value = the corresponding discount percentage. This field + is used only by offer terms of type 'Monetary Commitment'. + :vartype tiered_discount: dict[str, float] + :ivar excluded_meter_ids: An array of meter ids that are excluded from the given offer terms. + :vartype excluded_meter_ids: list[str] + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'Name', 'type': 'str'}, + 'effective_date': {'key': 'EffectiveDate', 'type': 'iso-8601'}, + 'tiered_discount': {'key': 'TieredDiscount', 'type': '{float}'}, + 'excluded_meter_ids': {'key': 'ExcludedMeterIds', 'type': '[str]'}, + } + + def __init__( + self, + *, + effective_date: Optional[datetime.datetime] = None, + tiered_discount: Optional[Dict[str, float]] = None, + excluded_meter_ids: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword effective_date: Indicates the date from which the offer term is effective. + :paramtype effective_date: ~datetime.datetime + :keyword tiered_discount: The list of key/value pairs for the tiered meter rates, in the format + 'key':'value' where key = price, and value = the corresponding discount percentage. This field + is used only by offer terms of type 'Monetary Commitment'. + :paramtype tiered_discount: dict[str, float] + :keyword excluded_meter_ids: An array of meter ids that are excluded from the given offer + terms. + :paramtype excluded_meter_ids: list[str] + """ + super(MonetaryCommitment, self).__init__(effective_date=effective_date, **kwargs) + self.name = 'Monetary Commitment' # type: str + self.tiered_discount = tiered_discount + self.excluded_meter_ids = excluded_meter_ids + + +class MonetaryCredit(OfferTermInfo): + """Indicates that this is a monetary credit offer. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. Name of the offer term.Constant filled by server. Possible values + include: "Recurring Charge", "Monetary Commitment", "Monetary Credit". + :vartype name: str or ~azure.mgmt.commerce.v2015_06_01_preview.models.OfferTermInfoEnum + :ivar effective_date: Indicates the date from which the offer term is effective. + :vartype effective_date: ~datetime.datetime + :ivar credit: The amount of credit provided under the terms of the given offer level. + :vartype credit: float + :ivar excluded_meter_ids: An array of meter ids that are excluded from the given offer terms. + :vartype excluded_meter_ids: list[str] + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'Name', 'type': 'str'}, + 'effective_date': {'key': 'EffectiveDate', 'type': 'iso-8601'}, + 'credit': {'key': 'Credit', 'type': 'float'}, + 'excluded_meter_ids': {'key': 'ExcludedMeterIds', 'type': '[str]'}, + } + + def __init__( + self, + *, + effective_date: Optional[datetime.datetime] = None, + credit: Optional[float] = None, + excluded_meter_ids: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword effective_date: Indicates the date from which the offer term is effective. + :paramtype effective_date: ~datetime.datetime + :keyword credit: The amount of credit provided under the terms of the given offer level. + :paramtype credit: float + :keyword excluded_meter_ids: An array of meter ids that are excluded from the given offer + terms. + :paramtype excluded_meter_ids: list[str] + """ + super(MonetaryCredit, self).__init__(effective_date=effective_date, **kwargs) + self.name = 'Monetary Credit' # type: str + self.credit = credit + self.excluded_meter_ids = excluded_meter_ids + + +class RateCardQueryParameters(msrest.serialization.Model): + """Parameters that are used in the odata $filter query parameter for providing RateCard information. + + All required parameters must be populated in order to send to Azure. + + :ivar offer_durable_id: Required. The Offer ID parameter consists of the 'MS-AZR-' prefix, plus + the Offer ID number (e.g., MS-AZR-0026P). See + https://azure.microsoft.com/en-us/support/legal/offer-details/ for more information on the list + of available Offer IDs, country/region availability, and billing currency. + :vartype offer_durable_id: str + :ivar currency: Required. The currency in which the rates need to be provided. + :vartype currency: str + :ivar locale: Required. The culture in which the resource metadata needs to be localized. + :vartype locale: str + :ivar region_info: Required. 2 letter ISO code where the offer was purchased. + :vartype region_info: str + """ + + _validation = { + 'offer_durable_id': {'required': True, 'pattern': r'^MS-AZR-\d{4}P(-\d{4}P)*$'}, + 'currency': {'required': True}, + 'locale': {'required': True}, + 'region_info': {'required': True}, + } + + _attribute_map = { + 'offer_durable_id': {'key': 'OfferDurableId', 'type': 'str'}, + 'currency': {'key': 'Currency', 'type': 'str'}, + 'locale': {'key': 'Locale', 'type': 'str'}, + 'region_info': {'key': 'RegionInfo', 'type': 'str'}, + } + + def __init__( + self, + *, + offer_durable_id: str, + currency: str, + locale: str, + region_info: str, + **kwargs + ): + """ + :keyword offer_durable_id: Required. The Offer ID parameter consists of the 'MS-AZR-' prefix, + plus the Offer ID number (e.g., MS-AZR-0026P). See + https://azure.microsoft.com/en-us/support/legal/offer-details/ for more information on the list + of available Offer IDs, country/region availability, and billing currency. + :paramtype offer_durable_id: str + :keyword currency: Required. The currency in which the rates need to be provided. + :paramtype currency: str + :keyword locale: Required. The culture in which the resource metadata needs to be localized. + :paramtype locale: str + :keyword region_info: Required. 2 letter ISO code where the offer was purchased. + :paramtype region_info: str + """ + super(RateCardQueryParameters, self).__init__(**kwargs) + self.offer_durable_id = offer_durable_id + self.currency = currency + self.locale = locale + self.region_info = region_info + + +class RecurringCharge(OfferTermInfo): + """Indicates a recurring charge is present for this offer. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. Name of the offer term.Constant filled by server. Possible values + include: "Recurring Charge", "Monetary Commitment", "Monetary Credit". + :vartype name: str or ~azure.mgmt.commerce.v2015_06_01_preview.models.OfferTermInfoEnum + :ivar effective_date: Indicates the date from which the offer term is effective. + :vartype effective_date: ~datetime.datetime + :ivar recurring_charge: The amount of recurring charge as per the offer term. + :vartype recurring_charge: int + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'Name', 'type': 'str'}, + 'effective_date': {'key': 'EffectiveDate', 'type': 'iso-8601'}, + 'recurring_charge': {'key': 'RecurringCharge', 'type': 'int'}, + } + + def __init__( + self, + *, + effective_date: Optional[datetime.datetime] = None, + recurring_charge: Optional[int] = None, + **kwargs + ): + """ + :keyword effective_date: Indicates the date from which the offer term is effective. + :paramtype effective_date: ~datetime.datetime + :keyword recurring_charge: The amount of recurring charge as per the offer term. + :paramtype recurring_charge: int + """ + super(RecurringCharge, self).__init__(effective_date=effective_date, **kwargs) + self.name = 'Recurring Charge' # type: str + self.recurring_charge = recurring_charge + + +class ResourceRateCardInfo(msrest.serialization.Model): + """Price and Metadata information for resources. + + :ivar currency: The currency in which the rates are provided. + :vartype currency: str + :ivar locale: The culture in which the resource information is localized. + :vartype locale: str + :ivar is_tax_included: All rates are pretax, so this will always be returned as 'false'. + :vartype is_tax_included: bool + :ivar offer_terms: A list of offer terms. + :vartype offer_terms: list[~azure.mgmt.commerce.v2015_06_01_preview.models.OfferTermInfo] + :ivar meters: A list of meters. + :vartype meters: list[~azure.mgmt.commerce.v2015_06_01_preview.models.MeterInfo] + """ + + _attribute_map = { + 'currency': {'key': 'Currency', 'type': 'str'}, + 'locale': {'key': 'Locale', 'type': 'str'}, + 'is_tax_included': {'key': 'IsTaxIncluded', 'type': 'bool'}, + 'offer_terms': {'key': 'OfferTerms', 'type': '[OfferTermInfo]'}, + 'meters': {'key': 'Meters', 'type': '[MeterInfo]'}, + } + + def __init__( + self, + *, + currency: Optional[str] = None, + locale: Optional[str] = None, + is_tax_included: Optional[bool] = None, + offer_terms: Optional[List["OfferTermInfo"]] = None, + meters: Optional[List["MeterInfo"]] = None, + **kwargs + ): + """ + :keyword currency: The currency in which the rates are provided. + :paramtype currency: str + :keyword locale: The culture in which the resource information is localized. + :paramtype locale: str + :keyword is_tax_included: All rates are pretax, so this will always be returned as 'false'. + :paramtype is_tax_included: bool + :keyword offer_terms: A list of offer terms. + :paramtype offer_terms: list[~azure.mgmt.commerce.v2015_06_01_preview.models.OfferTermInfo] + :keyword meters: A list of meters. + :paramtype meters: list[~azure.mgmt.commerce.v2015_06_01_preview.models.MeterInfo] + """ + super(ResourceRateCardInfo, self).__init__(**kwargs) + self.currency = currency + self.locale = locale + self.is_tax_included = is_tax_included + self.offer_terms = offer_terms + self.meters = meters + + +class UsageAggregation(msrest.serialization.Model): + """Describes the usageAggregation. + + :ivar id: Unique Id for the usage aggregate. + :vartype id: str + :ivar name: Name of the usage aggregate. + :vartype name: str + :ivar type: Type of the resource being returned. + :vartype type: str + :ivar subscription_id: The subscription identifier for the Azure user. + :vartype subscription_id: str + :ivar meter_id: Unique ID for the resource that was consumed (aka ResourceID). + :vartype meter_id: str + :ivar usage_start_time: UTC start time for the usage bucket to which this usage aggregate + belongs. + :vartype usage_start_time: ~datetime.datetime + :ivar usage_end_time: UTC end time for the usage bucket to which this usage aggregate belongs. + :vartype usage_end_time: ~datetime.datetime + :ivar quantity: The amount of the resource consumption that occurred in this time frame. + :vartype quantity: float + :ivar unit: The unit in which the usage for this resource is being counted, e.g. Hours, GB. + :vartype unit: str + :ivar meter_name: Friendly name of the resource being consumed. + :vartype meter_name: str + :ivar meter_category: Category of the consumed resource. + :vartype meter_category: str + :ivar meter_sub_category: Sub-category of the consumed resource. + :vartype meter_sub_category: str + :ivar meter_region: Region of the meterId used for billing purposes. + :vartype meter_region: str + :ivar info_fields: Key-value pairs of instance details (legacy format). + :vartype info_fields: ~azure.mgmt.commerce.v2015_06_01_preview.models.InfoField + :ivar instance_data: Key-value pairs of instance details represented as a string. + :vartype instance_data: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'subscription_id': {'key': 'properties.subscriptionId', 'type': 'str'}, + 'meter_id': {'key': 'properties.meterId', 'type': 'str'}, + 'usage_start_time': {'key': 'properties.usageStartTime', 'type': 'iso-8601'}, + 'usage_end_time': {'key': 'properties.usageEndTime', 'type': 'iso-8601'}, + 'quantity': {'key': 'properties.quantity', 'type': 'float'}, + 'unit': {'key': 'properties.unit', 'type': 'str'}, + 'meter_name': {'key': 'properties.meterName', 'type': 'str'}, + 'meter_category': {'key': 'properties.meterCategory', 'type': 'str'}, + 'meter_sub_category': {'key': 'properties.meterSubCategory', 'type': 'str'}, + 'meter_region': {'key': 'properties.meterRegion', 'type': 'str'}, + 'info_fields': {'key': 'properties.infoFields', 'type': 'InfoField'}, + 'instance_data': {'key': 'properties.instanceData', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + name: Optional[str] = None, + type: Optional[str] = None, + subscription_id: Optional[str] = None, + meter_id: Optional[str] = None, + usage_start_time: Optional[datetime.datetime] = None, + usage_end_time: Optional[datetime.datetime] = None, + quantity: Optional[float] = None, + unit: Optional[str] = None, + meter_name: Optional[str] = None, + meter_category: Optional[str] = None, + meter_sub_category: Optional[str] = None, + meter_region: Optional[str] = None, + info_fields: Optional["InfoField"] = None, + instance_data: Optional[str] = None, + **kwargs + ): + """ + :keyword id: Unique Id for the usage aggregate. + :paramtype id: str + :keyword name: Name of the usage aggregate. + :paramtype name: str + :keyword type: Type of the resource being returned. + :paramtype type: str + :keyword subscription_id: The subscription identifier for the Azure user. + :paramtype subscription_id: str + :keyword meter_id: Unique ID for the resource that was consumed (aka ResourceID). + :paramtype meter_id: str + :keyword usage_start_time: UTC start time for the usage bucket to which this usage aggregate + belongs. + :paramtype usage_start_time: ~datetime.datetime + :keyword usage_end_time: UTC end time for the usage bucket to which this usage aggregate + belongs. + :paramtype usage_end_time: ~datetime.datetime + :keyword quantity: The amount of the resource consumption that occurred in this time frame. + :paramtype quantity: float + :keyword unit: The unit in which the usage for this resource is being counted, e.g. Hours, GB. + :paramtype unit: str + :keyword meter_name: Friendly name of the resource being consumed. + :paramtype meter_name: str + :keyword meter_category: Category of the consumed resource. + :paramtype meter_category: str + :keyword meter_sub_category: Sub-category of the consumed resource. + :paramtype meter_sub_category: str + :keyword meter_region: Region of the meterId used for billing purposes. + :paramtype meter_region: str + :keyword info_fields: Key-value pairs of instance details (legacy format). + :paramtype info_fields: ~azure.mgmt.commerce.v2015_06_01_preview.models.InfoField + :keyword instance_data: Key-value pairs of instance details represented as a string. + :paramtype instance_data: str + """ + super(UsageAggregation, self).__init__(**kwargs) + self.id = id + self.name = name + self.type = type + self.subscription_id = subscription_id + self.meter_id = meter_id + self.usage_start_time = usage_start_time + self.usage_end_time = usage_end_time + self.quantity = quantity + self.unit = unit + self.meter_name = meter_name + self.meter_category = meter_category + self.meter_sub_category = meter_sub_category + self.meter_region = meter_region + self.info_fields = info_fields + self.instance_data = instance_data + + +class UsageAggregationListResult(msrest.serialization.Model): + """The Get UsageAggregates operation response. + + :ivar value: Gets or sets details for the requested aggregation. + :vartype value: list[~azure.mgmt.commerce.v2015_06_01_preview.models.UsageAggregation] + :ivar next_link: Gets or sets the link to the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[UsageAggregation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["UsageAggregation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Gets or sets details for the requested aggregation. + :paramtype value: list[~azure.mgmt.commerce.v2015_06_01_preview.models.UsageAggregation] + :keyword next_link: Gets or sets the link to the next set of results. + :paramtype next_link: str + """ + super(UsageAggregationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/models/_usage_management_client_enums.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/models/_usage_management_client_enums.py new file mode 100644 index 000000000000..c5e26ced811a --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/models/_usage_management_client_enums.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta + + +class AggregationGranularity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + + DAILY = "Daily" + HOURLY = "Hourly" + +class OfferTermInfoEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Name of the offer term + """ + + RECURRING_CHARGE = "Recurring Charge" + MONETARY_COMMITMENT = "Monetary Commitment" + MONETARY_CREDIT = "Monetary Credit" diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/operations/__init__.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/operations/__init__.py similarity index 100% rename from sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/operations/__init__.py rename to sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/operations/__init__.py diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/operations/_rate_card_operations.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/operations/_rate_card_operations.py similarity index 55% rename from sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/operations/_rate_card_operations.py rename to sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/operations/_rate_card_operations.py index dc62fc4c47bc..683db0793a90 100644 --- a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/operations/_rate_card_operations.py +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/operations/_rate_card_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + *, + filter: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-06-01-preview") # type: str + + accept = "application/json, text/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Commerce/RateCard") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class RateCardOperations(object): """RateCardOperations operations. @@ -29,7 +66,7 @@ class RateCardOperations(object): instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.commerce.models + :type models: ~azure.mgmt.commerce.v2015_06_01_preview.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -44,12 +81,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - filter, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ResourceRateCardInfo" + filter: str, + **kwargs: Any + ) -> "_models.ResourceRateCardInfo": """Enables you to query for the resource/meter metadata and related prices used in a given subscription by Offer ID, Currency, Locale and Region. The metadata associated with the billing meters, including but not limited to service names, types, resources, units of measure, and @@ -64,7 +101,7 @@ def get( :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ResourceRateCardInfo, or the result of cls(response) - :rtype: ~azure.mgmt.commerce.models.ResourceRateCardInfo + :rtype: ~azure.mgmt.commerce.v2015_06_01_preview.models.ResourceRateCardInfo :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceRateCardInfo"] @@ -72,32 +109,29 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2015-06-01-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ResourceRateCardInfo', pipeline_response) @@ -106,4 +140,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Commerce/RateCard'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Commerce/RateCard"} # type: ignore + diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/operations/_usage_aggregates_operations.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/operations/_usage_aggregates_operations.py new file mode 100644 index 000000000000..a69c724221d8 --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/operations/_usage_aggregates_operations.py @@ -0,0 +1,204 @@ +# pylint: disable=too-many-lines +# 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 datetime +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + *, + reported_start_time: datetime.datetime, + reported_end_time: datetime.datetime, + show_details: Optional[bool] = None, + aggregation_granularity: Optional[Union[str, "_models.AggregationGranularity"]] = "Daily", + continuation_token_parameter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-06-01-preview") # type: str + + accept = "application/json, text/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Commerce/UsageAggregates") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['reportedStartTime'] = _SERIALIZER.query("reported_start_time", reported_start_time, 'iso-8601') + _query_parameters['reportedEndTime'] = _SERIALIZER.query("reported_end_time", reported_end_time, 'iso-8601') + if show_details is not None: + _query_parameters['showDetails'] = _SERIALIZER.query("show_details", show_details, 'bool') + if aggregation_granularity is not None: + _query_parameters['aggregationGranularity'] = _SERIALIZER.query("aggregation_granularity", aggregation_granularity, 'str') + if continuation_token_parameter is not None: + _query_parameters['continuationToken'] = _SERIALIZER.query("continuation_token_parameter", continuation_token_parameter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class UsageAggregatesOperations(object): + """UsageAggregatesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.commerce.v2015_06_01_preview.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + reported_start_time: datetime.datetime, + reported_end_time: datetime.datetime, + show_details: Optional[bool] = None, + aggregation_granularity: Optional[Union[str, "_models.AggregationGranularity"]] = "Daily", + continuation_token_parameter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.UsageAggregationListResult"]: + """Query aggregated Azure subscription consumption data for a date range. + + :param reported_start_time: The start of the time range to retrieve data for. + :type reported_start_time: ~datetime.datetime + :param reported_end_time: The end of the time range to retrieve data for. + :type reported_end_time: ~datetime.datetime + :param show_details: ``True`` returns usage data in instance-level detail, ``false`` causes + server-side aggregation with fewer details. For example, if you have 3 website instances, by + default you will get 3 line items for website consumption. If you specify showDetails = false, + the data will be aggregated as a single line item for website consumption within the time + period (for the given subscriptionId, meterId, usageStartTime and usageEndTime). Default value + is None. + :type show_details: bool + :param aggregation_granularity: ``Daily`` (default) returns the data in daily granularity, + ``Hourly`` returns the data in hourly granularity. Default value is "Daily". + :type aggregation_granularity: str or + ~azure.mgmt.commerce.v2015_06_01_preview.models.AggregationGranularity + :param continuation_token_parameter: Used when a continuation token string is provided in the + response body of the previous call, enabling paging through a large result set. If not present, + the data is retrieved from the beginning of the day/hour (based on the granularity) passed in. + Default value is None. + :type continuation_token_parameter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either UsageAggregationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.commerce.v2015_06_01_preview.models.UsageAggregationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2015-06-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageAggregationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + reported_start_time=reported_start_time, + reported_end_time=reported_end_time, + show_details=show_details, + aggregation_granularity=aggregation_granularity, + continuation_token_parameter=continuation_token_parameter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + reported_start_time=reported_start_time, + reported_end_time=reported_end_time, + show_details=show_details, + aggregation_granularity=aggregation_granularity, + continuation_token_parameter=continuation_token_parameter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("UsageAggregationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Commerce/UsageAggregates"} # type: ignore diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/py.typed b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file