aws-sdk-appconfigdata 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. aws_sdk_appconfigdata/__init__.py +34 -0
  2. aws_sdk_appconfigdata/_async.py +25 -0
  3. aws_sdk_appconfigdata/_auth/_identity.py +16 -0
  4. aws_sdk_appconfigdata/_auth/_providers.py +159 -0
  5. aws_sdk_appconfigdata/_auth/_signers.py +84 -0
  6. aws_sdk_appconfigdata/_auth/_sigv4.py +382 -0
  7. aws_sdk_appconfigdata/_auth/_zapros_handler.py +62 -0
  8. aws_sdk_appconfigdata/_iter.py +23 -0
  9. aws_sdk_appconfigdata/_operations/app_config_data/get_latest_configuration.py +166 -0
  10. aws_sdk_appconfigdata/_operations/app_config_data/start_configuration_session.py +158 -0
  11. aws_sdk_appconfigdata/_pagination.py +21 -0
  12. aws_sdk_appconfigdata/_protocol/__init__.py +1 -0
  13. aws_sdk_appconfigdata/_protocol/errors.py +59 -0
  14. aws_sdk_appconfigdata/_protocol/xml.py +27 -0
  15. aws_sdk_appconfigdata/_resources/app_config_data/configuration_session.py +141 -0
  16. aws_sdk_appconfigdata/_rule_engine/__init__.py +0 -0
  17. aws_sdk_appconfigdata/_rule_engine/_aws_partition.py +160 -0
  18. aws_sdk_appconfigdata/_rule_engine/_endpoint_rule_set.py +154 -0
  19. aws_sdk_appconfigdata/_rule_engine/_endpoint_runtime.py +389 -0
  20. aws_sdk_appconfigdata/_services/_pipeline.py +195 -0
  21. aws_sdk_appconfigdata/_services/app_config_data.py +170 -0
  22. aws_sdk_appconfigdata/_services/async_app_config_data.py +171 -0
  23. aws_sdk_appconfigdata/errors/__init__.py +28 -0
  24. aws_sdk_appconfigdata/errors/_base.py +94 -0
  25. aws_sdk_appconfigdata/errors/bad_request_exception.py +76 -0
  26. aws_sdk_appconfigdata/errors/internal_server_exception.py +48 -0
  27. aws_sdk_appconfigdata/errors/resource_not_found_exception.py +70 -0
  28. aws_sdk_appconfigdata/errors/throttling_exception.py +48 -0
  29. aws_sdk_appconfigdata/py.typed +0 -0
  30. aws_sdk_appconfigdata/types/_prelude/blob.py +12 -0
  31. aws_sdk_appconfigdata/types/_prelude/timestamp.py +12 -0
  32. aws_sdk_appconfigdata/types/bad_request_details.py +44 -0
  33. aws_sdk_appconfigdata/types/bad_request_reason.py +5 -0
  34. aws_sdk_appconfigdata/types/get_latest_configuration_request.py +22 -0
  35. aws_sdk_appconfigdata/types/get_latest_configuration_response.py +55 -0
  36. aws_sdk_appconfigdata/types/id.py +5 -0
  37. aws_sdk_appconfigdata/types/identifier.py +5 -0
  38. aws_sdk_appconfigdata/types/integer.py +7 -0
  39. aws_sdk_appconfigdata/types/invalid_parameter_detail.py +30 -0
  40. aws_sdk_appconfigdata/types/invalid_parameter_map.py +35 -0
  41. aws_sdk_appconfigdata/types/invalid_parameter_problem.py +5 -0
  42. aws_sdk_appconfigdata/types/optional_poll_seconds.py +5 -0
  43. aws_sdk_appconfigdata/types/resource_type.py +5 -0
  44. aws_sdk_appconfigdata/types/sensitive_blob.py +15 -0
  45. aws_sdk_appconfigdata/types/start_configuration_session_request.py +66 -0
  46. aws_sdk_appconfigdata/types/start_configuration_session_response.py +28 -0
  47. aws_sdk_appconfigdata/types/string.py +5 -0
  48. aws_sdk_appconfigdata/types/string_map.py +26 -0
  49. aws_sdk_appconfigdata/types/token.py +5 -0
  50. aws_sdk_appconfigdata-0.1.0.dist-info/METADATA +82 -0
  51. aws_sdk_appconfigdata-0.1.0.dist-info/RECORD +54 -0
  52. aws_sdk_appconfigdata-0.1.0.dist-info/WHEEL +5 -0
  53. aws_sdk_appconfigdata-0.1.0.dist-info/licenses/LICENSE +21 -0
  54. aws_sdk_appconfigdata-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,62 @@
1
+ from typing import Optional, cast
2
+
3
+ from zapros import (
4
+ AsyncBaseHandler,
5
+ AsyncBaseMiddleware,
6
+ AsyncSyncMismatchError,
7
+ BaseHandler,
8
+ BaseMiddleware,
9
+ Request,
10
+ )
11
+ from zapros._models import Response
12
+
13
+ from ._signers import Signer
14
+
15
+
16
+ def ensure_async_handler(
17
+ handler: AsyncBaseHandler | BaseHandler,
18
+ ) -> AsyncBaseHandler:
19
+ if isinstance(handler, AsyncBaseHandler):
20
+ return handler
21
+ raise AsyncSyncMismatchError(
22
+ "Handler was expected to be an AsyncBaseHandler, but it is not."
23
+ )
24
+
25
+
26
+ def ensure_sync_handler(
27
+ handler: AsyncBaseHandler | BaseHandler,
28
+ ) -> BaseHandler:
29
+ if isinstance(handler, BaseHandler):
30
+ return handler
31
+ raise AsyncSyncMismatchError(
32
+ "Handler was expected to be a BaseHandler, but it is not."
33
+ )
34
+
35
+
36
+ class AuthMiddleware(BaseMiddleware, AsyncBaseMiddleware):
37
+ """Sign the outgoing request using the Signer placed in ``context["signer"]``.
38
+
39
+ The generated ``get_signer`` in each operation module resolves the
40
+ effective auth scheme to a concrete :class:`Signer` and threads it
41
+ through ``request.context`` before dispatch. This middleware does the
42
+ actual signing; ``None`` means the operation opted out via
43
+ ``@optionalAuth`` and the request passes through untouched.
44
+ """
45
+
46
+ def __init__(self, next_handler: BaseHandler | AsyncBaseHandler) -> None:
47
+ self.next = cast(BaseHandler, next_handler)
48
+ self.async_next = cast(AsyncBaseHandler, next_handler)
49
+
50
+ def handle(self, request: Request) -> Response:
51
+ next_handler = ensure_sync_handler(self.next)
52
+ signer = cast(Optional[Signer], request.context.get("signer"))
53
+ if signer is not None:
54
+ request = signer.sign(request)
55
+ return next_handler.handle(request)
56
+
57
+ async def ahandle(self, request: Request) -> Response:
58
+ next_handler = ensure_async_handler(self.async_next)
59
+ signer = cast(Optional[Signer], request.context.get("signer"))
60
+ if signer is not None:
61
+ request = await signer.asign(request)
62
+ return await next_handler.ahandle(request)
@@ -0,0 +1,23 @@
1
+ """Runtime helpers normalizing streaming payloads into byte iterators."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import AsyncIterator, Iterator
6
+
7
+
8
+ def ensure_sync_iterator(it: Iterator[bytes] | bytes) -> Iterator[bytes]:
9
+ if isinstance(it, bytes):
10
+ yield it
11
+ else:
12
+ for chunk in it:
13
+ yield chunk
14
+
15
+
16
+ async def ensure_async_iterator(
17
+ it: AsyncIterator[bytes] | bytes,
18
+ ) -> AsyncIterator[bytes]:
19
+ if isinstance(it, bytes):
20
+ yield it
21
+ else:
22
+ async for chunk in it:
23
+ yield chunk
@@ -0,0 +1,166 @@
1
+ """Generated from Smithy shape ``com.amazonaws.appconfigdata#GetLatestConfiguration``."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ from typing import TYPE_CHECKING, Any, Never
7
+
8
+ import zapros
9
+
10
+ import aws_sdk_appconfigdata._auth._signers
11
+ import aws_sdk_appconfigdata._auth._sigv4
12
+ from aws_sdk_appconfigdata._protocol.errors import parse_error_metadata_json
13
+ from aws_sdk_appconfigdata._rule_engine._endpoint_rule_set import (
14
+ EndpointParams,
15
+ resolve,
16
+ )
17
+ from aws_sdk_appconfigdata._services._pipeline import (
18
+ AsyncOperationOptions,
19
+ OperationOptions,
20
+ )
21
+ from aws_sdk_appconfigdata.errors import UnknownServiceError
22
+
23
+ if TYPE_CHECKING:
24
+ import aws_sdk_appconfigdata.types.get_latest_configuration_request
25
+ import aws_sdk_appconfigdata.types.get_latest_configuration_response
26
+
27
+
28
+ def handle_error(response: zapros.Response) -> Never:
29
+ data = json.loads(response.read())
30
+ code, message = parse_error_metadata_json(response, data)
31
+ match code:
32
+ case "BadRequestException":
33
+ import aws_sdk_appconfigdata.errors.bad_request_exception
34
+
35
+ raise aws_sdk_appconfigdata.errors.bad_request_exception.BadRequestException.from_json(
36
+ data
37
+ )
38
+ case "InternalServerException":
39
+ import aws_sdk_appconfigdata.errors.internal_server_exception
40
+
41
+ raise aws_sdk_appconfigdata.errors.internal_server_exception.InternalServerException.from_json(
42
+ data
43
+ )
44
+ case "ResourceNotFoundException":
45
+ import aws_sdk_appconfigdata.errors.resource_not_found_exception
46
+
47
+ raise aws_sdk_appconfigdata.errors.resource_not_found_exception.ResourceNotFoundException.from_json(
48
+ data
49
+ )
50
+ case "ThrottlingException":
51
+ import aws_sdk_appconfigdata.errors.throttling_exception
52
+
53
+ raise aws_sdk_appconfigdata.errors.throttling_exception.ThrottlingException.from_json(
54
+ data
55
+ )
56
+ case _:
57
+ raise UnknownServiceError(code=code, message=message, response=response)
58
+
59
+
60
+ def handle_response(
61
+ response: zapros.Response, is_async: bool
62
+ ) -> aws_sdk_appconfigdata.types.get_latest_configuration_response.GetLatestConfigurationResponse:
63
+ import aws_sdk_appconfigdata.types.sensitive_blob
64
+
65
+ out: aws_sdk_appconfigdata.types.get_latest_configuration_response.GetLatestConfigurationResponse = {
66
+ "configuration": aws_sdk_appconfigdata.types.sensitive_blob.deserialize_json(
67
+ json.loads(response.read())
68
+ )
69
+ } # type: ignore[typeddict-item]
70
+ if "Next-Poll-Configuration-Token" in response.headers:
71
+ out["next_poll_configuration_token"] = str(
72
+ response.headers["Next-Poll-Configuration-Token"]
73
+ )
74
+ out["next_poll_interval_in_seconds"] = int(
75
+ response.headers["Next-Poll-Interval-In-Seconds"]
76
+ )
77
+ if "Content-Type" in response.headers:
78
+ out["content_type"] = str(response.headers["Content-Type"])
79
+ if "Version-Label" in response.headers:
80
+ out["version_label"] = str(response.headers["Version-Label"])
81
+ return out
82
+
83
+
84
+ def get_signer(
85
+ options: AsyncOperationOptions | OperationOptions,
86
+ auth_schemes: list[dict[str, Any]] | None = None,
87
+ ) -> aws_sdk_appconfigdata._auth._signers.Signer | None:
88
+ name_to_schema = {s["name"]: s for s in (auth_schemes or [])} # noqa: F841
89
+ if options.credentials_provider is not None:
90
+ sigv4_config = (
91
+ name_to_schema.get("sigv4")
92
+ or name_to_schema.get("sigv4a")
93
+ or name_to_schema.get("sigv4-s3express")
94
+ or aws_sdk_appconfigdata._auth._sigv4.build_sigv4_auth_scheme(
95
+ "appconfig", options.region
96
+ )
97
+ )
98
+ if sigv4_config is not None:
99
+ return aws_sdk_appconfigdata._auth._signers.SigV4Signer(
100
+ options.credentials_provider, auth_scheme=sigv4_config
101
+ )
102
+ raise RuntimeError("Auth was not resolved")
103
+
104
+
105
+ def build_request(
106
+ options: OperationOptions | AsyncOperationOptions,
107
+ input_: aws_sdk_appconfigdata.types.get_latest_configuration_request.GetLatestConfigurationRequest,
108
+ ) -> zapros.Request:
109
+ endpoint = resolve(
110
+ EndpointParams(
111
+ Region=options.region,
112
+ UseDualStack=options.use_dual_stack,
113
+ UseFIPS=options.use_fips,
114
+ Endpoint=options.endpoint,
115
+ )
116
+ ) # noqa: F841
117
+ url = endpoint.url.rstrip("/") + "/configuration"
118
+ params: dict[str, str] = {}
119
+ if "configuration_token" in input_:
120
+ params["configuration_token"] = str(input_["configuration_token"])
121
+ headers: dict[str, str] = {k: ", ".join(v) for k, v in endpoint.headers.items()}
122
+ body: bytes | None = b""
123
+ signer = get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
124
+ normalized_url = zapros.URL(url)
125
+ normalized_url.search_params.update(params)
126
+ return zapros.Request(
127
+ normalized_url, "GET", headers=headers, body=body, context={"signer": signer}
128
+ )
129
+
130
+
131
+ def get_latest_configuration(
132
+ options: OperationOptions,
133
+ input_: aws_sdk_appconfigdata.types.get_latest_configuration_request.GetLatestConfigurationRequest,
134
+ ) -> tuple[
135
+ aws_sdk_appconfigdata.types.get_latest_configuration_response.GetLatestConfigurationResponse,
136
+ zapros.Response,
137
+ ]:
138
+ response = options.client.handler.handle(build_request(options, input_))
139
+ try:
140
+ if response.status >= 400:
141
+ response.read()
142
+ handle_error(response)
143
+ response.read()
144
+ return handle_response(response, is_async=False), response
145
+ except BaseException:
146
+ response.close()
147
+ raise
148
+
149
+
150
+ async def async_get_latest_configuration(
151
+ options: AsyncOperationOptions,
152
+ input_: aws_sdk_appconfigdata.types.get_latest_configuration_request.GetLatestConfigurationRequest,
153
+ ) -> tuple[
154
+ aws_sdk_appconfigdata.types.get_latest_configuration_response.GetLatestConfigurationResponse,
155
+ zapros.Response,
156
+ ]:
157
+ response = await options.client.handler.ahandle(build_request(options, input_))
158
+ try:
159
+ if response.status >= 400:
160
+ await response.aread()
161
+ handle_error(response)
162
+ await response.aread()
163
+ return handle_response(response, is_async=True), response
164
+ except BaseException:
165
+ await response.aclose()
166
+ raise
@@ -0,0 +1,158 @@
1
+ """Generated from Smithy shape ``com.amazonaws.appconfigdata#StartConfigurationSession``."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ from typing import TYPE_CHECKING, Any, Never
7
+
8
+ import zapros
9
+
10
+ import aws_sdk_appconfigdata._auth._signers
11
+ import aws_sdk_appconfigdata._auth._sigv4
12
+ from aws_sdk_appconfigdata._protocol.errors import parse_error_metadata_json
13
+ from aws_sdk_appconfigdata._rule_engine._endpoint_rule_set import (
14
+ EndpointParams,
15
+ resolve,
16
+ )
17
+ from aws_sdk_appconfigdata._services._pipeline import (
18
+ AsyncOperationOptions,
19
+ OperationOptions,
20
+ )
21
+ from aws_sdk_appconfigdata.errors import UnknownServiceError
22
+
23
+ if TYPE_CHECKING:
24
+ import aws_sdk_appconfigdata.types.start_configuration_session_request
25
+ import aws_sdk_appconfigdata.types.start_configuration_session_response
26
+
27
+
28
+ def handle_error(response: zapros.Response) -> Never:
29
+ data = json.loads(response.read())
30
+ code, message = parse_error_metadata_json(response, data)
31
+ match code:
32
+ case "BadRequestException":
33
+ import aws_sdk_appconfigdata.errors.bad_request_exception
34
+
35
+ raise aws_sdk_appconfigdata.errors.bad_request_exception.BadRequestException.from_json(
36
+ data
37
+ )
38
+ case "InternalServerException":
39
+ import aws_sdk_appconfigdata.errors.internal_server_exception
40
+
41
+ raise aws_sdk_appconfigdata.errors.internal_server_exception.InternalServerException.from_json(
42
+ data
43
+ )
44
+ case "ResourceNotFoundException":
45
+ import aws_sdk_appconfigdata.errors.resource_not_found_exception
46
+
47
+ raise aws_sdk_appconfigdata.errors.resource_not_found_exception.ResourceNotFoundException.from_json(
48
+ data
49
+ )
50
+ case "ThrottlingException":
51
+ import aws_sdk_appconfigdata.errors.throttling_exception
52
+
53
+ raise aws_sdk_appconfigdata.errors.throttling_exception.ThrottlingException.from_json(
54
+ data
55
+ )
56
+ case _:
57
+ raise UnknownServiceError(code=code, message=message, response=response)
58
+
59
+
60
+ def handle_response(
61
+ response: zapros.Response, is_async: bool
62
+ ) -> aws_sdk_appconfigdata.types.start_configuration_session_response.StartConfigurationSessionResponse:
63
+ import aws_sdk_appconfigdata.types.start_configuration_session_response
64
+
65
+ out: aws_sdk_appconfigdata.types.start_configuration_session_response.StartConfigurationSessionResponse = aws_sdk_appconfigdata.types.start_configuration_session_response.deserialize_json(
66
+ json.loads(response.read())
67
+ )
68
+ return out
69
+
70
+
71
+ def get_signer(
72
+ options: AsyncOperationOptions | OperationOptions,
73
+ auth_schemes: list[dict[str, Any]] | None = None,
74
+ ) -> aws_sdk_appconfigdata._auth._signers.Signer | None:
75
+ name_to_schema = {s["name"]: s for s in (auth_schemes or [])} # noqa: F841
76
+ if options.credentials_provider is not None:
77
+ sigv4_config = (
78
+ name_to_schema.get("sigv4")
79
+ or name_to_schema.get("sigv4a")
80
+ or name_to_schema.get("sigv4-s3express")
81
+ or aws_sdk_appconfigdata._auth._sigv4.build_sigv4_auth_scheme(
82
+ "appconfig", options.region
83
+ )
84
+ )
85
+ if sigv4_config is not None:
86
+ return aws_sdk_appconfigdata._auth._signers.SigV4Signer(
87
+ options.credentials_provider, auth_scheme=sigv4_config
88
+ )
89
+ raise RuntimeError("Auth was not resolved")
90
+
91
+
92
+ def build_request(
93
+ options: OperationOptions | AsyncOperationOptions,
94
+ input_: aws_sdk_appconfigdata.types.start_configuration_session_request.StartConfigurationSessionRequest,
95
+ ) -> zapros.Request:
96
+ endpoint = resolve(
97
+ EndpointParams(
98
+ Region=options.region,
99
+ UseDualStack=options.use_dual_stack,
100
+ UseFIPS=options.use_fips,
101
+ Endpoint=options.endpoint,
102
+ )
103
+ ) # noqa: F841
104
+ url = endpoint.url.rstrip("/") + "/configurationsessions"
105
+ params: dict[str, str] = {}
106
+ headers: dict[str, str] = {k: ", ".join(v) for k, v in endpoint.headers.items()}
107
+ import aws_sdk_appconfigdata.types.start_configuration_session_request
108
+
109
+ body: bytes | None = json.dumps(
110
+ aws_sdk_appconfigdata.types.start_configuration_session_request.serialize_json(
111
+ input_
112
+ )
113
+ ).encode()
114
+ headers["content-type"] = "application/json"
115
+ signer = get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
116
+ normalized_url = zapros.URL(url)
117
+ normalized_url.search_params.update(params)
118
+ return zapros.Request(
119
+ normalized_url, "POST", headers=headers, body=body, context={"signer": signer}
120
+ )
121
+
122
+
123
+ def start_configuration_session(
124
+ options: OperationOptions,
125
+ input_: aws_sdk_appconfigdata.types.start_configuration_session_request.StartConfigurationSessionRequest,
126
+ ) -> tuple[
127
+ aws_sdk_appconfigdata.types.start_configuration_session_response.StartConfigurationSessionResponse,
128
+ zapros.Response,
129
+ ]:
130
+ response = options.client.handler.handle(build_request(options, input_))
131
+ try:
132
+ if response.status >= 400:
133
+ response.read()
134
+ handle_error(response)
135
+ response.read()
136
+ return handle_response(response, is_async=False), response
137
+ except BaseException:
138
+ response.close()
139
+ raise
140
+
141
+
142
+ async def async_start_configuration_session(
143
+ options: AsyncOperationOptions,
144
+ input_: aws_sdk_appconfigdata.types.start_configuration_session_request.StartConfigurationSessionRequest,
145
+ ) -> tuple[
146
+ aws_sdk_appconfigdata.types.start_configuration_session_response.StartConfigurationSessionResponse,
147
+ zapros.Response,
148
+ ]:
149
+ response = await options.client.handler.ahandle(build_request(options, input_))
150
+ try:
151
+ if response.status >= 400:
152
+ await response.aread()
153
+ handle_error(response)
154
+ await response.aread()
155
+ return handle_response(response, is_async=True), response
156
+ except BaseException:
157
+ await response.aclose()
158
+ raise
@@ -0,0 +1,21 @@
1
+ """Runtime helpers for generated paginated ``iter_*`` operation methods."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+
8
+ def resolve_path(obj: Any, path: tuple[str, ...]) -> Any:
9
+ """Walk ``path`` segments on a nested ``dict`` (TypedDict at runtime).
10
+
11
+ Returns ``None`` as soon as any intermediate value is missing or non-dict —
12
+ the generated iter loop uses a falsy token as the terminate signal, so this
13
+ short-circuit gives the same semantics for dotted paths as for top-level ones.
14
+ """
15
+ for key in path:
16
+ if not isinstance(obj, dict):
17
+ return None
18
+ obj = obj.get(key)
19
+ if obj is None:
20
+ return None
21
+ return obj
@@ -0,0 +1 @@
1
+ """Protocol runtime modules. Hand-written; not generated."""
@@ -0,0 +1,59 @@
1
+ """Shared service-error runtime.
2
+
3
+ Hand-written, not regenerated. Helpers for extracting error metadata
4
+ from HTTP error responses.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from typing import TYPE_CHECKING
10
+
11
+ from zapros import Response
12
+
13
+ if TYPE_CHECKING:
14
+ from xml.etree.ElementTree import Element
15
+
16
+
17
+ def parse_error_metadata(root: Element) -> tuple[str | None, str | None]:
18
+ """Return ``(code, message)`` from a restXml error envelope.
19
+
20
+ Accepts either an ``<Error>`` element directly or an
21
+ ``<ErrorResponse>`` wrapper whose first ``<Error>`` child holds the
22
+ metadata. Missing children yield ``None``.
23
+ """
24
+ err = root if root.tag.endswith("Error") else root.find("Error")
25
+ if err is None:
26
+ return None, None
27
+ code_el = err.find("Code")
28
+ msg_el = err.find("Message")
29
+ code = code_el.text if code_el is not None else None
30
+ message = msg_el.text if msg_el is not None else None
31
+ return code, message
32
+
33
+
34
+ def parse_error_metadata_json(
35
+ response: Response, data: dict
36
+ ) -> tuple[str | None, str | None]:
37
+ """Return ``(code, message)`` from a restJson1 error response.
38
+
39
+ Code precedence: the ``X-Amzn-Errortype`` response header, then the
40
+ ``__type`` body field, then ``code``. The raw value is normalized by
41
+ dropping a ``prefix#`` namespace and a trailing ``:uri`` suffix.
42
+ Message comes from ``message`` or ``Message``. Missing values yield
43
+ ``None``.
44
+ """
45
+ code = (
46
+ response.headers.get("X-Amzn-Errortype")
47
+ or data.get("__type")
48
+ or data.get("code")
49
+ )
50
+ if code is not None:
51
+ code = code.rsplit("#", 1)[-1].split(":", 1)[0]
52
+ message = data.get("message") or data.get("Message")
53
+ return code, message
54
+
55
+
56
+ __all__ = [
57
+ "parse_error_metadata",
58
+ "parse_error_metadata_json",
59
+ ]
@@ -0,0 +1,27 @@
1
+ """Shared XML protocol runtime.
2
+
3
+ Hand-written, not regenerated. Holds re-exports of
4
+ ``xml.etree.ElementTree`` primitives generated code depends on.
5
+ """
6
+
7
+ from xml.etree.ElementTree import Element, SubElement, tostring
8
+ from xml.etree.ElementTree import fromstring as _fromstring
9
+
10
+
11
+ def fromstring(text: str | bytes) -> Element:
12
+ """Parse XML and strip namespaces so generated ``el.find("Tag")``
13
+ lookups match. AWS restXml responses use a default namespace which
14
+ ElementTree otherwise qualifies onto every tag as ``{ns}Tag``."""
15
+ root = _fromstring(text)
16
+ for el in root.iter():
17
+ if el.tag.startswith("{"):
18
+ el.tag = el.tag.rpartition("}")[2]
19
+ return root
20
+
21
+
22
+ __all__ = [
23
+ "Element",
24
+ "SubElement",
25
+ "fromstring",
26
+ "tostring",
27
+ ]
@@ -0,0 +1,141 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Optional
4
+
5
+ import aws_sdk_appconfigdata._auth._signers
6
+ import aws_sdk_appconfigdata._auth._sigv4
7
+ from aws_sdk_appconfigdata._services._pipeline import (
8
+ AsyncOperationRequest,
9
+ AsyncOperationResponse,
10
+ OperationRequest,
11
+ OperationResponse,
12
+ aexecute_pipeline,
13
+ execute_pipeline,
14
+ )
15
+
16
+ if TYPE_CHECKING:
17
+ import aws_sdk_appconfigdata.types.identifier
18
+ import aws_sdk_appconfigdata.types.optional_poll_seconds
19
+ import aws_sdk_appconfigdata.types.start_configuration_session_request
20
+ import aws_sdk_appconfigdata.types.start_configuration_session_response
21
+ from aws_sdk_appconfigdata._services.app_config_data import (
22
+ AppConfigDataClient,
23
+ AppConfigDataClientConfig,
24
+ )
25
+ from aws_sdk_appconfigdata._services.async_app_config_data import (
26
+ AsyncAppConfigDataClient,
27
+ AsyncAppConfigDataClientConfig,
28
+ )
29
+
30
+
31
+ class ConfigurationSession:
32
+ def __init__(self, service: AppConfigDataClient) -> None:
33
+ self._service = service
34
+
35
+ def create(
36
+ self,
37
+ application_identifier: "aws_sdk_appconfigdata.types.identifier.Identifier",
38
+ environment_identifier: "aws_sdk_appconfigdata.types.identifier.Identifier",
39
+ configuration_profile_identifier: "aws_sdk_appconfigdata.types.identifier.Identifier",
40
+ *,
41
+ config_overrides: Optional[AppConfigDataClientConfig] = None,
42
+ required_minimum_poll_interval_in_seconds: Optional[
43
+ "aws_sdk_appconfigdata.types.optional_poll_seconds.OptionalPollSeconds"
44
+ ] = None,
45
+ ) -> "aws_sdk_appconfigdata.types.start_configuration_session_response.StartConfigurationSessionResponse":
46
+ r"""<p>Starts a configuration session used to retrieve a deployed configuration. For more information about this API action and to view example CLI commands that show how to use it with the <a>GetLatestConfiguration</a> API action, see <a href=\"http://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-retrieving-the-configuration\">Retrieving the configuration</a> in the <i>AppConfig User Guide</i>. </p>
47
+
48
+ Args:
49
+ application_identifier: <p>The application ID or the application name.</p>
50
+ environment_identifier: <p>The environment ID or the environment name.</p>
51
+ configuration_profile_identifier: <p>The configuration profile ID or the configuration profile name.</p>
52
+ required_minimum_poll_interval_in_seconds: <p>Sets a constraint on a session. If you specify a value of, for example, 60 seconds, then the client that established the session can't call <a>GetLatestConfiguration</a> more frequently than every 60 seconds.</p>
53
+ """
54
+
55
+ def _handler(
56
+ req: "OperationRequest[aws_sdk_appconfigdata.types.start_configuration_session_request.StartConfigurationSessionRequest]",
57
+ ) -> OperationResponse[
58
+ "aws_sdk_appconfigdata.types.start_configuration_session_response.StartConfigurationSessionResponse"
59
+ ]:
60
+ import aws_sdk_appconfigdata._operations.app_config_data.start_configuration_session
61
+
62
+ output, http_response = (
63
+ aws_sdk_appconfigdata._operations.app_config_data.start_configuration_session.start_configuration_session(
64
+ req.options, req.input
65
+ )
66
+ )
67
+ return OperationResponse(output=output, response=http_response)
68
+
69
+ interceptors_, options_ = self._service.operation_options(config_overrides)
70
+ input_: aws_sdk_appconfigdata.types.start_configuration_session_request.StartConfigurationSessionRequest = {} # type: ignore[typeddict-item]
71
+ input_["application_identifier"] = application_identifier
72
+ input_["environment_identifier"] = environment_identifier
73
+ input_["configuration_profile_identifier"] = configuration_profile_identifier
74
+ if required_minimum_poll_interval_in_seconds is not None:
75
+ input_["required_minimum_poll_interval_in_seconds"] = (
76
+ required_minimum_poll_interval_in_seconds
77
+ )
78
+
79
+ response = execute_pipeline(
80
+ OperationRequest(input=input_, options=options_),
81
+ handler=_handler,
82
+ interceptors=list(interceptors_),
83
+ )
84
+ return response.output
85
+
86
+
87
+ class AsyncConfigurationSession:
88
+ def __init__(self, service: AsyncAppConfigDataClient) -> None:
89
+ self._service = service
90
+
91
+ async def create(
92
+ self,
93
+ application_identifier: "aws_sdk_appconfigdata.types.identifier.Identifier",
94
+ environment_identifier: "aws_sdk_appconfigdata.types.identifier.Identifier",
95
+ configuration_profile_identifier: "aws_sdk_appconfigdata.types.identifier.Identifier",
96
+ *,
97
+ config_overrides: Optional[AsyncAppConfigDataClientConfig] = None,
98
+ required_minimum_poll_interval_in_seconds: Optional[
99
+ "aws_sdk_appconfigdata.types.optional_poll_seconds.OptionalPollSeconds"
100
+ ] = None,
101
+ ) -> "aws_sdk_appconfigdata.types.start_configuration_session_response.StartConfigurationSessionResponse":
102
+ r"""<p>Starts a configuration session used to retrieve a deployed configuration. For more information about this API action and to view example CLI commands that show how to use it with the <a>GetLatestConfiguration</a> API action, see <a href=\"http://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-retrieving-the-configuration\">Retrieving the configuration</a> in the <i>AppConfig User Guide</i>. </p>
103
+
104
+ Args:
105
+ application_identifier: <p>The application ID or the application name.</p>
106
+ environment_identifier: <p>The environment ID or the environment name.</p>
107
+ configuration_profile_identifier: <p>The configuration profile ID or the configuration profile name.</p>
108
+ required_minimum_poll_interval_in_seconds: <p>Sets a constraint on a session. If you specify a value of, for example, 60 seconds, then the client that established the session can't call <a>GetLatestConfiguration</a> more frequently than every 60 seconds.</p>
109
+ """
110
+
111
+ async def _handler(
112
+ req: "AsyncOperationRequest[aws_sdk_appconfigdata.types.start_configuration_session_request.StartConfigurationSessionRequest]",
113
+ ) -> AsyncOperationResponse[
114
+ "aws_sdk_appconfigdata.types.start_configuration_session_response.StartConfigurationSessionResponse"
115
+ ]:
116
+ import aws_sdk_appconfigdata._operations.app_config_data.start_configuration_session
117
+
118
+ (
119
+ output,
120
+ http_response,
121
+ ) = await aws_sdk_appconfigdata._operations.app_config_data.start_configuration_session.async_start_configuration_session(
122
+ req.options, req.input
123
+ )
124
+ return AsyncOperationResponse(output=output, response=http_response)
125
+
126
+ interceptors_, options_ = self._service.operation_options(config_overrides)
127
+ input_: aws_sdk_appconfigdata.types.start_configuration_session_request.StartConfigurationSessionRequest = {} # type: ignore[typeddict-item]
128
+ input_["application_identifier"] = application_identifier
129
+ input_["environment_identifier"] = environment_identifier
130
+ input_["configuration_profile_identifier"] = configuration_profile_identifier
131
+ if required_minimum_poll_interval_in_seconds is not None:
132
+ input_["required_minimum_poll_interval_in_seconds"] = (
133
+ required_minimum_poll_interval_in_seconds
134
+ )
135
+
136
+ response = await aexecute_pipeline(
137
+ AsyncOperationRequest(input=input_, options=options_),
138
+ handler=_handler,
139
+ interceptors=list(interceptors_),
140
+ )
141
+ return response.output
File without changes