Skip to content

Commit a36fe45

Browse files
author
Yalin Li
authored
[AppConfig] Regenerate code without credentials (Azure#26375)
1 parent dfe8117 commit a36fe45

28 files changed

+4808
-1917
lines changed

sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
### Bugs Fixed
1010

1111
### Other Changes
12-
1312
- Python 2.7 is no longer supported. Please use Python version 3.6 or later.
13+
- Bumped mininum dependency on `azure-core` to `>=1.24.0`.
1414

1515
## 1.3.0 (2021-11-10)
1616

sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_azure_appconfiguration_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def __init__(self, base_url, credential, **kwargs):
7070
self._credential_scopes = base_url.strip("/") + "/.default"
7171

7272
self._config = AzureAppConfigurationConfiguration(
73-
credential, base_url, credential_scopes=self._credential_scopes, **kwargs # type: ignore
73+
base_url, credential_scopes=self._credential_scopes, **kwargs
7474
)
7575
self._config.user_agent_policy = UserAgentPolicy(
7676
base_user_agent=USER_AGENT, **kwargs
@@ -86,7 +86,7 @@ def __init__(self, base_url, credential, **kwargs):
8686
)
8787

8888
self._impl = AzureAppConfiguration(
89-
credential, base_url, pipeline=pipeline, credential_scopes=self._credential_scopes # type: ignore
89+
base_url, pipeline=pipeline, credential_scopes=self._credential_scopes
9090
)
9191

9292
@classmethod

sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/__init__.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@
77
# --------------------------------------------------------------------------
88

99
from ._azure_app_configuration import AzureAppConfiguration
10-
__all__ = ['AzureAppConfiguration']
1110

1211
try:
13-
from ._patch import patch_sdk # type: ignore
14-
patch_sdk()
12+
from ._patch import __all__ as _patch_all
13+
from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import
1514
except ImportError:
16-
pass
15+
_patch_all = []
16+
from ._patch import patch_sdk as _patch_sdk
17+
18+
__all__ = ["AzureAppConfiguration"]
19+
__all__.extend([p for p in _patch_all if p not in __all__])
20+
21+
_patch_sdk()

sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_azure_app_configuration.py

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,69 +6,68 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
from typing import TYPE_CHECKING
9+
from copy import deepcopy
10+
from typing import Any, Optional
1011

1112
from azure.core import PipelineClient
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
19-
from azure.core.pipeline.transport import HttpRequest, HttpResponse
13+
from azure.core.rest import HttpRequest, HttpResponse
2014

15+
from . import models
2116
from ._configuration import AzureAppConfigurationConfiguration
17+
from ._serialization import Deserializer, Serializer
2218
from .operations import AzureAppConfigurationOperationsMixin
23-
from . import models
2419

2520

26-
class AzureAppConfiguration(AzureAppConfigurationOperationsMixin):
21+
class AzureAppConfiguration(AzureAppConfigurationOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
2722
"""AzureAppConfiguration.
2823
29-
:param credential: Credential needed for the client to connect to Azure.
30-
:type credential: ~azure.core.credentials.TokenCredential
31-
:param endpoint: The endpoint of the App Configuration instance to send requests to.
24+
:param endpoint: The endpoint of the App Configuration instance to send requests to. Required.
3225
:type endpoint: str
33-
:param sync_token: Used to guarantee real-time consistency between requests.
26+
:param sync_token: Used to guarantee real-time consistency between requests. Default value is
27+
None.
3428
:type sync_token: str
29+
:keyword api_version: Api Version. Default value is "1.0". Note that overriding this default
30+
value may result in unsupported behavior.
31+
:paramtype api_version: str
3532
"""
3633

37-
def __init__(
38-
self,
39-
credential, # type: "TokenCredential"
40-
endpoint, # type: str
41-
sync_token=None, # type: Optional[str]
42-
**kwargs # type: Any
43-
):
44-
# type: (...) -> None
45-
base_url = '{endpoint}'
46-
self._config = AzureAppConfigurationConfiguration(credential, endpoint, sync_token, **kwargs)
47-
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)
34+
def __init__( # pylint: disable=missing-client-constructor-parameter-credential
35+
self, endpoint: str, sync_token: Optional[str] = None, **kwargs: Any
36+
) -> None:
37+
_endpoint = "{endpoint}"
38+
self._config = AzureAppConfigurationConfiguration(endpoint=endpoint, sync_token=sync_token, **kwargs)
39+
self._client = PipelineClient(base_url=_endpoint, config=self._config, **kwargs)
4840

4941
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
5042
self._serialize = Serializer(client_models)
51-
self._serialize.client_side_validation = False
5243
self._deserialize = Deserializer(client_models)
44+
self._serialize.client_side_validation = False
5345

54-
55-
def _send_request(self, http_request, **kwargs):
56-
# type: (HttpRequest, Any) -> HttpResponse
46+
def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
5747
"""Runs the network request through the client's chained policies.
5848
59-
:param http_request: The network request you want to make. Required.
60-
:type http_request: ~azure.core.pipeline.transport.HttpRequest
61-
:keyword bool stream: Whether the response payload will be streamed. Defaults to True.
49+
>>> from azure.core.rest import HttpRequest
50+
>>> request = HttpRequest("GET", "https://www.example.org/")
51+
<HttpRequest [GET], url: 'https://www.example.org/'>
52+
>>> response = client._send_request(request)
53+
<HttpResponse: 200 OK>
54+
55+
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
56+
57+
:param request: The network request you want to make. Required.
58+
:type request: ~azure.core.rest.HttpRequest
59+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
6260
:return: The response of your network call. Does not do error handling on your response.
63-
:rtype: ~azure.core.pipeline.transport.HttpResponse
61+
:rtype: ~azure.core.rest.HttpResponse
6462
"""
63+
64+
request_copy = deepcopy(request)
6565
path_format_arguments = {
66-
'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
66+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
6767
}
68-
http_request.url = self._client.format_url(http_request.url, **path_format_arguments)
69-
stream = kwargs.pop("stream", True)
70-
pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs)
71-
return pipeline_response.http_response
68+
69+
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
70+
return self._client.send_request(request_copy, **kwargs)
7271

7372
def close(self):
7473
# type: () -> None

sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_generated/_configuration.py

Lines changed: 25 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,68 +6,53 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
from typing import TYPE_CHECKING
9+
from typing import Any, Optional
1010

1111
from azure.core.configuration import Configuration
1212
from azure.core.pipeline import policies
1313

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
19-
2014
VERSION = "unknown"
2115

22-
class AzureAppConfigurationConfiguration(Configuration):
16+
17+
class AzureAppConfigurationConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
2318
"""Configuration for AzureAppConfiguration.
2419
2520
Note that all parameters used to create this instance are saved as instance
2621
attributes.
2722
28-
:param credential: Credential needed for the client to connect to Azure.
29-
:type credential: ~azure.core.credentials.TokenCredential
30-
:param endpoint: The endpoint of the App Configuration instance to send requests to.
23+
:param endpoint: The endpoint of the App Configuration instance to send requests to. Required.
3124
:type endpoint: str
32-
:param sync_token: Used to guarantee real-time consistency between requests.
25+
:param sync_token: Used to guarantee real-time consistency between requests. Default value is
26+
None.
3327
:type sync_token: str
28+
:keyword api_version: Api Version. Default value is "1.0". Note that overriding this default
29+
value may result in unsupported behavior.
30+
:paramtype api_version: str
3431
"""
3532

36-
def __init__(
37-
self,
38-
credential, # type: "TokenCredential"
39-
endpoint, # type: str
40-
sync_token=None, # type: Optional[str]
41-
**kwargs # type: Any
42-
):
43-
# type: (...) -> None
44-
if credential is None:
45-
raise ValueError("Parameter 'credential' must not be None.")
33+
def __init__(self, endpoint: str, sync_token: Optional[str] = None, **kwargs: Any) -> None:
34+
super(AzureAppConfigurationConfiguration, self).__init__(**kwargs)
35+
api_version = kwargs.pop("api_version", "1.0") # type: str
36+
4637
if endpoint is None:
4738
raise ValueError("Parameter 'endpoint' must not be None.")
48-
super(AzureAppConfigurationConfiguration, self).__init__(**kwargs)
4939

50-
self.credential = credential
5140
self.endpoint = endpoint
5241
self.sync_token = sync_token
53-
self.api_version = "1.0"
54-
self.credential_scopes = kwargs.pop('credential_scopes', ['https://dev.azuresynapse.net/.default'])
55-
kwargs.setdefault('sdk_moniker', 'appconfiguration/{}'.format(VERSION))
42+
self.api_version = api_version
43+
kwargs.setdefault("sdk_moniker", "appconfiguration/{}".format(VERSION))
5644
self._configure(**kwargs)
5745

5846
def _configure(
59-
self,
60-
**kwargs # type: Any
47+
self, **kwargs # type: Any
6148
):
6249
# type: (...) -> None
63-
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
64-
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
65-
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
66-
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
67-
self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs)
68-
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
69-
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
70-
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
71-
self.authentication_policy = kwargs.get('authentication_policy')
72-
if self.credential and not self.authentication_policy:
73-
self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
50+
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
51+
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
52+
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
53+
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
54+
self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs)
55+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
56+
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
57+
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
58+
self.authentication_policy = kwargs.get("authentication_policy")
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# ------------------------------------
2+
# Copyright (c) Microsoft Corporation.
3+
# Licensed under the MIT License.
4+
# ------------------------------------
5+
"""Customize generated code here.
6+
7+
Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
8+
"""
9+
from typing import List
10+
11+
__all__: List[str] = [] # Add all objects you want publicly available to users at this package level
12+
13+
14+
def patch_sdk():
15+
"""Do not remove from this file.
16+
17+
`patch_sdk` is a last resort escape hatch that allows you to do customizations
18+
you can't accomplish using the techniques described in
19+
https://aka.ms/azsdk/python/dpcodegen/python/customize
20+
"""

0 commit comments

Comments
 (0)