|
6 | 6 |
|
7 | 7 | Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
|
8 | 8 | """
|
9 |
| -from typing import List |
| 9 | +import urllib.parse |
| 10 | +from typing import Any, AsyncIterable, List, Optional, Union |
| 11 | +from azure.core.exceptions import ( |
| 12 | + ClientAuthenticationError, |
| 13 | + HttpResponseError, |
| 14 | + ResourceExistsError, |
| 15 | + ResourceNotFoundError, |
| 16 | + ResourceNotModifiedError, |
| 17 | + map_error, |
| 18 | +) |
| 19 | +from azure.core.rest import HttpRequest |
| 20 | +from azure.core.tracing.decorator_async import distributed_trace_async |
| 21 | +from azure.core.utils import case_insensitive_dict |
| 22 | +from ._azure_app_configuration_operations import ( |
| 23 | + AzureAppConfigurationOperationsMixin as AzureAppConfigOpGenerated, |
| 24 | + ClsType, |
| 25 | + build_get_key_values_request, |
| 26 | +) |
| 27 | +from ... import models as _models |
| 28 | +from ..._vendor import _convert_request |
10 | 29 |
|
11 |
| -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level |
| 30 | + |
| 31 | +class AzureAppConfigurationOperationsMixin(AzureAppConfigOpGenerated): |
| 32 | + @distributed_trace_async |
| 33 | + async def get_key_values_in_one_page( |
| 34 | + self, |
| 35 | + key: Optional[str] = None, |
| 36 | + label: Optional[str] = None, |
| 37 | + after: Optional[str] = None, |
| 38 | + accept_datetime: Optional[str] = None, |
| 39 | + select: Optional[List[Union[str, _models.KeyValueFields]]] = None, |
| 40 | + if_match: Optional[str] = None, |
| 41 | + if_none_match: Optional[str] = None, |
| 42 | + continuation_token: Optional[str] = None, |
| 43 | + **kwargs: Any |
| 44 | + ) -> AsyncIterable["_models.KeyValue"]: |
| 45 | + """Gets a list of key-values in one page. |
| 46 | +
|
| 47 | + Gets a list of key-values in one page. |
| 48 | +
|
| 49 | + :param key: A filter used to match keys. Default value is None. |
| 50 | + :type key: str |
| 51 | + :param label: A filter used to match labels. Default value is None. |
| 52 | + :type label: str |
| 53 | + :param after: Instructs the server to return elements that appear after the element referred to |
| 54 | + by the specified token. Default value is None. |
| 55 | + :type after: str |
| 56 | + :param accept_datetime: Requests the server to respond with the state of the resource at the |
| 57 | + specified time. Default value is None. |
| 58 | + :type accept_datetime: str |
| 59 | + :param select: Used to select what fields are present in the returned resource(s). Default |
| 60 | + value is None. |
| 61 | + :type select: list[str or ~azure.appconfiguration.models.KeyValueFields] |
| 62 | + :param if_match: Used to perform an operation only if the targeted resource's etag matches the |
| 63 | + value provided. Default value is None. |
| 64 | + :type if_match: str |
| 65 | + :param if_none_match: Used to perform an operation only if the targeted resource's etag does |
| 66 | + not match the value provided. Default value is None. |
| 67 | + :type if_none_match: str |
| 68 | + :param str continuation_token: An opaque continuation token. |
| 69 | + :keyword callable cls: A custom type or function that will be passed the direct response |
| 70 | + :return: An iterator like instance of either KeyValue or the result of cls(response) |
| 71 | + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.appconfiguration.models.KeyValue] |
| 72 | + :raises ~azure.core.exceptions.HttpResponseError: |
| 73 | + """ |
| 74 | + _headers = kwargs.pop("headers", {}) or {} |
| 75 | + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) |
| 76 | + |
| 77 | + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) |
| 78 | + cls: ClsType[_models.KeyValueListResult] = kwargs.pop("cls", None) |
| 79 | + |
| 80 | + error_map = { |
| 81 | + 401: ClientAuthenticationError, |
| 82 | + 404: ResourceNotFoundError, |
| 83 | + 409: ResourceExistsError, |
| 84 | + 304: ResourceNotModifiedError, |
| 85 | + } |
| 86 | + error_map.update(kwargs.pop("error_map", {}) or {}) |
| 87 | + |
| 88 | + def prepare_request(next_link=None): |
| 89 | + if not next_link: |
| 90 | + |
| 91 | + _request = build_get_key_values_request( |
| 92 | + key=key, |
| 93 | + label=label, |
| 94 | + after=after, |
| 95 | + accept_datetime=accept_datetime, |
| 96 | + select=select, |
| 97 | + if_match=if_match, |
| 98 | + if_none_match=if_none_match, |
| 99 | + sync_token=self._config.sync_token, |
| 100 | + api_version=api_version, |
| 101 | + headers=_headers, |
| 102 | + params=_params, |
| 103 | + ) |
| 104 | + _request = _convert_request(_request) |
| 105 | + path_format_arguments = { |
| 106 | + "endpoint": self._serialize.url( |
| 107 | + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True |
| 108 | + ), |
| 109 | + } |
| 110 | + _request.url = self._client.format_url(_request.url, **path_format_arguments) |
| 111 | + |
| 112 | + else: |
| 113 | + # make call to next link with the client's api-version |
| 114 | + _parsed_next_link = urllib.parse.urlparse(next_link) |
| 115 | + _next_request_params = case_insensitive_dict( |
| 116 | + { |
| 117 | + key: [urllib.parse.quote(v) for v in value] |
| 118 | + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() |
| 119 | + } |
| 120 | + ) |
| 121 | + _next_request_params["api-version"] = self._config.api_version |
| 122 | + _request = HttpRequest( |
| 123 | + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params |
| 124 | + ) |
| 125 | + _request = _convert_request(_request) |
| 126 | + path_format_arguments = { |
| 127 | + "endpoint": self._serialize.url( |
| 128 | + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True |
| 129 | + ), |
| 130 | + } |
| 131 | + _request.url = self._client.format_url(_request.url, **path_format_arguments) |
| 132 | + _request.method = "GET" |
| 133 | + return _request |
| 134 | + |
| 135 | + _request = prepare_request(continuation_token) |
| 136 | + |
| 137 | + _stream = False |
| 138 | + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access |
| 139 | + _request, stream=_stream, **kwargs |
| 140 | + ) |
| 141 | + response = pipeline_response.http_response |
| 142 | + |
| 143 | + if response.status_code not in [200]: |
| 144 | + map_error(status_code=response.status_code, response=response, error_map=error_map) |
| 145 | + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) |
| 146 | + raise HttpResponseError(response=response, model=error) |
| 147 | + |
| 148 | + response_headers = response.headers |
| 149 | + deserialized = self._deserialize("KeyValueListResult", pipeline_response) |
| 150 | + |
| 151 | + if cls: |
| 152 | + return cls(pipeline_response, deserialized, response_headers) |
| 153 | + |
| 154 | + return deserialized |
| 155 | + |
| 156 | + |
| 157 | +__all__: List[str] = [ |
| 158 | + "AzureAppConfigurationOperationsMixin" |
| 159 | +] # Add all objects you want publicly available to users at this package level |
12 | 160 |
|
13 | 161 |
|
14 | 162 | def patch_sdk():
|
|
0 commit comments