Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating generated code #17874

Merged
merged 6 commits into from
Apr 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eng/.docsettings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ known_content_issues:
- ['sdk/textanalytics/azure-ai-textanalytics/swagger/README.md', '#4554']
- ['sdk/media/azure-media-nspkg/README.md', '#4554']
- ['sdk/containerregistry/azure-containerregistry/swagger/README.md', '#4554']
- ['sdk/appconfiguration/azure-appconfiguration/swagger/README.md', '#4554']

# nspckg and common.
- ['sdk/appconfiguration/azure-appconfiguration/README.md', 'nspkg and common']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
DistributedTracingPolicy,
HttpLoggingPolicy,
BearerTokenCredentialPolicy,
ContentDecodePolicy,
)
from azure.core.tracing.decorator import distributed_trace
from azure.core.pipeline.transport import RequestsTransport
Expand All @@ -25,7 +26,6 @@
)
from ._azure_appconfiguration_error import ResourceReadOnlyError
from ._generated import AzureAppConfiguration
from ._generated.models import ErrorException
from ._generated._configuration import AzureAppConfigurationConfiguration
from ._models import ConfigurationSetting
from ._azure_appconfiguration_requests import AppConfigRequestsCredentialsPolicy
Expand Down Expand Up @@ -74,8 +74,10 @@ def __init__(self, base_url, credential, **kwargs):
if not credential:
raise ValueError("Missing credential")

self._credential_scopes = base_url.strip("/") + "/.default"

self._config = AzureAppConfigurationConfiguration(
credential, base_url, **kwargs
credential, base_url, credential_scopes=self._credential_scopes, **kwargs
)
self._config.user_agent_policy = UserAgentPolicy(
base_user_agent=USER_AGENT, **kwargs
Expand All @@ -94,7 +96,7 @@ def __init__(self, base_url, credential, **kwargs):
)

self._impl = AzureAppConfiguration(
credentials=credential, endpoint=base_url, pipeline=pipeline
credential, base_url, pipeline=pipeline, credential_scopes=self._credential_scopes
)

@classmethod
Expand Down Expand Up @@ -151,6 +153,7 @@ def _create_appconfig_pipeline(
self._config.logging_policy, # HTTP request/response log
DistributedTracingPolicy(**kwargs),
HttpLoggingPolicy(**kwargs),
ContentDecodePolicy(**kwargs),
]

if not transport:
Expand Down Expand Up @@ -213,8 +216,9 @@ def list_configuration_settings(
error_map=error_map,
**kwargs
)
except ErrorException as error:
raise HttpResponseError(message=error.message, response=error.response)
except HttpResponseError as error:
e = error_map[error.status_code]
raise e(message=error.message, response=error.response)
except binascii.Error:
raise binascii.Error("Connection string secret has incorrect padding")

Expand Down Expand Up @@ -274,8 +278,9 @@ def get_configuration_setting(
return ConfigurationSetting._from_generated(key_value)
except ResourceNotModifiedError:
return None
except ErrorException as error:
raise HttpResponseError(message=error.message, response=error.response)
except HttpResponseError as error:
e = error_map[error.status_code]
raise e(message=error.message, response=error.response)
except binascii.Error:
raise binascii.Error("Connection string secret has incorrect padding")

Expand Down Expand Up @@ -322,8 +327,9 @@ def add_configuration_setting(
error_map=error_map,
)
return ConfigurationSetting._from_generated(key_value_added)
except ErrorException as error:
raise HttpResponseError(message=error.message, response=error.response)
except HttpResponseError as error:
e = error_map[error.status_code]
raise e(message=error.message, response=error.response)
except binascii.Error:
raise binascii.Error("Connection string secret has incorrect padding")

Expand Down Expand Up @@ -388,8 +394,9 @@ def set_configuration_setting(
error_map=error_map,
)
return ConfigurationSetting._from_generated(key_value_set)
except ErrorException as error:
raise HttpResponseError(message=error.message, response=error.response)
except HttpResponseError as error:
e = error_map[error.status_code]
raise e(message=error.message, response=error.response)
except binascii.Error:
raise binascii.Error("Connection string secret has incorrect padding")

Expand Down Expand Up @@ -443,8 +450,9 @@ def delete_configuration_setting(
error_map=error_map,
)
return ConfigurationSetting._from_generated(key_value_deleted)
except ErrorException as error:
raise HttpResponseError(message=error.message, response=error.response)
except HttpResponseError as error:
e = error_map[error.status_code]
raise e(message=error.message, response=error.response)
except binascii.Error:
raise binascii.Error("Connection string secret has incorrect padding")

Expand Down Expand Up @@ -503,8 +511,9 @@ def list_revisions(
error_map=error_map,
**kwargs
)
except ErrorException as error:
raise HttpResponseError(message=error.message, response=error.response)
except HttpResponseError as error:
e = error_map[error.status_code]
raise e(message=error.message, response=error.response)
except binascii.Error:
raise binascii.Error("Connection string secret has incorrect padding")

Expand Down Expand Up @@ -572,8 +581,9 @@ def set_read_only(
**kwargs
)
return ConfigurationSetting._from_generated(key_value)
except ErrorException as error:
raise HttpResponseError(message=error.message, response=error.response)
except HttpResponseError as error:
e = error_map[error.status_code]
raise e(message=error.message, response=error.response)
except binascii.Error:
raise binascii.Error("Connection string secret has incorrect padding")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# 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.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._azure_app_configuration import AzureAppConfiguration
__all__ = ['AzureAppConfiguration']

from .version import VERSION

__version__ = VERSION

try:
from ._patch import patch_sdk # type: ignore
patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
@@ -1,48 +1,84 @@
# 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.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import TYPE_CHECKING

from azure.core import PipelineClient
from msrest import Serializer, Deserializer
from msrest import Deserializer, Serializer

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any, Optional

from azure.core.credentials import TokenCredential
from azure.core.pipeline.transport import HttpRequest, HttpResponse

from ._configuration import AzureAppConfigurationConfiguration
from .operations import AzureAppConfigurationOperationsMixin
from . import models


class AzureAppConfiguration(AzureAppConfigurationOperationsMixin):
"""AzureAppConfiguration
"""AzureAppConfiguration.


:param credentials: Credentials needed for the client to connect to Azure.
:type credentials: :mod:`A msrestazure Credentials
object<msrestazure.azure_active_directory>`
:param endpoint: The endpoint of the App Configuration instance to send
requests to.
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials.TokenCredential
:param endpoint: The endpoint of the App Configuration instance to send requests to.
:type endpoint: str
:param sync_token: Used to guarantee real-time consistency between
requests.
:param sync_token: Used to guarantee real-time consistency between requests.
:type sync_token: str
"""

def __init__(
self, credentials, endpoint, sync_token=None, **kwargs):

self,
credential, # type: "TokenCredential"
endpoint, # type: str
sync_token=None, # type: Optional[str]
**kwargs # type: Any
):
# type: (...) -> None
base_url = '{endpoint}'
self._config = AzureAppConfigurationConfiguration(credentials, endpoint, sync_token, **kwargs)
self._config = AzureAppConfigurationConfiguration(credential, endpoint, sync_token, **kwargs)
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self.api_version = '1.0'
self._serialize = Serializer(client_models)
self._serialize.client_side_validation = False
self._deserialize = Deserializer(client_models)


def _send_request(self, http_request, **kwargs):
# type: (HttpRequest, Any) -> HttpResponse
"""Runs the network request through the client's chained policies.

:param http_request: The network request you want to make. Required.
:type http_request: ~azure.core.pipeline.transport.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to True.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.pipeline.transport.HttpResponse
"""
path_format_arguments = {
'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
}
http_request.url = self._client.format_url(http_request.url, **path_format_arguments)
stream = kwargs.pop("stream", True)
pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs)
return pipeline_response.http_response

def close(self):
# type: () -> None
self._client.close()

def __enter__(self):
# type: () -> AzureAppConfiguration
self._client.__enter__()
return self

def __exit__(self, *exc_details):
# type: (Any) -> None
self._client.__exit__(*exc_details)
Original file line number Diff line number Diff line change
@@ -1,53 +1,75 @@
# 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.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import TYPE_CHECKING

from azure.core.configuration import Configuration
from azure.core.pipeline import policies

from .version import VERSION
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any, Optional

from azure.core.credentials import TokenCredential

VERSION = "unknown"

class AzureAppConfigurationConfiguration(Configuration):
"""Configuration for AzureAppConfiguration
"""Configuration for AzureAppConfiguration.

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 endpoint: The endpoint of the App Configuration instance to send
requests to.
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials.TokenCredential
:param endpoint: The endpoint of the App Configuration instance to send requests to.
:type endpoint: str
:param sync_token: Used to guarantee real-time consistency between
requests.
:param sync_token: Used to guarantee real-time consistency between requests.
:type sync_token: str
"""

def __init__(self, credentials, endpoint, sync_token=None, **kwargs):

if credentials is None:
raise ValueError("Parameter 'credentials' must not be None.")
def __init__(
self,
credential, # type: "TokenCredential"
endpoint, # type: str
sync_token=None, # type: Optional[str]
**kwargs # type: Any
):
# type: (...) -> None
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")

super(AzureAppConfigurationConfiguration, self).__init__(**kwargs)
self._configure(**kwargs)

self.user_agent_policy.add_user_agent('azsdk-python-azureappconfiguration/{}'.format(VERSION))
self.generate_client_request_id = True

self.credentials = credentials
self.credential = credential
self.endpoint = endpoint
self.sync_token = sync_token
self.api_version = "1.0"
self.credential_scopes = kwargs.pop('credential_scopes', [])
kwargs.setdefault('sdk_moniker', 'appconfiguration/{}'.format(VERSION))
self._configure(**kwargs)

def _configure(self, **kwargs):
def _configure(
self,
**kwargs # type: Any
):
# type: (...) -> None
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get('authentication_policy')
if not self.credential_scopes and not self.authentication_policy:
raise ValueError("You must provide either credential_scopes or authentication_policy as kwargs")
if self.credential and not self.authentication_policy:
self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# 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.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._azure_app_configuration_async import AzureAppConfiguration
from ._azure_app_configuration import AzureAppConfiguration
__all__ = ['AzureAppConfiguration']
Loading