Skip to content

Commit 4794bdf

Browse files
author
SDKAuto
committed
CodeGen from PR 31303 in Azure/azure-rest-api-specs
Merge 7037b9349a8b7018399ba12d1ec2c1d6d375c7ad into 4e3820497caa29ed0efada28a38cb4292cea9d55
1 parent dc2e258 commit 4794bdf

File tree

99 files changed

+1820
-9479
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+1820
-9479
lines changed

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

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

33
This is the Microsoft Azure Extended Location Management Client Library.
4-
This package has been tested with Python 3.7+.
4+
This package has been tested with Python 3.8+.
55
For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all).
66

77
## _Disclaimer_
@@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For
1212

1313
### Prerequisites
1414

15-
- Python 3.7+ is required to use this package.
15+
- Python 3.8+ is required to use this package.
1616
- [Azure subscription](https://azure.microsoft.com/free/)
1717

1818
### Install the package
@@ -45,8 +45,9 @@ client = CustomLocations(credential=DefaultAzureCredential(), subscription_id=su
4545

4646
## Examples
4747

48-
49-
Code samples for this package can be found at [Extended Location Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com and [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples)
48+
Code samples for this package can be found at:
49+
- [Search Extended Location Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com
50+
- [Azure Python Mgmt SDK Samples Repo](https://aka.ms/azsdk/python/mgmt/samples)
5051

5152

5253
## Troubleshooting
@@ -58,6 +59,3 @@ Code samples for this package can be found at [Extended Location Management](htt
5859
If you encounter any bugs or have suggestions, please file an issue in the
5960
[Issues](https://github.com/Azure/azure-sdk-for-python/issues)
6061
section of the project.
61-
62-
63-
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-extendedlocation%2FREADME.png)
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"commit": "2f17a9028f33fe80cf1ae62642fe9ed63c0a17f7",
2+
"commit": "ec167d8e363e98893b9a1d535a39fa33ed2e530c",
33
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4-
"autorest": "3.9.2",
4+
"autorest": "3.10.2",
55
"use": [
6-
"@autorest/python@6.4.0",
7-
"@autorest/modelerfour@4.24.3"
6+
"@autorest/python@6.19.0",
7+
"@autorest/modelerfour@4.27.0"
88
],
9-
"autorest_command": "autorest specification/extendedlocation/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.4.0 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False",
9+
"autorest_command": "autorest specification/extendedlocation/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False",
1010
"readme": "specification/extendedlocation/resource-manager/readme.md"
1111
}

sdk/extendedlocation/azure-mgmt-extendedlocation/azure/mgmt/extendedlocation/__init__.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,20 @@
77
# --------------------------------------------------------------------------
88

99
from ._custom_locations import CustomLocations
10-
__all__ = ['CustomLocations']
10+
from ._version import VERSION
11+
12+
__version__ = VERSION
1113

1214
try:
13-
from ._patch import patch_sdk # type: ignore
14-
patch_sdk()
15+
from ._patch import __all__ as _patch_all
16+
from ._patch import * # pylint: disable=unused-wildcard-import
1517
except ImportError:
16-
pass
18+
_patch_all = []
19+
from ._patch import patch_sdk as _patch_sdk
1720

18-
from ._version import VERSION
21+
__all__ = [
22+
"CustomLocations",
23+
]
24+
__all__.extend([p for p in _patch_all if p not in __all__])
1925

20-
__version__ = VERSION
26+
_patch_sdk()
Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
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
# --------------------------------------------------------------------------
8+
119
from typing import Any, TYPE_CHECKING
1210

13-
from azure.core.configuration import Configuration
1411
from azure.core.pipeline import policies
1512
from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy
1613

@@ -20,7 +17,8 @@
2017
# pylint: disable=unused-import,ungrouped-imports
2118
from azure.core.credentials import TokenCredential
2219

23-
class CustomLocationsConfiguration(Configuration):
20+
21+
class CustomLocationsConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
2422
"""Configuration for CustomLocations.
2523
2624
Note that all parameters used to create this instance are saved as instance
@@ -30,38 +28,38 @@ class CustomLocationsConfiguration(Configuration):
3028
:type credential: ~azure.core.credentials.TokenCredential
3129
:param subscription_id: The ID of the target subscription. Required.
3230
:type subscription_id: str
31+
:keyword api_version: Api Version. Default value is "2021-08-31-preview". Note that overriding
32+
this default value may result in unsupported behavior.
33+
:paramtype api_version: str
3334
"""
3435

35-
def __init__(
36-
self,
37-
credential: "TokenCredential",
38-
subscription_id: str,
39-
**kwargs: Any
40-
):
36+
def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None:
37+
api_version: str = kwargs.pop("api_version", "2021-08-31-preview")
38+
4139
if credential is None:
4240
raise ValueError("Parameter 'credential' must not be None.")
4341
if subscription_id is None:
4442
raise ValueError("Parameter 'subscription_id' must not be None.")
45-
super(CustomLocationsConfiguration, self).__init__(**kwargs)
4643

4744
self.credential = credential
4845
self.subscription_id = subscription_id
49-
self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
50-
kwargs.setdefault('sdk_moniker', 'azure-mgmt-extendedlocation/{}'.format(VERSION))
46+
self.api_version = api_version
47+
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
48+
kwargs.setdefault("sdk_moniker", "mgmt-extendedlocation/{}".format(VERSION))
49+
self.polling_interval = kwargs.get("polling_interval", 30)
5150
self._configure(**kwargs)
5251

53-
def _configure(
54-
self,
55-
**kwargs: Any
56-
):
57-
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
58-
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
59-
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
60-
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
61-
self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)
62-
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
63-
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
64-
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
65-
self.authentication_policy = kwargs.get('authentication_policy')
52+
def _configure(self, **kwargs: Any) -> None:
53+
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
54+
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
55+
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
56+
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
57+
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
58+
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
59+
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
60+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
61+
self.authentication_policy = kwargs.get("authentication_policy")
6662
if self.credential and not self.authentication_policy:
67-
self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)
63+
self.authentication_policy = ARMChallengeAuthenticationPolicy(
64+
self.credential, *self.credential_scopes, **kwargs
65+
)
Lines changed: 77 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,144 +1,118 @@
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 typing import Any, Optional, TYPE_CHECKING
9+
from copy import deepcopy
10+
from typing import Any, TYPE_CHECKING
11+
from typing_extensions import Self
1312

13+
from azure.core.pipeline import policies
14+
from azure.core.rest import HttpRequest, HttpResponse
1415
from azure.mgmt.core import ARMPipelineClient
15-
from azure.profiles import KnownProfiles, ProfileDefinition
16-
from azure.profiles.multiapiclient import MultiApiClientMixin
16+
from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy
1717

18+
from . import models as _models
1819
from ._configuration import CustomLocationsConfiguration
1920
from ._serialization import Deserializer, Serializer
21+
from .operations import CustomLocationsOperations, ResourceSyncRulesOperations
2022

2123
if TYPE_CHECKING:
2224
# pylint: disable=unused-import,ungrouped-imports
2325
from azure.core.credentials import TokenCredential
2426

25-
class _SDKClient(object):
26-
def __init__(self, *args, **kwargs):
27-
"""This is a fake class to support current implemetation of MultiApiClientMixin."
28-
Will be removed in final version of multiapi azure-core based client
29-
"""
30-
pass
3127

32-
class CustomLocations(MultiApiClientMixin, _SDKClient):
28+
class CustomLocations: # pylint: disable=client-accepts-api-version-keyword
3329
"""The customLocations Rest API spec.
3430
35-
This ready contains multiple API versions, to help you deal with all of the Azure clouds
36-
(Azure Stack, Azure Government, Azure China, etc.).
37-
By default, it uses the latest API version available on public Azure.
38-
For production, you should stick to a particular api-version and/or profile.
39-
The profile sets a mapping between an operation group and its API version.
40-
The api-version parameter sets the default API version if the operation
41-
group is not described in the profile.
42-
31+
:ivar custom_locations: CustomLocationsOperations operations
32+
:vartype custom_locations: azure.mgmt.extendedlocation.operations.CustomLocationsOperations
33+
:ivar resource_sync_rules: ResourceSyncRulesOperations operations
34+
:vartype resource_sync_rules:
35+
azure.mgmt.extendedlocation.operations.ResourceSyncRulesOperations
4336
:param credential: Credential needed for the client to connect to Azure. Required.
4437
:type credential: ~azure.core.credentials.TokenCredential
4538
:param subscription_id: The ID of the target subscription. Required.
4639
:type subscription_id: str
47-
:param api_version: API version to use if no profile is provided, or if missing in profile.
48-
:type api_version: str
49-
:param base_url: Service URL
40+
:param base_url: Service URL. Default value is "https://management.azure.com".
5041
:type base_url: str
51-
:param profile: A profile definition, from KnownProfiles to dict.
52-
:type profile: azure.profiles.KnownProfiles
53-
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
42+
:keyword api_version: Api Version. Default value is "2021-08-31-preview". Note that overriding
43+
this default value may result in unsupported behavior.
44+
:paramtype api_version: str
45+
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
46+
Retry-After header is present.
5447
"""
5548

56-
DEFAULT_API_VERSION = '2021-08-15'
57-
_PROFILE_TAG = "azure.mgmt.extendedlocation.CustomLocations"
58-
LATEST_PROFILE = ProfileDefinition({
59-
_PROFILE_TAG: {
60-
None: DEFAULT_API_VERSION,
61-
}},
62-
_PROFILE_TAG + " latest"
63-
)
64-
6549
def __init__(
6650
self,
6751
credential: "TokenCredential",
6852
subscription_id: str,
69-
api_version: Optional[str]=None,
7053
base_url: str = "https://management.azure.com",
71-
profile: KnownProfiles=KnownProfiles.default,
7254
**kwargs: Any
73-
):
74-
self._config = CustomLocationsConfiguration(credential, subscription_id, **kwargs)
75-
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
76-
super(CustomLocations, self).__init__(
77-
api_version=api_version,
78-
profile=profile
55+
) -> None:
56+
self._config = CustomLocationsConfiguration(credential=credential, subscription_id=subscription_id, **kwargs)
57+
_policies = kwargs.pop("policies", None)
58+
if _policies is None:
59+
_policies = [
60+
policies.RequestIdPolicy(**kwargs),
61+
self._config.headers_policy,
62+
self._config.user_agent_policy,
63+
self._config.proxy_policy,
64+
policies.ContentDecodePolicy(**kwargs),
65+
ARMAutoResourceProviderRegistrationPolicy(),
66+
self._config.redirect_policy,
67+
self._config.retry_policy,
68+
self._config.authentication_policy,
69+
self._config.custom_hook_policy,
70+
self._config.logging_policy,
71+
policies.DistributedTracingPolicy(**kwargs),
72+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
73+
self._config.http_logging_policy,
74+
]
75+
self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs)
76+
77+
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
78+
self._serialize = Serializer(client_models)
79+
self._deserialize = Deserializer(client_models)
80+
self._serialize.client_side_validation = False
81+
self.custom_locations = CustomLocationsOperations(
82+
self._client, self._config, self._serialize, self._deserialize
83+
)
84+
self.resource_sync_rules = ResourceSyncRulesOperations(
85+
self._client, self._config, self._serialize, self._deserialize
7986
)
8087

81-
@classmethod
82-
def _models_dict(cls, api_version):
83-
return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)}
88+
def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
89+
"""Runs the network request through the client's chained policies.
8490
85-
@classmethod
86-
def models(cls, api_version=DEFAULT_API_VERSION):
87-
"""Module depends on the API version:
91+
>>> from azure.core.rest import HttpRequest
92+
>>> request = HttpRequest("GET", "https://www.example.org/")
93+
<HttpRequest [GET], url: 'https://www.example.org/'>
94+
>>> response = client._send_request(request)
95+
<HttpResponse: 200 OK>
8896
89-
* 2021-03-15-preview: :mod:`v2021_03_15_preview.models<azure.mgmt.extendedlocation.v2021_03_15_preview.models>`
90-
* 2021-08-15: :mod:`v2021_08_15.models<azure.mgmt.extendedlocation.v2021_08_15.models>`
91-
* 2021-08-31-preview: :mod:`v2021_08_31_preview.models<azure.mgmt.extendedlocation.v2021_08_31_preview.models>`
92-
"""
93-
if api_version == '2021-03-15-preview':
94-
from .v2021_03_15_preview import models
95-
return models
96-
elif api_version == '2021-08-15':
97-
from .v2021_08_15 import models
98-
return models
99-
elif api_version == '2021-08-31-preview':
100-
from .v2021_08_31_preview import models
101-
return models
102-
raise ValueError("API version {} is not available".format(api_version))
103-
104-
@property
105-
def custom_locations(self):
106-
"""Instance depends on the API version:
107-
108-
* 2021-03-15-preview: :class:`CustomLocationsOperations<azure.mgmt.extendedlocation.v2021_03_15_preview.operations.CustomLocationsOperations>`
109-
* 2021-08-15: :class:`CustomLocationsOperations<azure.mgmt.extendedlocation.v2021_08_15.operations.CustomLocationsOperations>`
110-
* 2021-08-31-preview: :class:`CustomLocationsOperations<azure.mgmt.extendedlocation.v2021_08_31_preview.operations.CustomLocationsOperations>`
111-
"""
112-
api_version = self._get_api_version('custom_locations')
113-
if api_version == '2021-03-15-preview':
114-
from .v2021_03_15_preview.operations import CustomLocationsOperations as OperationClass
115-
elif api_version == '2021-08-15':
116-
from .v2021_08_15.operations import CustomLocationsOperations as OperationClass
117-
elif api_version == '2021-08-31-preview':
118-
from .v2021_08_31_preview.operations import CustomLocationsOperations as OperationClass
119-
else:
120-
raise ValueError("API version {} does not have operation group 'custom_locations'".format(api_version))
121-
self._config.api_version = api_version
122-
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
123-
124-
@property
125-
def resource_sync_rules(self):
126-
"""Instance depends on the API version:
127-
128-
* 2021-08-31-preview: :class:`ResourceSyncRulesOperations<azure.mgmt.extendedlocation.v2021_08_31_preview.operations.ResourceSyncRulesOperations>`
97+
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
98+
99+
:param request: The network request you want to make. Required.
100+
:type request: ~azure.core.rest.HttpRequest
101+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
102+
:return: The response of your network call. Does not do error handling on your response.
103+
:rtype: ~azure.core.rest.HttpResponse
129104
"""
130-
api_version = self._get_api_version('resource_sync_rules')
131-
if api_version == '2021-08-31-preview':
132-
from .v2021_08_31_preview.operations import ResourceSyncRulesOperations as OperationClass
133-
else:
134-
raise ValueError("API version {} does not have operation group 'resource_sync_rules'".format(api_version))
135-
self._config.api_version = api_version
136-
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
137-
138-
def close(self):
105+
106+
request_copy = deepcopy(request)
107+
request_copy.url = self._client.format_url(request_copy.url)
108+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
109+
110+
def close(self) -> None:
139111
self._client.close()
140-
def __enter__(self):
112+
113+
def __enter__(self) -> Self:
141114
self._client.__enter__()
142115
return self
143-
def __exit__(self, *exc_details):
116+
117+
def __exit__(self, *exc_details: Any) -> None:
144118
self._client.__exit__(*exc_details)

0 commit comments

Comments
 (0)