diff --git a/sdk/commerce/azure-mgmt-commerce/MANIFEST.in b/sdk/commerce/azure-mgmt-commerce/MANIFEST.in index a3cb07df8765..3a9b6517412b 100644 --- a/sdk/commerce/azure-mgmt-commerce/MANIFEST.in +++ b/sdk/commerce/azure-mgmt-commerce/MANIFEST.in @@ -1,3 +1,4 @@ +include _meta.json recursive-include tests *.py *.yaml include *.md include azure/__init__.py diff --git a/sdk/commerce/azure-mgmt-commerce/_meta.json b/sdk/commerce/azure-mgmt-commerce/_meta.json new file mode 100644 index 000000000000..4850fcac862c --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.4.2", + "use": [ + "@autorest/python@5.8.1", + "@autorest/modelerfour@4.19.2" + ], + "commit": "0abc0495ddd2d32319104c905ffee0ad43bdce21", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/commerce/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.1 --use=@autorest/modelerfour@4.19.2 --version=3.4.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..1ebff8056012 100644 --- a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/_configuration.py +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/_configuration.py @@ -1,11 +1,13 @@ # 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 @@ -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( 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..44cf9dbc3ea8 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,132 @@ # 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 azure.profiles import KnownProfiles, ProfileDefinition +from azure.profiles.multiapiclient import MultiApiClientMixin from msrest import Deserializer, Serializer +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 azure.core.pipeline.transport import HttpRequest, HttpResponse -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 + api_version=None, # type: Optional[str] base_url=None, # type: Optional[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)} - 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(cls, api_version=DEFAULT_API_VERSION): + """Module 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: :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.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..910aa27f0771 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,11 +1,13 @@ # 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 @@ -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( 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..aa1170d9c84d 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,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 Any, Optional, TYPE_CHECKING +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.profiles import KnownProfiles, ProfileDefinition +from azure.profiles.multiapiclient import MultiApiClientMixin from msrest import Deserializer, Serializer +from ._configuration import UsageManagementClientConfiguration + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports 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, + api_version: Optional[str] = None, base_url: Optional[str] = None, - **kwargs: Any + 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)) - async def __aenter__(self) -> "UsageManagementClient": + @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))) + + @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/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..e9cde45fd2ff --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/__init__.py @@ -0,0 +1,19 @@ +# 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'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass 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..e46fff482645 --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/_configuration.py @@ -0,0 +1,71 @@ +# 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 TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + + +class UsageManagementClientConfiguration(Configuration): + """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 + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") + super(UsageManagementClientConfiguration, self).__init__(**kwargs) + + 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)) + 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 = policies.BearerTokenCredentialPolicy(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..356c9bbc36e1 --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/_metadata.json @@ -0,0 +1,104 @@ +{ + "chosen_version": "2015-06-01-preview", + "total_api_version_list": ["2015-06-01-preview"], + "client": { + "name": "UsageManagementClient", + "filename": "_usage_management_client", + "description": "UsageManagementClient.", + "base_url": "\u0027https://management.azure.com\u0027", + "custom_base_url": 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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"UsageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"UsageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + }, + "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=None, # type: Optional[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: Optional[str] = None,", + "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_default_policy_type": "BearerTokenCredentialPolicy", + "credential_default_policy_type_has_async_version": true, + "credential_key_header_name": null, + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"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\"]}, \"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/_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..87096faafb13 --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/_usage_management_client.py @@ -0,0 +1,93 @@ +# 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 TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + from azure.core.pipeline.transport import HttpRequest, HttpResponse + +from ._configuration import UsageManagementClientConfiguration +from .operations import UsageAggregatesOperations +from .operations import RateCardOperations +from . import models + + +class UsageManagementClient(object): + """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 str base_url: Service URL + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **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) + + 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) + + 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, http_request, **kwargs): + # type: (HttpRequest, Any) -> HttpResponse + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.HttpResponse + """ + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + + 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/_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..6ab657d72f07 --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/aio/__init__.py @@ -0,0 +1,10 @@ +# 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'] 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..a47bc64a21c4 --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/aio/_configuration.py @@ -0,0 +1,67 @@ +# 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 + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class UsageManagementClientConfiguration(Configuration): + """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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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.") + super(UsageManagementClientConfiguration, self).__init__(**kwargs) + + 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)) + 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 = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) 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..037a7a25bc1c --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/aio/_usage_management_client.py @@ -0,0 +1,86 @@ +# 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, Optional, TYPE_CHECKING + +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._configuration import UsageManagementClientConfiguration +from .operations import UsageAggregatesOperations +from .operations import RateCardOperations +from .. import models + + +class UsageManagementClient(object): + """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 str base_url: Service URL + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: 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) + + 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) + + self.usage_aggregates = UsageAggregatesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.rate_card = RateCardOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + """ + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + + 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/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/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/v2015_06_01_preview/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 new file mode 100644 index 000000000000..3cc9e2b22603 --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/aio/operations/_rate_card_operations.py @@ -0,0 +1,104 @@ +# 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, Callable, Dict, Generic, Optional, TypeVar +import warnings + +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.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class RateCardOperations: + """RateCardOperations async 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) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get( + self, + 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 + regions, is subject to change at any time and without notice. If you intend to use this billing + data in an automated fashion, please use the billing meter GUID to uniquely identify each + billable item. If the billing meter GUID is scheduled to change due to a new billing model, you + will be notified in advance of the change. + + :param filter: The filter to apply on the operation. It ONLY supports the 'eq' and 'and' + logical operators at this time. All the 4 query parameters 'OfferDurableId', 'Currency', + 'Locale', 'Region' are required to be a part of the $filter. + :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.v2015_06_01_preview.models.ResourceRateCardInfo + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceRateCardInfo"] + 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" + + # 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) + 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, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceRateCardInfo', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + 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/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 new file mode 100644 index 000000000000..e27b9e8f8423 --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/aio/operations/_usage_aggregates_operations.py @@ -0,0 +1,140 @@ +# 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +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.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class UsageAggregatesOperations: + """UsageAggregatesOperations async 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) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + 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 + ) -> AsyncIterable["_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.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. + :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.v2015_06_01_preview.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 + + async 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, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_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 AsyncItemPaged( + 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/models/__init__.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/models/__init__.py similarity index 100% rename from sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/__init__.py rename to sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/models/__init__.py diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/_models.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/models/_models.py similarity index 94% rename from sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/_models.py rename to sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/models/_models.py index 41e0c7e54fa7..e311925ff69d 100644 --- a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/_models.py +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/models/_models.py @@ -121,7 +121,7 @@ class OfferTermInfo(msrest.serialization.Model): :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 + :type name: str or ~azure.mgmt.commerce.v2015_06_01_preview.models.OfferTermInfoEnum :param effective_date: Indicates the date from which the offer term is effective. :type effective_date: ~datetime.datetime """ @@ -155,7 +155,7 @@ class MonetaryCommitment(OfferTermInfo): :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 + :type name: str or ~azure.mgmt.commerce.v2015_06_01_preview.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 @@ -194,7 +194,7 @@ class MonetaryCredit(OfferTermInfo): :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 + :type name: str or ~azure.mgmt.commerce.v2015_06_01_preview.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. @@ -230,9 +230,9 @@ class RateCardQueryParameters(msrest.serialization.Model): 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. + 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 @@ -274,7 +274,7 @@ class RecurringCharge(OfferTermInfo): :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 + :type name: str or ~azure.mgmt.commerce.v2015_06_01_preview.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. @@ -310,9 +310,9 @@ class ResourceRateCardInfo(msrest.serialization.Model): :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] + :type offer_terms: list[~azure.mgmt.commerce.v2015_06_01_preview.models.OfferTermInfo] :param meters: A list of meters. - :type meters: list[~azure.mgmt.commerce.models.MeterInfo] + :type meters: list[~azure.mgmt.commerce.v2015_06_01_preview.models.MeterInfo] """ _attribute_map = { @@ -366,7 +366,7 @@ class UsageAggregation(msrest.serialization.Model): :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 + :type info_fields: ~azure.mgmt.commerce.v2015_06_01_preview.models.InfoField :param instance_data: Key-value pairs of instance details represented as a string. :type instance_data: str """ @@ -415,7 +415,7 @@ 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] + :type value: list[~azure.mgmt.commerce.v2015_06_01_preview.models.UsageAggregation] :param next_link: Gets or sets the link to the next set of results. :type next_link: str """ diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/_models_py3.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/models/_models_py3.py similarity index 95% rename from sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/_models_py3.py rename to sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/models/_models_py3.py index fb0c50841d5b..a8bf9d758e4f 100644 --- a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/_models_py3.py +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/models/_models_py3.py @@ -140,7 +140,7 @@ class OfferTermInfo(msrest.serialization.Model): :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 + :type name: str or ~azure.mgmt.commerce.v2015_06_01_preview.models.OfferTermInfoEnum :param effective_date: Indicates the date from which the offer term is effective. :type effective_date: ~datetime.datetime """ @@ -176,7 +176,7 @@ class MonetaryCommitment(OfferTermInfo): :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 + :type name: str or ~azure.mgmt.commerce.v2015_06_01_preview.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 @@ -219,7 +219,7 @@ class MonetaryCredit(OfferTermInfo): :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 + :type name: str or ~azure.mgmt.commerce.v2015_06_01_preview.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. @@ -259,9 +259,9 @@ class RateCardQueryParameters(msrest.serialization.Model): 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. + 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 @@ -308,7 +308,7 @@ class RecurringCharge(OfferTermInfo): :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 + :type name: str or ~azure.mgmt.commerce.v2015_06_01_preview.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. @@ -347,9 +347,9 @@ class ResourceRateCardInfo(msrest.serialization.Model): :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] + :type offer_terms: list[~azure.mgmt.commerce.v2015_06_01_preview.models.OfferTermInfo] :param meters: A list of meters. - :type meters: list[~azure.mgmt.commerce.models.MeterInfo] + :type meters: list[~azure.mgmt.commerce.v2015_06_01_preview.models.MeterInfo] """ _attribute_map = { @@ -409,7 +409,7 @@ class UsageAggregation(msrest.serialization.Model): :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 + :type info_fields: ~azure.mgmt.commerce.v2015_06_01_preview.models.InfoField :param instance_data: Key-value pairs of instance details represented as a string. :type instance_data: str """ @@ -474,7 +474,7 @@ 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] + :type value: list[~azure.mgmt.commerce.v2015_06_01_preview.models.UsageAggregation] :param next_link: Gets or sets the link to the next set of results. :type next_link: str """ 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/v2015_06_01_preview/models/_usage_management_client_enums.py similarity index 100% rename from sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/_usage_management_client_enums.py rename to sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/models/_usage_management_client_enums.py diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/operations/__init__.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/operations/__init__.py new file mode 100644 index 000000000000..2ae232ba60e4 --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/operations/__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_aggregates_operations import UsageAggregatesOperations +from ._rate_card_operations import RateCardOperations + +__all__ = [ + 'UsageAggregatesOperations', + 'RateCardOperations', +] 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 95% 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..0634abad8a06 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 @@ -29,7 +29,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. @@ -64,7 +64,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"] @@ -97,7 +97,7 @@ def get( 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, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ResourceRateCardInfo', pipeline_response) 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/v2015_06_01_preview/operations/_usage_aggregates_operations.py similarity index 96% rename from sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/operations/_usage_aggregates_operations.py rename to sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/operations/_usage_aggregates_operations.py index deac3eb71da6..9eb030933b79 100644 --- a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/operations/_usage_aggregates_operations.py +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/v2015_06_01_preview/operations/_usage_aggregates_operations.py @@ -31,7 +31,7 @@ class UsageAggregatesOperations(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. @@ -70,14 +70,14 @@ def list( :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 + :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. :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] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.commerce.v2015_06_01_preview.models.UsageAggregationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageAggregationListResult"] @@ -133,7 +133,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_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) 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