Skip to content

Commit

Permalink
[AutoPR] resources/resource-manager (#5555)
Browse files Browse the repository at this point in the history
* Generated from 621a104fcefa006dfdef9a4bb62a49f5d5280eeb (#5537)

Add descriptions.

* ChangeLog

* Re-record with new API

* Remove log from tests

* Generated from 59e4ec44f32e3b03bc55a06a3f6ebba140640e01 (#5753)

Add additional ExportTemplate options

* Record providers

* Full regeneration with Autorest Python v4

* Support multi-client SDK + no subcription_id SDK

* Update Policy tests

* 3.0.0
  • Loading branch information
AutorestCI authored and lmazuel committed Jun 13, 2019
1 parent a5624aa commit 15dc31f
Show file tree
Hide file tree
Showing 846 changed files with 36,191 additions and 30,380 deletions.
33 changes: 32 additions & 1 deletion scripts/multiapi_init_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import shutil
from pathlib import Path

from typing import List, Tuple, Any
from typing import List, Tuple, Any, Union

try:
import msrestazure
Expand Down Expand Up @@ -341,7 +341,33 @@ def find_client_file(package_name, module_name):
return next(module_path.glob("*_client.py"))


def patch_import(file_path: Union[str, Path]) -> None:
"""If multi-client package, we need to patch import to be
from ..version
and not
from .version
That should probably means those files should become a template, but since right now
it's literally one dot, let's do it the raw way.
"""
# That's a dirty hack, maybe it's worth making configuration a template?
with open(file_path, "rb") as read_fd:
conf_bytes: bytes = read_fd.read()
conf_bytes = conf_bytes.replace(
b" .version", b" ..version"
) # Just a dot right? Worth its own template for that? :)
with open(file_path, "wb") as write_fd:
write_fd.write(conf_bytes)


def has_subscription_id(client_class):
return "subscription_id" in inspect.signature(client_class).parameters


def main(input_str):
# The only known multi-client package right now is azure-mgmt-resource
is_multi_client_package = "#" in input_str

package_name, module_name = parse_input(input_str)
versioned_modules = get_versioned_modules(package_name, module_name)
versioned_operations_dict, mod_to_api_version = build_operation_meta(
Expand All @@ -359,6 +385,10 @@ def main(input_str):
shutil.copy(
client_folder / last_api_version / "__init__.py", client_folder / "__init__.py"
)
if is_multi_client_package:
_LOGGER.warning("Patching multi-api client basic files")
patch_import(client_folder / "_configuration.py")
patch_import(client_folder / "__init__.py")

versionned_mod = versioned_modules[last_api_version]
client_name = get_client_class_name_from_module(versionned_mod)
Expand Down Expand Up @@ -401,6 +431,7 @@ def main(input_str):
conf = {
"api_version_modules": sorted(mod_to_api_version.keys()),
"client_name": client_name,
"has_subscription_id": has_subscription_id(client_class),
"module_name": module_name,
"operations": versioned_operations_dict,
"mixin_operations": mixin_operations,
Expand Down
7 changes: 4 additions & 3 deletions scripts/templates/_multiapi_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

from azure.profiles import KnownProfiles, ProfileDefinition
from azure.profiles.multiapiclient import MultiApiClientMixin
from .version import VERSION
from ._configuration import {{ client_name }}Configuration
{% if mixin_operations %}from ._operations_mixin import {{ client_name }}OperationsMixin{% endif %}

Expand All @@ -36,10 +35,12 @@ class {{ client_name }}({% if mixin_operations %}{{ client_name }}OperationsMixi
:param credentials: Credentials needed for the client to connect to Azure.
:type credentials: :mod:`A msrestazure Credentials
object<msrestazure.azure_active_directory>`
{%- if has_subscription_id %}
:param subscription_id: Subscription credentials which uniquely identify
Microsoft Azure subscription. The subscription ID forms part of the URI
for every service call.
:type subscription_id: str
{%- endif %}
:param str api_version: API version to use if no profile is provided, or if
missing in profile.
:param str base_url: Service URL
Expand All @@ -59,8 +60,8 @@ class {{ client_name }}({% if mixin_operations %}{{ client_name }}OperationsMixi
_PROFILE_TAG + " latest"
)

def __init__(self, credentials, subscription_id, api_version=None, base_url=None, profile=KnownProfiles.default):
self.config = {{ client_name }}Configuration(credentials, subscription_id, base_url)
def __init__(self, credentials{%- if has_subscription_id %}, subscription_id{% endif %}, api_version=None, base_url=None, profile=KnownProfiles.default):
self.config = {{ client_name }}Configuration(credentials{%- if has_subscription_id %}, subscription_id{% endif %}, base_url)
super({{ client_name }}, self).__init__(
credentials,
self.config,
Expand Down
35 changes: 35 additions & 0 deletions sdk/resources/azure-mgmt-resource/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,41 @@
Release History
===============

3.0.0 (2019-06-13)
++++++++++++++++++

**Features**

- Model Provider has a new parameter registration_policy
- Model ProviderResourceType has a new parameter capabilities
- Model DeploymentOperationProperties has a new parameter duration
- Model DeploymentPropertiesExtended has a new parameter duration
- Added operation DeploymentOperations.get_at_management_group_scope
- Added operation DeploymentOperations.list_at_management_group_scope
- Added operation DeploymentsOperations.export_template_at_management_group_scope
- Added operation DeploymentsOperations.create_or_update_at_management_group_scope
- Added operation DeploymentsOperations.list_at_management_group_scope
- Added operation DeploymentsOperations.get_at_management_group_scope
- Added operation DeploymentsOperations.check_existence_at_management_group_scope
- Added operation DeploymentsOperations.cancel_at_management_group_scope
- Added operation DeploymentsOperations.delete_at_management_group_scope
- Added operation DeploymentsOperations.validate_at_management_group_scope

- Policy default API version is now 2018-05-01

**General Breaking changes**

This version uses a next-generation code generator that *might* introduce breaking changes if you were importing from the v20xx_yy_zz API folders.
In summary, some modules were incorrectly visible/importable and have been renamed. This fixed several issues caused by usage of classes that were not supposed to be used in the first place.

The following applies for all client and namespaces, we take ResourceManagementClient and "resources" as example:
- ResourceManagementClient cannot be imported from `azure.mgmt.resource.resources.v20xx_yy_zz.resource_management_client` anymore (import from `azure.mgmt.resource.resources.v20xx_yy_zz` works like before)
- ResourceManagementClientConfiguration import has been moved from `azure.mgmt.resource.resources.v20xx_yy_zz.resource_management_client` to `azure.mgmt.resource.resources.v20xx_yy_zz`
- A model `MyClass` from a "models" sub-module cannot be imported anymore using `azure.mgmt.resource.resources.v20xx_yy_zz.models.my_class` (import from `azure.mgmt.resource.resources.v20xx_yy_zz.models` works like before)
- An operation class `MyClassOperations` from an `operations` sub-module cannot be imported anymore using `azure.mgmt.resource.resources.v20xx_yy_zz.operations.my_class_operations` (import from `azure.mgmt.resource.resources.v20xx_yy_zz.operations` works like before)

Last but not least, HTTP connection pooling is now enabled by default. You should always use a client as a context manager, or call close(), or use no more than one client per process.

2.2.0 (2019-05-23)
++++++++++++++++++

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
# coding=utf-8
# 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 .feature_client import FeatureClient
from ._configuration import FeatureClientConfiguration
from ._feature_client import FeatureClient
__all__ = ['FeatureClient', 'FeatureClientConfiguration']

from ..version import VERSION

__version__ = VERSION

__all__ = ['FeatureClient']
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# 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 msrestazure import AzureConfiguration

from ..version import VERSION


class FeatureClientConfiguration(AzureConfiguration):
"""Configuration for FeatureClient
Note that all parameters used to create this instance are saved as instance
attributes.
:param credentials: Credentials needed for the client to connect to Azure.
:type credentials: :mod:`A msrestazure Credentials
object<msrestazure.azure_active_directory>`
:param subscription_id: The ID of the target subscription.
:type subscription_id: str
:param str base_url: Service URL
"""

def __init__(
self, credentials, subscription_id, base_url=None):

if credentials is None:
raise ValueError("Parameter 'credentials' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")
if not base_url:
base_url = 'https://management.azure.com'

super(FeatureClientConfiguration, self).__init__(base_url)

# Starting Autorest.Python 4.0.64, make connection pool activated by default
self.keep_alive = True

self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION))
self.add_user_agent('Azure-SDK-For-Python')

self.credentials = credentials
self.subscription_id = subscription_id
Original file line number Diff line number Diff line change
Expand Up @@ -11,60 +11,33 @@

from msrest.service_client import SDKClient
from msrest import Serializer, Deserializer
from msrestazure import AzureConfiguration

from azure.profiles import KnownProfiles, ProfileDefinition
from azure.profiles.multiapiclient import MultiApiClientMixin
from ..version import VERSION
from ._configuration import FeatureClientConfiguration
from ._operations_mixin import FeatureClientOperationsMixin


class FeatureClientConfiguration(AzureConfiguration):
"""Configuration for FeatureClient
Note that all parameters used to create this instance are saved as instance
attributes.
:param credentials: Credentials needed for the client to connect to Azure.
:type credentials: :mod:`A msrestazure Credentials
object<msrestazure.azure_active_directory>`
:param subscription_id: The ID of the target subscription.
:type subscription_id: str
:param api_version: The API version to use for this operation.
:type api_version: str
:param str base_url: Service URL
"""

def __init__(
self, credentials, subscription_id, api_version='2015-12-01', base_url=None):

if credentials is None:
raise ValueError("Parameter 'credentials' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")
if api_version is not None and not isinstance(api_version, str):
raise TypeError("Optional parameter 'api_version' must be str.")
if not base_url:
base_url = 'https://management.azure.com'

super(FeatureClientConfiguration, self).__init__(base_url)

self.add_user_agent('featureclient/{}'.format(VERSION))
self.add_user_agent('Azure-SDK-For-Python')

self.credentials = credentials
self.subscription_id = subscription_id
self.api_version = api_version


class FeatureClient(MultiApiClientMixin, SDKClient):
class FeatureClient(FeatureClientOperationsMixin, MultiApiClientMixin, SDKClient):
"""Azure Feature Exposure Control (AFEC) provides a mechanism for the resource providers to control feature exposure to users. Resource providers typically use this mechanism to provide public/private preview for new features prior to making them generally available. Users need to explicitly register for AFEC features to get access to such functionality.
This ready contains multiple API versions, to help you deal with all Azure clouds
(Azure Stack, Azure Government, Azure China, etc.).
By default, uses latest API version available on public Azure.
For production, you should stick a particular api-version and/or profile.
The profile sets a mapping between the operation group and an API version.
The api-version parameter sets the default API version if the operation
group is not described in the profile.
:ivar config: Configuration for client.
:vartype config: FeatureClientConfiguration
:param credentials: Credentials needed for the client to connect to Azure.
:type credentials: :mod:`A msrestazure Credentials
object<msrestazure.azure_active_directory>`
:param subscription_id: The ID of the target subscription.
:param subscription_id: Subscription credentials which uniquely identify
Microsoft Azure subscription. The subscription ID forms part of the URI
for every service call.
:type subscription_id: str
:param str api_version: API version to use if no profile is provided, or if
missing in profile.
Expand All @@ -77,22 +50,20 @@ class FeatureClient(MultiApiClientMixin, SDKClient):
_PROFILE_TAG = "azure.mgmt.resource.features.FeatureClient"
LATEST_PROFILE = ProfileDefinition({
_PROFILE_TAG: {
None: DEFAULT_API_VERSION
None: DEFAULT_API_VERSION,
}},
_PROFILE_TAG + " latest"
)

def __init__(self, credentials, subscription_id, api_version=None, base_url=None, profile=KnownProfiles.default):
self.config = FeatureClientConfiguration(credentials, subscription_id, api_version, base_url)
self.config = FeatureClientConfiguration(credentials, subscription_id, base_url)
super(FeatureClient, self).__init__(
credentials,
self.config,
api_version=api_version,
profile=profile
)

############ Generated from here ############

@classmethod
def _models_dict(cls, api_version):
return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 msrest import Serializer, Deserializer


class FeatureClientOperationsMixin(object):


def list_operations(self, custom_headers=None, raw=False, **operation_config):
"""Lists all of the available Microsoft.Features REST API operations.
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param operation_config: :ref:`Operation configuration
overrides<msrest:optionsforoperations>`.
:return: An iterator like instance of Operation
:rtype:
~azure.mgmt.resource.features.v2015_12_01.models.OperationPaged[~azure.mgmt.resource.features.v2015_12_01.models.Operation]
:raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
"""
api_version = self._get_api_version('list_operations')
if api_version == '2015-12-01':
from .v2015_12_01.operations import FeatureClientOperationsMixin as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
mixin_instance = OperationClass()
mixin_instance._client = self._client
mixin_instance.config = self.config
mixin_instance._serialize = Serializer(self._models_dict(api_version))
mixin_instance._deserialize = Deserializer(self._models_dict(api_version))
return mixin_instance.list_operations(custom_headers, raw, **operation_config)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# coding=utf-8
# 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_12_01.models import *
from .v2015_12_01.models import *
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
# regenerated.
# --------------------------------------------------------------------------

from .feature_client import FeatureClient
from .version import VERSION
from ._configuration import FeatureClientConfiguration
from ._feature_client import FeatureClient
__all__ = ['FeatureClient', 'FeatureClientConfiguration']

__all__ = ['FeatureClient']
from .version import VERSION

__version__ = VERSION

Loading

0 comments on commit 15dc31f

Please sign in to comment.