Skip to content

Commit 6f01b19

Browse files
updating generated code (Azure#17874)
* updating generated code * adding generated folder * getting error about rawdeserializer * fixes to error throwing * lint fixes * ignore swagger readme
1 parent 6b640a4 commit 6f01b19

24 files changed

+2472
-1849
lines changed

eng/.docsettings.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ known_content_issues:
108108
- ['sdk/textanalytics/azure-ai-textanalytics/swagger/README.md', '#4554']
109109
- ['sdk/media/azure-media-nspkg/README.md', '#4554']
110110
- ['sdk/containerregistry/azure-containerregistry/swagger/README.md', '#4554']
111+
- ['sdk/appconfiguration/azure-appconfiguration/swagger/README.md', '#4554']
111112

112113
# nspckg and common.
113114
- ['sdk/appconfiguration/azure-appconfiguration/README.md', 'nspkg and common']

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

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
DistributedTracingPolicy,
1313
HttpLoggingPolicy,
1414
BearerTokenCredentialPolicy,
15+
ContentDecodePolicy,
1516
)
1617
from azure.core.tracing.decorator import distributed_trace
1718
from azure.core.pipeline.transport import RequestsTransport
@@ -25,7 +26,6 @@
2526
)
2627
from ._azure_appconfiguration_error import ResourceReadOnlyError
2728
from ._generated import AzureAppConfiguration
28-
from ._generated.models import ErrorException
2929
from ._generated._configuration import AzureAppConfigurationConfiguration
3030
from ._models import ConfigurationSetting
3131
from ._azure_appconfiguration_requests import AppConfigRequestsCredentialsPolicy
@@ -74,8 +74,10 @@ def __init__(self, base_url, credential, **kwargs):
7474
if not credential:
7575
raise ValueError("Missing credential")
7676

77+
self._credential_scopes = base_url.strip("/") + "/.default"
78+
7779
self._config = AzureAppConfigurationConfiguration(
78-
credential, base_url, **kwargs
80+
credential, base_url, credential_scopes=self._credential_scopes, **kwargs
7981
)
8082
self._config.user_agent_policy = UserAgentPolicy(
8183
base_user_agent=USER_AGENT, **kwargs
@@ -94,7 +96,7 @@ def __init__(self, base_url, credential, **kwargs):
9496
)
9597

9698
self._impl = AzureAppConfiguration(
97-
credentials=credential, endpoint=base_url, pipeline=pipeline
99+
credential, base_url, pipeline=pipeline, credential_scopes=self._credential_scopes
98100
)
99101

100102
@classmethod
@@ -151,6 +153,7 @@ def _create_appconfig_pipeline(
151153
self._config.logging_policy, # HTTP request/response log
152154
DistributedTracingPolicy(**kwargs),
153155
HttpLoggingPolicy(**kwargs),
156+
ContentDecodePolicy(**kwargs),
154157
]
155158

156159
if not transport:
@@ -213,8 +216,9 @@ def list_configuration_settings(
213216
error_map=error_map,
214217
**kwargs
215218
)
216-
except ErrorException as error:
217-
raise HttpResponseError(message=error.message, response=error.response)
219+
except HttpResponseError as error:
220+
e = error_map[error.status_code]
221+
raise e(message=error.message, response=error.response)
218222
except binascii.Error:
219223
raise binascii.Error("Connection string secret has incorrect padding")
220224

@@ -274,8 +278,9 @@ def get_configuration_setting(
274278
return ConfigurationSetting._from_generated(key_value)
275279
except ResourceNotModifiedError:
276280
return None
277-
except ErrorException as error:
278-
raise HttpResponseError(message=error.message, response=error.response)
281+
except HttpResponseError as error:
282+
e = error_map[error.status_code]
283+
raise e(message=error.message, response=error.response)
279284
except binascii.Error:
280285
raise binascii.Error("Connection string secret has incorrect padding")
281286

@@ -322,8 +327,9 @@ def add_configuration_setting(
322327
error_map=error_map,
323328
)
324329
return ConfigurationSetting._from_generated(key_value_added)
325-
except ErrorException as error:
326-
raise HttpResponseError(message=error.message, response=error.response)
330+
except HttpResponseError as error:
331+
e = error_map[error.status_code]
332+
raise e(message=error.message, response=error.response)
327333
except binascii.Error:
328334
raise binascii.Error("Connection string secret has incorrect padding")
329335

@@ -388,8 +394,9 @@ def set_configuration_setting(
388394
error_map=error_map,
389395
)
390396
return ConfigurationSetting._from_generated(key_value_set)
391-
except ErrorException as error:
392-
raise HttpResponseError(message=error.message, response=error.response)
397+
except HttpResponseError as error:
398+
e = error_map[error.status_code]
399+
raise e(message=error.message, response=error.response)
393400
except binascii.Error:
394401
raise binascii.Error("Connection string secret has incorrect padding")
395402

@@ -443,8 +450,9 @@ def delete_configuration_setting(
443450
error_map=error_map,
444451
)
445452
return ConfigurationSetting._from_generated(key_value_deleted)
446-
except ErrorException as error:
447-
raise HttpResponseError(message=error.message, response=error.response)
453+
except HttpResponseError as error:
454+
e = error_map[error.status_code]
455+
raise e(message=error.message, response=error.response)
448456
except binascii.Error:
449457
raise binascii.Error("Connection string secret has incorrect padding")
450458

@@ -503,8 +511,9 @@ def list_revisions(
503511
error_map=error_map,
504512
**kwargs
505513
)
506-
except ErrorException as error:
507-
raise HttpResponseError(message=error.message, response=error.response)
514+
except HttpResponseError as error:
515+
e = error_map[error.status_code]
516+
raise e(message=error.message, response=error.response)
508517
except binascii.Error:
509518
raise binascii.Error("Connection string secret has incorrect padding")
510519

@@ -572,8 +581,9 @@ def set_read_only(
572581
**kwargs
573582
)
574583
return ConfigurationSetting._from_generated(key_value)
575-
except ErrorException as error:
576-
raise HttpResponseError(message=error.message, response=error.response)
584+
except HttpResponseError as error:
585+
e = error_map[error.status_code]
586+
raise e(message=error.message, response=error.response)
577587
except binascii.Error:
578588
raise binascii.Error("Connection string secret has incorrect padding")
579589

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

89
from ._azure_app_configuration import AzureAppConfiguration
910
__all__ = ['AzureAppConfiguration']
1011

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

9+
from typing import TYPE_CHECKING
10+
811
from azure.core import PipelineClient
9-
from msrest import Serializer, Deserializer
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
1020

1121
from ._configuration import AzureAppConfigurationConfiguration
1222
from .operations import AzureAppConfigurationOperationsMixin
1323
from . import models
1424

1525

1626
class AzureAppConfiguration(AzureAppConfigurationOperationsMixin):
17-
"""AzureAppConfiguration
27+
"""AzureAppConfiguration.
1828
19-
20-
:param credentials: Credentials needed for the client to connect to Azure.
21-
:type credentials: :mod:`A msrestazure Credentials
22-
object<msrestazure.azure_active_directory>`
23-
:param endpoint: The endpoint of the App Configuration instance to send
24-
requests to.
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.
2532
:type endpoint: str
26-
:param sync_token: Used to guarantee real-time consistency between
27-
requests.
33+
:param sync_token: Used to guarantee real-time consistency between requests.
2834
:type sync_token: str
2935
"""
3036

3137
def __init__(
32-
self, credentials, endpoint, sync_token=None, **kwargs):
33-
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
3445
base_url = '{endpoint}'
35-
self._config = AzureAppConfigurationConfiguration(credentials, endpoint, sync_token, **kwargs)
46+
self._config = AzureAppConfigurationConfiguration(credential, endpoint, sync_token, **kwargs)
3647
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)
3748

3849
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
39-
self.api_version = '1.0'
4050
self._serialize = Serializer(client_models)
51+
self._serialize.client_side_validation = False
4152
self._deserialize = Deserializer(client_models)
4253

4354

55+
def _send_request(self, http_request, **kwargs):
56+
# type: (HttpRequest, Any) -> HttpResponse
57+
"""Runs the network request through the client's chained policies.
58+
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.
62+
:return: The response of your network call. Does not do error handling on your response.
63+
:rtype: ~azure.core.pipeline.transport.HttpResponse
64+
"""
65+
path_format_arguments = {
66+
'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
67+
}
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
72+
73+
def close(self):
74+
# type: () -> None
75+
self._client.close()
76+
4477
def __enter__(self):
78+
# type: () -> AzureAppConfiguration
4579
self._client.__enter__()
4680
return self
81+
4782
def __exit__(self, *exc_details):
83+
# type: (Any) -> None
4884
self._client.__exit__(*exc_details)
Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,75 @@
11
# coding=utf-8
22
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
35
# Code generated by Microsoft (R) AutoRest Code Generator.
4-
# Changes may cause incorrect behavior and will be lost if the code is
5-
# regenerated.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
67
# --------------------------------------------------------------------------
8+
9+
from typing import TYPE_CHECKING
10+
711
from azure.core.configuration import Configuration
812
from azure.core.pipeline import policies
913

10-
from .version import VERSION
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
1119

20+
VERSION = "unknown"
1221

1322
class AzureAppConfigurationConfiguration(Configuration):
14-
"""Configuration for AzureAppConfiguration
23+
"""Configuration for AzureAppConfiguration.
24+
1525
Note that all parameters used to create this instance are saved as instance
1626
attributes.
1727
18-
:param credentials: Credentials needed for the client to connect to Azure.
19-
:type credentials: :mod:`A msrestazure Credentials
20-
object<msrestazure.azure_active_directory>`
21-
:param endpoint: The endpoint of the App Configuration instance to send
22-
requests to.
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.
2331
:type endpoint: str
24-
:param sync_token: Used to guarantee real-time consistency between
25-
requests.
32+
:param sync_token: Used to guarantee real-time consistency between requests.
2633
:type sync_token: str
2734
"""
2835

29-
def __init__(self, credentials, endpoint, sync_token=None, **kwargs):
30-
31-
if credentials is None:
32-
raise ValueError("Parameter 'credentials' must not be None.")
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.")
3346
if endpoint is None:
3447
raise ValueError("Parameter 'endpoint' must not be None.")
35-
3648
super(AzureAppConfigurationConfiguration, self).__init__(**kwargs)
37-
self._configure(**kwargs)
3849

39-
self.user_agent_policy.add_user_agent('azsdk-python-azureappconfiguration/{}'.format(VERSION))
40-
self.generate_client_request_id = True
41-
42-
self.credentials = credentials
50+
self.credential = credential
4351
self.endpoint = endpoint
4452
self.sync_token = sync_token
53+
self.api_version = "1.0"
54+
self.credential_scopes = kwargs.pop('credential_scopes', [])
55+
kwargs.setdefault('sdk_moniker', 'appconfiguration/{}'.format(VERSION))
56+
self._configure(**kwargs)
4557

46-
def _configure(self, **kwargs):
58+
def _configure(
59+
self,
60+
**kwargs # type: Any
61+
):
62+
# type: (...) -> None
4763
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
4864
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
4965
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
5066
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)
5168
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
5269
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
5370
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
71+
self.authentication_policy = kwargs.get('authentication_policy')
72+
if not self.credential_scopes and not self.authentication_policy:
73+
raise ValueError("You must provide either credential_scopes or authentication_policy as kwargs")
74+
if self.credential and not self.authentication_policy:
75+
self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# coding=utf-8
22
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
35
# Code generated by Microsoft (R) AutoRest Code Generator.
4-
# Changes may cause incorrect behavior and will be lost if the code is
5-
# regenerated.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
67
# --------------------------------------------------------------------------
78

8-
from ._azure_app_configuration_async import AzureAppConfiguration
9+
from ._azure_app_configuration import AzureAppConfiguration
910
__all__ = ['AzureAppConfiguration']

0 commit comments

Comments
 (0)