Skip to content

Commit

Permalink
[AutoPR] dns/resource-manager (Azure#2874)
Browse files Browse the repository at this point in the history
* MultiAPI DNS client

* Generated from 702b6047761782d41a490bd89b5585b6264fd91c (Azure#2873)

DNS multi-api Python

* DNS packaging
  • Loading branch information
AutorestCI authored and lmazuel committed Jul 5, 2018
1 parent d474dfc commit cc37a54
Show file tree
Hide file tree
Showing 87 changed files with 3,665 additions and 220 deletions.
36 changes: 36 additions & 0 deletions azure-mgmt-dns/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,42 @@
Release History
===============

2.0.0rc2 (2018-07-05)
+++++++++++++++++++++

**Features**

- Client class can be used as a context manager to keep the underlying HTTP session open for performance

**General Breaking changes**

This version uses a next-generation code generator that *might* introduce breaking changes.

- Model signatures now use only keyword-argument syntax. All positional arguments must be re-written as keyword-arguments.
To keep auto-completion in most cases, models are now generated for Python 2 and Python 3. Python 3 uses the "*" syntax for keyword-only arguments.
- Enum types now use the "str" mixin (class AzureEnum(str, Enum)) to improve the behavior when unrecognized enum values are encountered.
While this is not a breaking change, the distinctions are important, and are documented here:
https://docs.python.org/3/library/enum.html#others
At a glance:

- "is" should not be used at all.
- "format" will return the string value, where "%s" string formatting will return `NameOfEnum.stringvalue`. Format syntax should be prefered.

- New Long Running Operation:

- Return type changes from `msrestazure.azure_operation.AzureOperationPoller` to `msrest.polling.LROPoller`. External API is the same.
- Return type is now **always** a `msrest.polling.LROPoller`, regardless of the optional parameters used.
- The behavior has changed when using `raw=True`. Instead of returning the initial call result as `ClientRawResponse`,
without polling, now this returns an LROPoller. After polling, the final resource will be returned as a `ClientRawResponse`.
- New `polling` parameter. The default behavior is `Polling=True` which will poll using ARM algorithm. When `Polling=False`,
the response of the initial call will be returned without polling.
- `polling` parameter accepts instances of subclasses of `msrest.polling.PollingMethod`.
- `add_done_callback` will no longer raise if called after polling is finished, but will instead execute the callback right away.

**Bugfixes**

- Compatibility of the sdist with wheel 0.31.0

2.0.0rc1 (2018-03-14)
+++++++++++++++++++++

Expand Down
114 changes: 87 additions & 27 deletions azure-mgmt-dns/azure/mgmt/dns/dns_management_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
# regenerated.
# --------------------------------------------------------------------------

from msrest.service_client import ServiceClient
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 .operations.record_sets_operations import RecordSetsOperations
from .operations.zones_operations import ZonesOperations
from . import models


class DnsManagementClientConfiguration(AzureConfiguration):
Expand All @@ -26,8 +26,7 @@ class DnsManagementClientConfiguration(AzureConfiguration):
: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: Specifies the Azure subscription ID, which
uniquely identifies the Microsoft Azure subscription.
:param subscription_id: The Microsoft Azure subscription ID.
:type subscription_id: str
:param str base_url: Service URL
"""
Expand All @@ -51,38 +50,99 @@ def __init__(
self.subscription_id = subscription_id


class DnsManagementClient(object):
class DnsManagementClient(MultiApiClientMixin, SDKClient):
"""The DNS Management Client.
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: DnsManagementClientConfiguration
:ivar record_sets: RecordSets operations
:vartype record_sets: azure.mgmt.dns.operations.RecordSetsOperations
:ivar zones: Zones operations
:vartype zones: azure.mgmt.dns.operations.ZonesOperations
: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: Specifies the Azure subscription ID, which
uniquely identifies the Microsoft Azure subscription.
:param subscription_id: The Microsoft Azure subscription ID.
:type subscription_id: str
:param str api_version: API version to use if no profile is provided, or if
missing in profile.
:param str base_url: Service URL
:param profile: A profile definition, from KnownProfiles to dict.
:type profile: azure.profiles.KnownProfiles
"""

def __init__(
self, credentials, subscription_id, base_url=None):
DEFAULT_API_VERSION = '2018-03-01-preview'
_PROFILE_TAG = "azure.mgmt.dns.DnsManagementClient"
LATEST_PROFILE = ProfileDefinition({
_PROFILE_TAG: {
None: DEFAULT_API_VERSION
}},
_PROFILE_TAG + " latest"
)

def __init__(self, credentials, subscription_id, api_version=None, base_url=None, profile=KnownProfiles.default):
self.config = DnsManagementClientConfiguration(credentials, subscription_id, base_url)
self._client = ServiceClient(self.config.credentials, self.config)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self.api_version = '2018-03-01-preview'
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)

self.record_sets = RecordSetsOperations(
self._client, self.config, self._serialize, self._deserialize)
self.zones = ZonesOperations(
self._client, self.config, self._serialize, self._deserialize)
super(DnsManagementClient, 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)}

@classmethod
def models(cls, api_version=DEFAULT_API_VERSION):
"""Module depends on the API version:
* 2016-04-01: :mod:`v2016_04_01.models<azure.mgmt.dns.v2016_04_01.models>`
* 2018-03-01-preview: :mod:`v2018_03_01_preview.models<azure.mgmt.dns.v2018_03_01_preview.models>`
"""
if api_version == '2016-04-01':
from .v2016_04_01 import models
return models
elif api_version == '2018-03-01-preview':
from .v2018_03_01_preview import models
return models
raise NotImplementedError("APIVersion {} is not available".format(api_version))

@property
def record_sets(self):
"""Instance depends on the API version:
* 2016-04-01: :class:`RecordSetsOperations<azure.mgmt.dns.v2016_04_01.operations.RecordSetsOperations>`
* 2018-03-01-preview: :class:`RecordSetsOperations<azure.mgmt.dns.v2018_03_01_preview.operations.RecordSetsOperations>`
"""
api_version = self._get_api_version('record_sets')
if api_version == '2016-04-01':
from .v2016_04_01.operations import RecordSetsOperations as OperationClass
elif api_version == '2018-03-01-preview':
from .v2018_03_01_preview.operations import RecordSetsOperations as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))

@property
def zones(self):
"""Instance depends on the API version:
* 2016-04-01: :class:`ZonesOperations<azure.mgmt.dns.v2016_04_01.operations.ZonesOperations>`
* 2018-03-01-preview: :class:`ZonesOperations<azure.mgmt.dns.v2018_03_01_preview.operations.ZonesOperations>`
"""
api_version = self._get_api_version('zones')
if api_version == '2016-04-01':
from .v2016_04_01.operations import ZonesOperations as OperationClass
elif api_version == '2018-03-01-preview':
from .v2018_03_01_preview.operations import ZonesOperations as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
7 changes: 7 additions & 0 deletions azure-mgmt-dns/azure/mgmt/dns/models.py
Original file line number Diff line number Diff line change
@@ -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 .v2018_03_01_preview.models import *
56 changes: 0 additions & 56 deletions azure-mgmt-dns/azure/mgmt/dns/models/__init__.py

This file was deleted.

18 changes: 18 additions & 0 deletions azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

from .dns_management_client import DnsManagementClient
from .version import VERSION

__all__ = ['DnsManagementClient']

__version__ = VERSION

88 changes: 88 additions & 0 deletions azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/dns_management_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# 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.service_client import SDKClient
from msrest import Serializer, Deserializer
from msrestazure import AzureConfiguration
from .version import VERSION
from .operations.record_sets_operations import RecordSetsOperations
from .operations.zones_operations import ZonesOperations
from . import models


class DnsManagementClientConfiguration(AzureConfiguration):
"""Configuration for DnsManagementClient
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: Specifies the Azure subscription ID, which
uniquely identifies the Microsoft Azure 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(DnsManagementClientConfiguration, self).__init__(base_url)

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

self.credentials = credentials
self.subscription_id = subscription_id


class DnsManagementClient(SDKClient):
"""The DNS Management Client.
:ivar config: Configuration for client.
:vartype config: DnsManagementClientConfiguration
:ivar record_sets: RecordSets operations
:vartype record_sets: azure.mgmt.dns.v2016_04_01.operations.RecordSetsOperations
:ivar zones: Zones operations
:vartype zones: azure.mgmt.dns.v2016_04_01.operations.ZonesOperations
: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: Specifies the Azure subscription ID, which
uniquely identifies the Microsoft Azure subscription.
:type subscription_id: str
:param str base_url: Service URL
"""

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

self.config = DnsManagementClientConfiguration(credentials, subscription_id, base_url)
super(DnsManagementClient, self).__init__(self.config.credentials, self.config)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self.api_version = '2016-04-01'
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)

self.record_sets = RecordSetsOperations(
self._client, self.config, self._serialize, self._deserialize)
self.zones = ZonesOperations(
self._client, self.config, self._serialize, self._deserialize)
Loading

0 comments on commit cc37a54

Please sign in to comment.