Skip to content

Commit

Permalink
CodeGen from PR 15007 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
[python]track2 config for some services (Azure#15007)

* consumption

* delete track1 config
  • Loading branch information
SDKAuto committed Jun 29, 2021
1 parent 57e9798 commit 242d234
Show file tree
Hide file tree
Showing 27 changed files with 954 additions and 99 deletions.
1 change: 1 addition & 0 deletions sdk/commerce/azure-mgmt-commerce/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include _meta.json
recursive-include tests *.py *.yaml
include *.md
include azure/__init__.py
Expand Down
11 changes: 11 additions & 0 deletions sdk/commerce/azure-mgmt-commerce/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"autorest": "3.4.2",
"use": [
"@autorest/[email protected]",
"@autorest/[email protected]"
],
"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/[email protected] --use=@autorest/[email protected] --version=3.4.2",
"readme": "specification/commerce/resource-manager/readme.md"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
# --------------------------------------------------------------------------

from ._usage_management_client import UsageManagementClient
from ._version import VERSION

__version__ = VERSION
__all__ = ['UsageManagementClient']

try:
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -20,7 +22,6 @@

from azure.core.credentials import TokenCredential


class UsageManagementClientConfiguration(Configuration):
"""Configuration for UsageManagementClient.
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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<azure.mgmt.commerce.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<azure.mgmt.commerce.v2015_06_01_preview.operations.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<azure.mgmt.commerce.v2015_06_01_preview.operations.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)
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,7 +20,6 @@
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential


class UsageManagementClientConfiguration(Configuration):
"""Configuration for UsageManagementClient.
Expand All @@ -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.")
Expand All @@ -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(
Expand Down
Loading

0 comments on commit 242d234

Please sign in to comment.