Skip to content

Commit c64ca07

Browse files
authored
[T2] OperationsManagement (#14950)
1 parent f6a850d commit c64ca07

25 files changed

+2824
-1158
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
11
# Release History
22

3+
## 1.0.0b1 (2020-11-02)
4+
5+
This is beta preview version.
6+
7+
This version uses a next-generation code generator that introduces important breaking changes, but also important new features (like unified authentication and async programming).
8+
9+
General breaking changes
10+
11+
Credential system has been completly revamped:
12+
13+
azure.common.credentials or msrestazure.azure_active_directory instances are no longer supported, use the azure-identity classes instead: https://pypi.org/project/azure-identity/
14+
credentials parameter has been renamed credential
15+
The config attribute no longer exists on a client, configuration should be passed as kwarg. Example: MyClient(credential, subscription_id, enable_logging=True). For a complete set of supported options, see the parameters accept in init documentation of azure-core
16+
17+
You can't import a version module anymore, use __version__ instead
18+
19+
Operations that used to return a msrest.polling.LROPoller now returns a azure.core.polling.LROPoller and are prefixed with begin_.
20+
21+
Exceptions tree have been simplified and most exceptions are now azure.core.exceptions.HttpResponseError (CloudError has been removed).
22+
23+
Most of the operation kwarg have changed. Some of the most noticeable:
24+
25+
raw has been removed. Equivalent feature can be found using cls, a callback that will give access to internal HTTP response for advanced user
26+
For a complete set of supported options, see the parameters accept in Request documentation of azure-core
27+
General new features
28+
29+
Type annotations support using typing. SDKs are mypy ready.
30+
This client has now stable and official support for async. Check the aio namespace of your package to find the async client.
31+
This client now support natively tracing library like OpenCensus or OpenTelemetry. See this tracing quickstart for an overview.
32+
333
## 0.1.0 (2020-01-24)
434

535
* Initial Release

sdk/operationsmanagement/azure-mgmt-operationsmanagement/README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Microsoft Azure SDK for Python
22

3-
This is the Microsoft Azure MyService Management Client Library.
3+
This is the Microsoft Azure OperationsManagement Management Client Library.
44

55
Azure Resource Manager (ARM) is the next generation of management APIs
66
that replace the old Azure Service Management (ASM).
@@ -14,11 +14,18 @@ library.
1414
For a more complete set of Azure libraries, see the
1515
[azure sdk python release](https://aka.ms/azsdk/python/all).
1616

17+
1718
## Usage
1819

19-
For code examples, see [MyService
20-
Management](https://docs.microsoft.com/python/api/overview/azure/) on
21-
docs.microsoft.com.
20+
21+
To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt)
22+
23+
24+
25+
For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/)
26+
Code samples for this package can be found at [Operationsmanagement Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com.
27+
Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples)
28+
2229

2330
## Provide Feedback
2431

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
# coding=utf-8
22
# --------------------------------------------------------------------------
33
# Copyright (c) Microsoft Corporation. All rights reserved.
4-
# Licensed under the MIT License. See License.txt in the project root for
5-
# license information.
6-
#
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
75
# Code generated by Microsoft (R) AutoRest Code Generator.
8-
# Changes may cause incorrect behavior and will be lost if the code is
9-
# regenerated.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
107
# --------------------------------------------------------------------------
118

12-
from ._configuration import OperationsManagementClientConfiguration
139
from ._operations_management_client import OperationsManagementClient
14-
__all__ = ['OperationsManagementClient', 'OperationsManagementClientConfiguration']
15-
16-
from .version import VERSION
17-
18-
__version__ = VERSION
10+
__all__ = ['OperationsManagementClient']
1911

12+
try:
13+
from ._patch import patch_sdk # type: ignore
14+
patch_sdk()
15+
except ImportError:
16+
pass
Lines changed: 55 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,55 @@
11
# coding=utf-8
22
# --------------------------------------------------------------------------
33
# Copyright (c) Microsoft Corporation. All rights reserved.
4-
# Licensed under the MIT License. See License.txt in the project root for
5-
# license information.
6-
#
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
75
# Code generated by Microsoft (R) AutoRest Code Generator.
8-
# Changes may cause incorrect behavior and will be lost if the code is
9-
# regenerated.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
107
# --------------------------------------------------------------------------
11-
from msrestazure import AzureConfiguration
128

13-
from .version import VERSION
9+
from typing import TYPE_CHECKING
1410

11+
from azure.core.configuration import Configuration
12+
from azure.core.pipeline import policies
13+
from azure.mgmt.core.policies import ARMHttpLoggingPolicy
14+
15+
if TYPE_CHECKING:
16+
# pylint: disable=unused-import,ungrouped-imports
17+
from typing import Any
18+
19+
from azure.core.credentials import TokenCredential
20+
21+
VERSION = "unknown"
22+
23+
class OperationsManagementClientConfiguration(Configuration):
24+
"""Configuration for OperationsManagementClient.
1525
16-
class OperationsManagementClientConfiguration(AzureConfiguration):
17-
"""Configuration for OperationsManagementClient
1826
Note that all parameters used to create this instance are saved as instance
1927
attributes.
2028
21-
:param credentials: Credentials needed for the client to connect to Azure.
22-
:type credentials: :mod:`A msrestazure Credentials
23-
object<msrestazure.azure_active_directory>`
24-
:param subscription_id: Gets subscription credentials which uniquely
25-
identify Microsoft Azure subscription. The subscription ID forms part of
26-
the URI for every service call.
29+
:param credential: Credential needed for the client to connect to Azure.
30+
:type credential: ~azure.core.credentials.TokenCredential
31+
:param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.
2732
:type subscription_id: str
2833
:param provider_name: Provider name for the parent resource.
2934
:type provider_name: str
30-
:param resource_type: Resource type for the parent resource
35+
:param resource_type: Resource type for the parent resource.
3136
:type resource_type: str
3237
:param resource_name: Parent resource name.
3338
:type resource_name: str
34-
:param str base_url: Service URL
3539
"""
3640

3741
def __init__(
38-
self, credentials, subscription_id, provider_name, resource_type, resource_name, base_url=None):
39-
40-
if credentials is None:
41-
raise ValueError("Parameter 'credentials' must not be None.")
42+
self,
43+
credential, # type: "TokenCredential"
44+
subscription_id, # type: str
45+
provider_name, # type: str
46+
resource_type, # type: str
47+
resource_name, # type: str
48+
**kwargs # type: Any
49+
):
50+
# type: (...) -> None
51+
if credential is None:
52+
raise ValueError("Parameter 'credential' must not be None.")
4253
if subscription_id is None:
4354
raise ValueError("Parameter 'subscription_id' must not be None.")
4455
if provider_name is None:
@@ -47,19 +58,31 @@ def __init__(
4758
raise ValueError("Parameter 'resource_type' must not be None.")
4859
if resource_name is None:
4960
raise ValueError("Parameter 'resource_name' must not be None.")
50-
if not base_url:
51-
base_url = 'https://management.azure.com'
61+
super(OperationsManagementClientConfiguration, self).__init__(**kwargs)
5262

53-
super(OperationsManagementClientConfiguration, self).__init__(base_url)
54-
55-
# Starting Autorest.Python 4.0.64, make connection pool activated by default
56-
self.keep_alive = True
57-
58-
self.add_user_agent('azure-mgmt-operationsmanagement/{}'.format(VERSION))
59-
self.add_user_agent('Azure-SDK-For-Python')
60-
61-
self.credentials = credentials
63+
self.credential = credential
6264
self.subscription_id = subscription_id
6365
self.provider_name = provider_name
6466
self.resource_type = resource_type
6567
self.resource_name = resource_name
68+
self.api_version = "2015-11-01-preview"
69+
self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
70+
kwargs.setdefault('sdk_moniker', 'mgmt-operationsmanagement/{}'.format(VERSION))
71+
self._configure(**kwargs)
72+
73+
def _configure(
74+
self,
75+
**kwargs # type: Any
76+
):
77+
# type: (...) -> None
78+
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
79+
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
80+
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
81+
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
82+
self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)
83+
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
84+
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
85+
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
86+
self.authentication_policy = kwargs.get('authentication_policy')
87+
if self.credential and not self.authentication_policy:
88+
self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
Lines changed: 58 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
# coding=utf-8
22
# --------------------------------------------------------------------------
33
# Copyright (c) Microsoft Corporation. All rights reserved.
4-
# Licensed under the MIT License. See License.txt in the project root for
5-
# license information.
6-
#
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
75
# Code generated by Microsoft (R) AutoRest Code Generator.
8-
# Changes may cause incorrect behavior and will be lost if the code is
9-
# regenerated.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
107
# --------------------------------------------------------------------------
118

12-
from msrest.service_client import SDKClient
13-
from msrest import Serializer, Deserializer
9+
from typing import TYPE_CHECKING
10+
11+
from azure.mgmt.core import ARMPipelineClient
12+
from msrest import Deserializer, Serializer
13+
14+
if TYPE_CHECKING:
15+
# pylint: disable=unused-import,ungrouped-imports
16+
from typing import Any, Optional
17+
18+
from azure.core.credentials import TokenCredential
1419

1520
from ._configuration import OperationsManagementClientConfiguration
1621
from .operations import SolutionsOperations
@@ -20,53 +25,70 @@
2025
from . import models
2126

2227

23-
class OperationsManagementClient(SDKClient):
24-
"""Operations Management Client
28+
class OperationsManagementClient(object):
29+
"""Operations Management Client.
2530
26-
:ivar config: Configuration for client.
27-
:vartype config: OperationsManagementClientConfiguration
28-
29-
:ivar solutions: Solutions operations
30-
:vartype solutions: azure.mgmt.operationsmanagement.operations.SolutionsOperations
31-
:ivar management_associations: ManagementAssociations operations
32-
:vartype management_associations: azure.mgmt.operationsmanagement.operations.ManagementAssociationsOperations
33-
:ivar management_configurations: ManagementConfigurations operations
34-
:vartype management_configurations: azure.mgmt.operationsmanagement.operations.ManagementConfigurationsOperations
31+
:ivar solutions: SolutionsOperations operations
32+
:vartype solutions: operations_management_client.operations.SolutionsOperations
33+
:ivar management_associations: ManagementAssociationsOperations operations
34+
:vartype management_associations: operations_management_client.operations.ManagementAssociationsOperations
35+
:ivar management_configurations: ManagementConfigurationsOperations operations
36+
:vartype management_configurations: operations_management_client.operations.ManagementConfigurationsOperations
3537
:ivar operations: Operations operations
36-
:vartype operations: azure.mgmt.operationsmanagement.operations.Operations
37-
38-
:param credentials: Credentials needed for the client to connect to Azure.
39-
:type credentials: :mod:`A msrestazure Credentials
40-
object<msrestazure.azure_active_directory>`
41-
:param subscription_id: Gets subscription credentials which uniquely
42-
identify Microsoft Azure subscription. The subscription ID forms part of
43-
the URI for every service call.
38+
:vartype operations: operations_management_client.operations.Operations
39+
:param credential: Credential needed for the client to connect to Azure.
40+
:type credential: ~azure.core.credentials.TokenCredential
41+
:param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.
4442
:type subscription_id: str
4543
:param provider_name: Provider name for the parent resource.
4644
:type provider_name: str
47-
:param resource_type: Resource type for the parent resource
45+
:param resource_type: Resource type for the parent resource.
4846
:type resource_type: str
4947
:param resource_name: Parent resource name.
5048
:type resource_name: str
5149
:param str base_url: Service URL
50+
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
5251
"""
5352

5453
def __init__(
55-
self, credentials, subscription_id, provider_name, resource_type, resource_name, base_url=None):
56-
57-
self.config = OperationsManagementClientConfiguration(credentials, subscription_id, provider_name, resource_type, resource_name, base_url)
58-
super(OperationsManagementClient, self).__init__(self.config.credentials, self.config)
54+
self,
55+
credential, # type: "TokenCredential"
56+
subscription_id, # type: str
57+
provider_name, # type: str
58+
resource_type, # type: str
59+
resource_name, # type: str
60+
base_url=None, # type: Optional[str]
61+
**kwargs # type: Any
62+
):
63+
# type: (...) -> None
64+
if not base_url:
65+
base_url = 'https://management.azure.com'
66+
self._config = OperationsManagementClientConfiguration(credential, subscription_id, provider_name, resource_type, resource_name, **kwargs)
67+
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
5968

6069
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
61-
self.api_version = '2015-11-01-preview'
6270
self._serialize = Serializer(client_models)
71+
self._serialize.client_side_validation = False
6372
self._deserialize = Deserializer(client_models)
6473

6574
self.solutions = SolutionsOperations(
66-
self._client, self.config, self._serialize, self._deserialize)
75+
self._client, self._config, self._serialize, self._deserialize)
6776
self.management_associations = ManagementAssociationsOperations(
68-
self._client, self.config, self._serialize, self._deserialize)
77+
self._client, self._config, self._serialize, self._deserialize)
6978
self.management_configurations = ManagementConfigurationsOperations(
70-
self._client, self.config, self._serialize, self._deserialize)
79+
self._client, self._config, self._serialize, self._deserialize)
7180
self.operations = Operations(
72-
self._client, self.config, self._serialize, self._deserialize)
81+
self._client, self._config, self._serialize, self._deserialize)
82+
83+
def close(self):
84+
# type: () -> None
85+
self._client.close()
86+
87+
def __enter__(self):
88+
# type: () -> OperationsManagementClient
89+
self._client.__enter__()
90+
return self
91+
92+
def __exit__(self, *exc_details):
93+
# type: (Any) -> None
94+
self._client.__exit__(*exc_details)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
# regenerated.
1010
# --------------------------------------------------------------------------
1111

12-
VERSION = "0.1.0"
12+
VERSION = "1.0.0b1"
1313

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) AutoRest Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
from ._operations_management_client import OperationsManagementClient
10+
__all__ = ['OperationsManagementClient']

0 commit comments

Comments
 (0)