capo-workspaces-thin-client 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 (144) hide show
  1. capo_workspaces_thin_client/__init__.py +74 -0
  2. capo_workspaces_thin_client/_async.py +25 -0
  3. capo_workspaces_thin_client/_auth/_identity.py +16 -0
  4. capo_workspaces_thin_client/_auth/_providers.py +886 -0
  5. capo_workspaces_thin_client/_auth/_signers.py +88 -0
  6. capo_workspaces_thin_client/_auth/_sigv4.py +434 -0
  7. capo_workspaces_thin_client/_auth/_zapros_handler.py +80 -0
  8. capo_workspaces_thin_client/_iter.py +113 -0
  9. capo_workspaces_thin_client/_operations/thin_client/create_environment.py +189 -0
  10. capo_workspaces_thin_client/_operations/thin_client/delete_device.py +172 -0
  11. capo_workspaces_thin_client/_operations/thin_client/delete_environment.py +172 -0
  12. capo_workspaces_thin_client/_operations/thin_client/deregister_device.py +177 -0
  13. capo_workspaces_thin_client/_operations/thin_client/get_device.py +174 -0
  14. capo_workspaces_thin_client/_operations/thin_client/get_environment.py +170 -0
  15. capo_workspaces_thin_client/_operations/thin_client/get_software_set.py +170 -0
  16. capo_workspaces_thin_client/_operations/thin_client/list_devices.py +171 -0
  17. capo_workspaces_thin_client/_operations/thin_client/list_environments.py +167 -0
  18. capo_workspaces_thin_client/_operations/thin_client/list_software_sets.py +167 -0
  19. capo_workspaces_thin_client/_operations/thin_client/list_tags_for_resource.py +170 -0
  20. capo_workspaces_thin_client/_operations/thin_client/tag_resource.py +175 -0
  21. capo_workspaces_thin_client/_operations/thin_client/untag_resource.py +173 -0
  22. capo_workspaces_thin_client/_operations/thin_client/update_device.py +175 -0
  23. capo_workspaces_thin_client/_operations/thin_client/update_environment.py +185 -0
  24. capo_workspaces_thin_client/_operations/thin_client/update_software_set.py +172 -0
  25. capo_workspaces_thin_client/_pagination.py +21 -0
  26. capo_workspaces_thin_client/_protocol/__init__.py +1 -0
  27. capo_workspaces_thin_client/_protocol/errors.py +93 -0
  28. capo_workspaces_thin_client/_protocol/eventstream.py +238 -0
  29. capo_workspaces_thin_client/_protocol/serialize.py +47 -0
  30. capo_workspaces_thin_client/_protocol/xml.py +33 -0
  31. capo_workspaces_thin_client/_rule_engine/__init__.py +0 -0
  32. capo_workspaces_thin_client/_rule_engine/_aws_partition.py +160 -0
  33. capo_workspaces_thin_client/_rule_engine/_endpoint_rule_set.py +137 -0
  34. capo_workspaces_thin_client/_rule_engine/_endpoint_runtime.py +389 -0
  35. capo_workspaces_thin_client/_services/_aws_config.py +160 -0
  36. capo_workspaces_thin_client/_services/_pipeline.py +198 -0
  37. capo_workspaces_thin_client/_services/async_work_spaces_thin_client.py +1224 -0
  38. capo_workspaces_thin_client/_services/work_spaces_thin_client.py +1206 -0
  39. capo_workspaces_thin_client/errors/__init__.py +36 -0
  40. capo_workspaces_thin_client/errors/_base.py +94 -0
  41. capo_workspaces_thin_client/errors/access_denied_exception.py +53 -0
  42. capo_workspaces_thin_client/errors/conflict_exception.py +67 -0
  43. capo_workspaces_thin_client/errors/internal_server_exception.py +58 -0
  44. capo_workspaces_thin_client/errors/resource_not_found_exception.py +69 -0
  45. capo_workspaces_thin_client/errors/service_quota_exceeded_exception.py +87 -0
  46. capo_workspaces_thin_client/errors/throttling_exception.py +72 -0
  47. capo_workspaces_thin_client/errors/validation_exception.py +93 -0
  48. capo_workspaces_thin_client/py.typed +0 -0
  49. capo_workspaces_thin_client/types/_prelude/blob.py +12 -0
  50. capo_workspaces_thin_client/types/_prelude/timestamp.py +17 -0
  51. capo_workspaces_thin_client/types/activation_code.py +5 -0
  52. capo_workspaces_thin_client/types/apply_time_of.py +17 -0
  53. capo_workspaces_thin_client/types/arn.py +5 -0
  54. capo_workspaces_thin_client/types/client_token.py +5 -0
  55. capo_workspaces_thin_client/types/create_environment_request.py +173 -0
  56. capo_workspaces_thin_client/types/create_environment_response.py +42 -0
  57. capo_workspaces_thin_client/types/day_of_week.py +22 -0
  58. capo_workspaces_thin_client/types/day_of_week_list.py +31 -0
  59. capo_workspaces_thin_client/types/delete_device_request.py +29 -0
  60. capo_workspaces_thin_client/types/delete_device_response.py +18 -0
  61. capo_workspaces_thin_client/types/delete_environment_request.py +29 -0
  62. capo_workspaces_thin_client/types/delete_environment_response.py +18 -0
  63. capo_workspaces_thin_client/types/deregister_device_request.py +54 -0
  64. capo_workspaces_thin_client/types/deregister_device_response.py +18 -0
  65. capo_workspaces_thin_client/types/desktop_endpoint.py +5 -0
  66. capo_workspaces_thin_client/types/desktop_type.py +18 -0
  67. capo_workspaces_thin_client/types/device.py +267 -0
  68. capo_workspaces_thin_client/types/device_creation_tag_key.py +5 -0
  69. capo_workspaces_thin_client/types/device_creation_tag_value.py +5 -0
  70. capo_workspaces_thin_client/types/device_creation_tags_map.py +29 -0
  71. capo_workspaces_thin_client/types/device_id.py +5 -0
  72. capo_workspaces_thin_client/types/device_list.py +35 -0
  73. capo_workspaces_thin_client/types/device_name.py +5 -0
  74. capo_workspaces_thin_client/types/device_software_set_compliance_status.py +18 -0
  75. capo_workspaces_thin_client/types/device_status.py +19 -0
  76. capo_workspaces_thin_client/types/device_summary.py +206 -0
  77. capo_workspaces_thin_client/types/environment.py +263 -0
  78. capo_workspaces_thin_client/types/environment_id.py +5 -0
  79. capo_workspaces_thin_client/types/environment_list.py +35 -0
  80. capo_workspaces_thin_client/types/environment_name.py +5 -0
  81. capo_workspaces_thin_client/types/environment_software_set_compliance_status.py +18 -0
  82. capo_workspaces_thin_client/types/environment_summary.py +202 -0
  83. capo_workspaces_thin_client/types/exception_message.py +5 -0
  84. capo_workspaces_thin_client/types/field_name.py +5 -0
  85. capo_workspaces_thin_client/types/get_device_request.py +24 -0
  86. capo_workspaces_thin_client/types/get_device_response.py +36 -0
  87. capo_workspaces_thin_client/types/get_environment_request.py +24 -0
  88. capo_workspaces_thin_client/types/get_environment_response.py +42 -0
  89. capo_workspaces_thin_client/types/get_software_set_request.py +24 -0
  90. capo_workspaces_thin_client/types/get_software_set_response.py +42 -0
  91. capo_workspaces_thin_client/types/hour.py +5 -0
  92. capo_workspaces_thin_client/types/kms_key_arn.py +5 -0
  93. capo_workspaces_thin_client/types/list_devices_request.py +29 -0
  94. capo_workspaces_thin_client/types/list_devices_response.py +45 -0
  95. capo_workspaces_thin_client/types/list_environments_request.py +29 -0
  96. capo_workspaces_thin_client/types/list_environments_response.py +51 -0
  97. capo_workspaces_thin_client/types/list_software_sets_request.py +29 -0
  98. capo_workspaces_thin_client/types/list_software_sets_response.py +51 -0
  99. capo_workspaces_thin_client/types/list_tags_for_resource_request.py +19 -0
  100. capo_workspaces_thin_client/types/list_tags_for_resource_response.py +36 -0
  101. capo_workspaces_thin_client/types/maintenance_window.py +111 -0
  102. capo_workspaces_thin_client/types/maintenance_window_type.py +17 -0
  103. capo_workspaces_thin_client/types/max_results.py +5 -0
  104. capo_workspaces_thin_client/types/minute.py +5 -0
  105. capo_workspaces_thin_client/types/pagination_token.py +5 -0
  106. capo_workspaces_thin_client/types/quota_code.py +5 -0
  107. capo_workspaces_thin_client/types/resource_id.py +5 -0
  108. capo_workspaces_thin_client/types/resource_type.py +5 -0
  109. capo_workspaces_thin_client/types/retry_after_seconds.py +5 -0
  110. capo_workspaces_thin_client/types/service_code.py +5 -0
  111. capo_workspaces_thin_client/types/software.py +29 -0
  112. capo_workspaces_thin_client/types/software_list.py +29 -0
  113. capo_workspaces_thin_client/types/software_set.py +120 -0
  114. capo_workspaces_thin_client/types/software_set_id.py +5 -0
  115. capo_workspaces_thin_client/types/software_set_id_or_empty_string.py +5 -0
  116. capo_workspaces_thin_client/types/software_set_list.py +37 -0
  117. capo_workspaces_thin_client/types/software_set_summary.py +99 -0
  118. capo_workspaces_thin_client/types/software_set_update_mode.py +17 -0
  119. capo_workspaces_thin_client/types/software_set_update_schedule.py +17 -0
  120. capo_workspaces_thin_client/types/software_set_update_status.py +18 -0
  121. capo_workspaces_thin_client/types/software_set_validation_status.py +17 -0
  122. capo_workspaces_thin_client/types/tag_keys.py +14 -0
  123. capo_workspaces_thin_client/types/tag_resource_request.py +41 -0
  124. capo_workspaces_thin_client/types/tag_resource_response.py +18 -0
  125. capo_workspaces_thin_client/types/tags_map.py +22 -0
  126. capo_workspaces_thin_client/types/target_device_status.py +17 -0
  127. capo_workspaces_thin_client/types/timestamp.py +20 -0
  128. capo_workspaces_thin_client/types/untag_resource_request.py +26 -0
  129. capo_workspaces_thin_client/types/untag_resource_response.py +18 -0
  130. capo_workspaces_thin_client/types/update_device_request.py +61 -0
  131. capo_workspaces_thin_client/types/update_device_response.py +40 -0
  132. capo_workspaces_thin_client/types/update_environment_request.py +142 -0
  133. capo_workspaces_thin_client/types/update_environment_response.py +42 -0
  134. capo_workspaces_thin_client/types/update_software_set_request.py +48 -0
  135. capo_workspaces_thin_client/types/update_software_set_response.py +18 -0
  136. capo_workspaces_thin_client/types/user_id.py +5 -0
  137. capo_workspaces_thin_client/types/validation_exception_field.py +39 -0
  138. capo_workspaces_thin_client/types/validation_exception_field_list.py +39 -0
  139. capo_workspaces_thin_client/types/validation_exception_reason.py +19 -0
  140. capo_workspaces_thin_client-0.1.0.dist-info/METADATA +101 -0
  141. capo_workspaces_thin_client-0.1.0.dist-info/RECORD +144 -0
  142. capo_workspaces_thin_client-0.1.0.dist-info/WHEEL +5 -0
  143. capo_workspaces_thin_client-0.1.0.dist-info/licenses/LICENSE +21 -0
  144. capo_workspaces_thin_client-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,113 @@
1
+ """Iterator helpers used by generated streaming operations.
2
+
3
+ Hand-written, not regenerated.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ from collections.abc import AsyncIterable, AsyncIterator, Callable, Iterable, Iterator
9
+ from typing import Generic, TypeVar, cast
10
+
11
+ T = TypeVar("T")
12
+ U = TypeVar("U")
13
+
14
+
15
+ class AnyIterator(AsyncIterator[T], Iterator[T], Generic[T]):
16
+ """A type that is both a synchronous and asynchronous iterator.
17
+
18
+ Streaming output fields use this so the same TypedDict type works for
19
+ both sync and async operation variants.
20
+ """
21
+
22
+ ...
23
+
24
+
25
+ class StaticAnyIterator(AnyIterator[T], Generic[T]):
26
+ """An :class:`AnyIterator` backed by static, in-memory content.
27
+
28
+ Used when streaming output is produced from already-materialized bytes
29
+ rather than a live stream. The ``content`` is yielded once and remains
30
+ accessible as a public attribute.
31
+ """
32
+
33
+ def __init__(self, content: T) -> None:
34
+ self.content = content
35
+ self._consumed = False
36
+
37
+ def __next__(self) -> T:
38
+ if self._consumed:
39
+ raise StopIteration
40
+ self._consumed = True
41
+ return self.content
42
+
43
+ async def __anext__(self) -> T:
44
+ if self._consumed:
45
+ raise StopAsyncIteration
46
+ self._consumed = True
47
+ return self.content
48
+
49
+
50
+ def map_sync_iterator(iterable: Iterable[T], fn: Callable[[T], U]) -> Iterator[U]:
51
+ """Map ``fn`` over a synchronous iterable, yielding results lazily."""
52
+ for item in iterable:
53
+ yield fn(item)
54
+
55
+
56
+ async def map_async_iterator(
57
+ async_iterable: AsyncIterable[T], fn: Callable[[T], U]
58
+ ) -> AsyncIterator[U]:
59
+ """Map ``fn`` over an asynchronous iterable, yielding results lazily."""
60
+ async for item in async_iterable:
61
+ yield fn(item)
62
+
63
+
64
+ def chain_sync_iterator(*iterables: Iterable[T]) -> Iterator[T]:
65
+ """Yield items from each iterable in order."""
66
+ for iterable in iterables:
67
+ yield from iterable
68
+
69
+
70
+ async def chain_async_iterator(
71
+ prefix: Iterable[T], rest: AsyncIterable[T]
72
+ ) -> AsyncIterator[T]:
73
+ """Yield the synchronous ``prefix`` items, then the async ``rest`` items."""
74
+ for item in prefix:
75
+ yield item
76
+ async for item in rest:
77
+ yield item
78
+
79
+
80
+ def ensure_async_iterator(value: AsyncIterator[T] | T) -> AnyIterator[T]:
81
+ """Return ``value`` as an :class:`AnyIterator`.
82
+
83
+ An async iterator is returned unchanged; a single value is wrapped in a
84
+ fresh single-item async iterator.
85
+ """
86
+ if isinstance(value, AsyncIterator):
87
+ return cast(AnyIterator[T], value)
88
+
89
+ return StaticAnyIterator(value)
90
+
91
+
92
+ def ensure_sync_iterator(value: Iterator[T] | T) -> AnyIterator[T]:
93
+ """Return ``value`` as an :class:`AnyIterator`.
94
+
95
+ A sync iterator is returned unchanged; a single value is wrapped in a
96
+ fresh single-item sync iterator.
97
+ """
98
+ if isinstance(value, Iterator):
99
+ return cast(AnyIterator[T], value)
100
+
101
+ return StaticAnyIterator(value)
102
+
103
+
104
+ __all__ = [
105
+ "AnyIterator",
106
+ "StaticAnyIterator",
107
+ "chain_async_iterator",
108
+ "chain_sync_iterator",
109
+ "ensure_async_iterator",
110
+ "ensure_sync_iterator",
111
+ "map_async_iterator",
112
+ "map_sync_iterator",
113
+ ]
@@ -0,0 +1,189 @@
1
+ """Generated from Smithy shape ``com.amazonaws.workspacesthinclient#CreateEnvironment``."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ from typing import Any
7
+
8
+ import zapros
9
+ from typing_extensions import Never
10
+
11
+ import capo_workspaces_thin_client._auth._signers
12
+ import capo_workspaces_thin_client._auth._sigv4
13
+ import capo_workspaces_thin_client._protocol.eventstream
14
+ import capo_workspaces_thin_client.errors.access_denied_exception
15
+ import capo_workspaces_thin_client.errors.conflict_exception
16
+ import capo_workspaces_thin_client.errors.internal_server_exception
17
+ import capo_workspaces_thin_client.errors.resource_not_found_exception
18
+ import capo_workspaces_thin_client.errors.service_quota_exceeded_exception
19
+ import capo_workspaces_thin_client.errors.throttling_exception
20
+ import capo_workspaces_thin_client.errors.validation_exception
21
+ import capo_workspaces_thin_client.types.create_environment_request
22
+ import capo_workspaces_thin_client.types.create_environment_response
23
+ import capo_workspaces_thin_client.types.device_creation_tags_map
24
+ import capo_workspaces_thin_client.types.environment_summary
25
+ import capo_workspaces_thin_client.types.maintenance_window
26
+ import capo_workspaces_thin_client.types.software_set_update_mode
27
+ import capo_workspaces_thin_client.types.software_set_update_schedule
28
+ import capo_workspaces_thin_client.types.tags_map
29
+ from capo_workspaces_thin_client._protocol.errors import parse_error_metadata_json
30
+ from capo_workspaces_thin_client._rule_engine._endpoint_rule_set import (
31
+ EndpointParams,
32
+ resolve,
33
+ )
34
+ from capo_workspaces_thin_client._services._pipeline import (
35
+ AsyncOperationOptions,
36
+ OperationOptions,
37
+ )
38
+ from capo_workspaces_thin_client.errors import UnknownServiceError
39
+
40
+
41
+ def handle_error(response: zapros.Response) -> Never:
42
+ data = json.loads(response.read())
43
+ code, message = parse_error_metadata_json(response, data)
44
+ match code:
45
+ case "AccessDeniedException":
46
+ raise capo_workspaces_thin_client.errors.access_denied_exception.AccessDeniedException.from_json(
47
+ data, message
48
+ )
49
+ case "ConflictException":
50
+ raise capo_workspaces_thin_client.errors.conflict_exception.ConflictException.from_json(
51
+ data, message
52
+ )
53
+ case "InternalServerException":
54
+ raise capo_workspaces_thin_client.errors.internal_server_exception.InternalServerException.from_json(
55
+ data, message
56
+ )
57
+ case "ResourceNotFoundException":
58
+ raise capo_workspaces_thin_client.errors.resource_not_found_exception.ResourceNotFoundException.from_json(
59
+ data, message
60
+ )
61
+ case "ServiceQuotaExceededException":
62
+ raise capo_workspaces_thin_client.errors.service_quota_exceeded_exception.ServiceQuotaExceededException.from_json(
63
+ data, message
64
+ )
65
+ case "ThrottlingException":
66
+ raise capo_workspaces_thin_client.errors.throttling_exception.ThrottlingException.from_json(
67
+ data, message
68
+ )
69
+ case "ValidationException":
70
+ raise capo_workspaces_thin_client.errors.validation_exception.ValidationException.from_json(
71
+ data, message
72
+ )
73
+ case _:
74
+ raise UnknownServiceError(code=code, message=message, response=response)
75
+
76
+
77
+ def handle_response(
78
+ response: zapros.Response,
79
+ ) -> capo_workspaces_thin_client.types.create_environment_response.CreateEnvironmentResponse:
80
+ out: capo_workspaces_thin_client.types.create_environment_response.CreateEnvironmentResponse = capo_workspaces_thin_client.types.create_environment_response.deserialize_json(
81
+ json.loads(response.read())
82
+ )
83
+ return out
84
+
85
+
86
+ async def async_handle_response(
87
+ response: zapros.Response,
88
+ ) -> capo_workspaces_thin_client.types.create_environment_response.CreateEnvironmentResponse:
89
+ out: capo_workspaces_thin_client.types.create_environment_response.CreateEnvironmentResponse = capo_workspaces_thin_client.types.create_environment_response.deserialize_json(
90
+ json.loads(await response.aread())
91
+ )
92
+ return out
93
+
94
+
95
+ def get_signer(
96
+ options: AsyncOperationOptions | OperationOptions,
97
+ auth_schemes: list[dict[str, Any]] | None = None,
98
+ ) -> capo_workspaces_thin_client._auth._signers.Signer | None:
99
+ name_to_schema = {s["name"]: s for s in (auth_schemes or [])} # noqa: F841
100
+ if (
101
+ options.credentials_provider is not None
102
+ and name_to_schema
103
+ and not name_to_schema.keys() & {"sigv4", "sigv4-s3express"}
104
+ ):
105
+ raise RuntimeError(
106
+ "Endpoint requires an unsupported auth scheme: " + ", ".join(name_to_schema)
107
+ )
108
+ if options.credentials_provider is not None:
109
+ endpoint_scheme = name_to_schema.get("sigv4") or name_to_schema.get(
110
+ "sigv4-s3express"
111
+ )
112
+ if endpoint_scheme is not None or not name_to_schema:
113
+ sigv4_config = (
114
+ capo_workspaces_thin_client._auth._sigv4.build_sigv4_auth_scheme(
115
+ "thinclient", options.region, endpoint_scheme
116
+ )
117
+ )
118
+ if sigv4_config is not None:
119
+ return capo_workspaces_thin_client._auth._signers.SigV4Signer(
120
+ options.credentials_provider, auth_scheme=sigv4_config
121
+ )
122
+ raise RuntimeError("Auth was not resolved")
123
+
124
+
125
+ def build_request(
126
+ options: OperationOptions | AsyncOperationOptions,
127
+ input_: capo_workspaces_thin_client.types.create_environment_request.CreateEnvironmentRequest,
128
+ ) -> zapros.Request:
129
+ endpoint = resolve(
130
+ EndpointParams(
131
+ Region=options.region,
132
+ UseDualStack=options.use_dual_stack,
133
+ UseFIPS=options.use_fips,
134
+ Endpoint=options.endpoint,
135
+ )
136
+ ) # noqa: F841
137
+ url = endpoint.url.rstrip("/") + "/environments"
138
+ params: list[tuple[str, str]] = []
139
+ headers: dict[str, str] = {k: ", ".join(v) for k, v in endpoint.headers.items()}
140
+ body: bytes | None = json.dumps(
141
+ capo_workspaces_thin_client.types.create_environment_request.serialize_json(
142
+ input_
143
+ ),
144
+ allow_nan=False,
145
+ ).encode()
146
+ headers["content-type"] = "application/json"
147
+ signer = get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
148
+ normalized_url = zapros.URL(url)
149
+ for k, v in params:
150
+ normalized_url.search_params.append(k, v)
151
+ return zapros.Request(
152
+ normalized_url, "POST", headers=headers, body=body, context={"signer": signer}
153
+ )
154
+
155
+
156
+ def create_environment(
157
+ options: OperationOptions,
158
+ input_: capo_workspaces_thin_client.types.create_environment_request.CreateEnvironmentRequest,
159
+ ) -> tuple[
160
+ capo_workspaces_thin_client.types.create_environment_response.CreateEnvironmentResponse,
161
+ zapros.Response,
162
+ ]:
163
+ response = options.client.handler.handle(build_request(options, input_))
164
+ try:
165
+ if response.status >= 300:
166
+ response.read()
167
+ handle_error(response)
168
+ return handle_response(response), response
169
+ except BaseException:
170
+ response.close()
171
+ raise
172
+
173
+
174
+ async def async_create_environment(
175
+ options: AsyncOperationOptions,
176
+ input_: capo_workspaces_thin_client.types.create_environment_request.CreateEnvironmentRequest,
177
+ ) -> tuple[
178
+ capo_workspaces_thin_client.types.create_environment_response.CreateEnvironmentResponse,
179
+ zapros.Response,
180
+ ]:
181
+ response = await options.client.handler.ahandle(build_request(options, input_))
182
+ try:
183
+ if response.status >= 300:
184
+ await response.aread()
185
+ handle_error(response)
186
+ return await async_handle_response(response), response
187
+ except BaseException:
188
+ await response.aclose()
189
+ raise
@@ -0,0 +1,172 @@
1
+ """Generated from Smithy shape ``com.amazonaws.workspacesthinclient#DeleteDevice``."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ from typing import Any
7
+ from urllib.parse import quote
8
+
9
+ import zapros
10
+ from typing_extensions import Never
11
+
12
+ import capo_workspaces_thin_client._auth._signers
13
+ import capo_workspaces_thin_client._auth._sigv4
14
+ import capo_workspaces_thin_client._protocol.eventstream
15
+ import capo_workspaces_thin_client.errors.access_denied_exception
16
+ import capo_workspaces_thin_client.errors.conflict_exception
17
+ import capo_workspaces_thin_client.errors.internal_server_exception
18
+ import capo_workspaces_thin_client.errors.resource_not_found_exception
19
+ import capo_workspaces_thin_client.errors.throttling_exception
20
+ import capo_workspaces_thin_client.errors.validation_exception
21
+ import capo_workspaces_thin_client.types.delete_device_request
22
+ import capo_workspaces_thin_client.types.delete_device_response
23
+ from capo_workspaces_thin_client._protocol.errors import parse_error_metadata_json
24
+ from capo_workspaces_thin_client._rule_engine._endpoint_rule_set import (
25
+ EndpointParams,
26
+ resolve,
27
+ )
28
+ from capo_workspaces_thin_client._services._pipeline import (
29
+ AsyncOperationOptions,
30
+ OperationOptions,
31
+ )
32
+ from capo_workspaces_thin_client.errors import UnknownServiceError
33
+
34
+
35
+ def handle_error(response: zapros.Response) -> Never:
36
+ data = json.loads(response.read())
37
+ code, message = parse_error_metadata_json(response, data)
38
+ match code:
39
+ case "AccessDeniedException":
40
+ raise capo_workspaces_thin_client.errors.access_denied_exception.AccessDeniedException.from_json(
41
+ data, message
42
+ )
43
+ case "ConflictException":
44
+ raise capo_workspaces_thin_client.errors.conflict_exception.ConflictException.from_json(
45
+ data, message
46
+ )
47
+ case "InternalServerException":
48
+ raise capo_workspaces_thin_client.errors.internal_server_exception.InternalServerException.from_json(
49
+ data, message
50
+ )
51
+ case "ResourceNotFoundException":
52
+ raise capo_workspaces_thin_client.errors.resource_not_found_exception.ResourceNotFoundException.from_json(
53
+ data, message
54
+ )
55
+ case "ThrottlingException":
56
+ raise capo_workspaces_thin_client.errors.throttling_exception.ThrottlingException.from_json(
57
+ data, message
58
+ )
59
+ case "ValidationException":
60
+ raise capo_workspaces_thin_client.errors.validation_exception.ValidationException.from_json(
61
+ data, message
62
+ )
63
+ case _:
64
+ raise UnknownServiceError(code=code, message=message, response=response)
65
+
66
+
67
+ def handle_response(
68
+ response: zapros.Response,
69
+ ) -> capo_workspaces_thin_client.types.delete_device_response.DeleteDeviceResponse:
70
+ out: capo_workspaces_thin_client.types.delete_device_response.DeleteDeviceResponse = {} # type: ignore[typeddict-item]
71
+ return out
72
+
73
+
74
+ async def async_handle_response(
75
+ response: zapros.Response,
76
+ ) -> capo_workspaces_thin_client.types.delete_device_response.DeleteDeviceResponse:
77
+ out: capo_workspaces_thin_client.types.delete_device_response.DeleteDeviceResponse = {} # type: ignore[typeddict-item]
78
+ return out
79
+
80
+
81
+ def get_signer(
82
+ options: AsyncOperationOptions | OperationOptions,
83
+ auth_schemes: list[dict[str, Any]] | None = None,
84
+ ) -> capo_workspaces_thin_client._auth._signers.Signer | None:
85
+ name_to_schema = {s["name"]: s for s in (auth_schemes or [])} # noqa: F841
86
+ if (
87
+ options.credentials_provider is not None
88
+ and name_to_schema
89
+ and not name_to_schema.keys() & {"sigv4", "sigv4-s3express"}
90
+ ):
91
+ raise RuntimeError(
92
+ "Endpoint requires an unsupported auth scheme: " + ", ".join(name_to_schema)
93
+ )
94
+ if options.credentials_provider is not None:
95
+ endpoint_scheme = name_to_schema.get("sigv4") or name_to_schema.get(
96
+ "sigv4-s3express"
97
+ )
98
+ if endpoint_scheme is not None or not name_to_schema:
99
+ sigv4_config = (
100
+ capo_workspaces_thin_client._auth._sigv4.build_sigv4_auth_scheme(
101
+ "thinclient", options.region, endpoint_scheme
102
+ )
103
+ )
104
+ if sigv4_config is not None:
105
+ return capo_workspaces_thin_client._auth._signers.SigV4Signer(
106
+ options.credentials_provider, auth_scheme=sigv4_config
107
+ )
108
+ raise RuntimeError("Auth was not resolved")
109
+
110
+
111
+ def build_request(
112
+ options: OperationOptions | AsyncOperationOptions,
113
+ input_: capo_workspaces_thin_client.types.delete_device_request.DeleteDeviceRequest,
114
+ ) -> zapros.Request:
115
+ endpoint = resolve(
116
+ EndpointParams(
117
+ Region=options.region,
118
+ UseDualStack=options.use_dual_stack,
119
+ UseFIPS=options.use_fips,
120
+ Endpoint=options.endpoint,
121
+ )
122
+ ) # noqa: F841
123
+ url = endpoint.url.rstrip("/") + "/devices/{id}"
124
+ url = url.replace("{id}", quote(input_["id"], safe=""))
125
+ params: list[tuple[str, str]] = []
126
+ if "client_token" in input_:
127
+ params.append(("clientToken", input_["client_token"]))
128
+ headers: dict[str, str] = {k: ", ".join(v) for k, v in endpoint.headers.items()}
129
+ body: bytes | None = b""
130
+ signer = get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
131
+ normalized_url = zapros.URL(url)
132
+ for k, v in params:
133
+ normalized_url.search_params.append(k, v)
134
+ return zapros.Request(
135
+ normalized_url, "DELETE", headers=headers, body=body, context={"signer": signer}
136
+ )
137
+
138
+
139
+ def delete_device(
140
+ options: OperationOptions,
141
+ input_: capo_workspaces_thin_client.types.delete_device_request.DeleteDeviceRequest,
142
+ ) -> tuple[
143
+ capo_workspaces_thin_client.types.delete_device_response.DeleteDeviceResponse,
144
+ zapros.Response,
145
+ ]:
146
+ response = options.client.handler.handle(build_request(options, input_))
147
+ try:
148
+ if response.status >= 300:
149
+ response.read()
150
+ handle_error(response)
151
+ return handle_response(response), response
152
+ except BaseException:
153
+ response.close()
154
+ raise
155
+
156
+
157
+ async def async_delete_device(
158
+ options: AsyncOperationOptions,
159
+ input_: capo_workspaces_thin_client.types.delete_device_request.DeleteDeviceRequest,
160
+ ) -> tuple[
161
+ capo_workspaces_thin_client.types.delete_device_response.DeleteDeviceResponse,
162
+ zapros.Response,
163
+ ]:
164
+ response = await options.client.handler.ahandle(build_request(options, input_))
165
+ try:
166
+ if response.status >= 300:
167
+ await response.aread()
168
+ handle_error(response)
169
+ return await async_handle_response(response), response
170
+ except BaseException:
171
+ await response.aclose()
172
+ raise
@@ -0,0 +1,172 @@
1
+ """Generated from Smithy shape ``com.amazonaws.workspacesthinclient#DeleteEnvironment``."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ from typing import Any
7
+ from urllib.parse import quote
8
+
9
+ import zapros
10
+ from typing_extensions import Never
11
+
12
+ import capo_workspaces_thin_client._auth._signers
13
+ import capo_workspaces_thin_client._auth._sigv4
14
+ import capo_workspaces_thin_client._protocol.eventstream
15
+ import capo_workspaces_thin_client.errors.access_denied_exception
16
+ import capo_workspaces_thin_client.errors.conflict_exception
17
+ import capo_workspaces_thin_client.errors.internal_server_exception
18
+ import capo_workspaces_thin_client.errors.resource_not_found_exception
19
+ import capo_workspaces_thin_client.errors.throttling_exception
20
+ import capo_workspaces_thin_client.errors.validation_exception
21
+ import capo_workspaces_thin_client.types.delete_environment_request
22
+ import capo_workspaces_thin_client.types.delete_environment_response
23
+ from capo_workspaces_thin_client._protocol.errors import parse_error_metadata_json
24
+ from capo_workspaces_thin_client._rule_engine._endpoint_rule_set import (
25
+ EndpointParams,
26
+ resolve,
27
+ )
28
+ from capo_workspaces_thin_client._services._pipeline import (
29
+ AsyncOperationOptions,
30
+ OperationOptions,
31
+ )
32
+ from capo_workspaces_thin_client.errors import UnknownServiceError
33
+
34
+
35
+ def handle_error(response: zapros.Response) -> Never:
36
+ data = json.loads(response.read())
37
+ code, message = parse_error_metadata_json(response, data)
38
+ match code:
39
+ case "AccessDeniedException":
40
+ raise capo_workspaces_thin_client.errors.access_denied_exception.AccessDeniedException.from_json(
41
+ data, message
42
+ )
43
+ case "ConflictException":
44
+ raise capo_workspaces_thin_client.errors.conflict_exception.ConflictException.from_json(
45
+ data, message
46
+ )
47
+ case "InternalServerException":
48
+ raise capo_workspaces_thin_client.errors.internal_server_exception.InternalServerException.from_json(
49
+ data, message
50
+ )
51
+ case "ResourceNotFoundException":
52
+ raise capo_workspaces_thin_client.errors.resource_not_found_exception.ResourceNotFoundException.from_json(
53
+ data, message
54
+ )
55
+ case "ThrottlingException":
56
+ raise capo_workspaces_thin_client.errors.throttling_exception.ThrottlingException.from_json(
57
+ data, message
58
+ )
59
+ case "ValidationException":
60
+ raise capo_workspaces_thin_client.errors.validation_exception.ValidationException.from_json(
61
+ data, message
62
+ )
63
+ case _:
64
+ raise UnknownServiceError(code=code, message=message, response=response)
65
+
66
+
67
+ def handle_response(
68
+ response: zapros.Response,
69
+ ) -> capo_workspaces_thin_client.types.delete_environment_response.DeleteEnvironmentResponse:
70
+ out: capo_workspaces_thin_client.types.delete_environment_response.DeleteEnvironmentResponse = {} # type: ignore[typeddict-item]
71
+ return out
72
+
73
+
74
+ async def async_handle_response(
75
+ response: zapros.Response,
76
+ ) -> capo_workspaces_thin_client.types.delete_environment_response.DeleteEnvironmentResponse:
77
+ out: capo_workspaces_thin_client.types.delete_environment_response.DeleteEnvironmentResponse = {} # type: ignore[typeddict-item]
78
+ return out
79
+
80
+
81
+ def get_signer(
82
+ options: AsyncOperationOptions | OperationOptions,
83
+ auth_schemes: list[dict[str, Any]] | None = None,
84
+ ) -> capo_workspaces_thin_client._auth._signers.Signer | None:
85
+ name_to_schema = {s["name"]: s for s in (auth_schemes or [])} # noqa: F841
86
+ if (
87
+ options.credentials_provider is not None
88
+ and name_to_schema
89
+ and not name_to_schema.keys() & {"sigv4", "sigv4-s3express"}
90
+ ):
91
+ raise RuntimeError(
92
+ "Endpoint requires an unsupported auth scheme: " + ", ".join(name_to_schema)
93
+ )
94
+ if options.credentials_provider is not None:
95
+ endpoint_scheme = name_to_schema.get("sigv4") or name_to_schema.get(
96
+ "sigv4-s3express"
97
+ )
98
+ if endpoint_scheme is not None or not name_to_schema:
99
+ sigv4_config = (
100
+ capo_workspaces_thin_client._auth._sigv4.build_sigv4_auth_scheme(
101
+ "thinclient", options.region, endpoint_scheme
102
+ )
103
+ )
104
+ if sigv4_config is not None:
105
+ return capo_workspaces_thin_client._auth._signers.SigV4Signer(
106
+ options.credentials_provider, auth_scheme=sigv4_config
107
+ )
108
+ raise RuntimeError("Auth was not resolved")
109
+
110
+
111
+ def build_request(
112
+ options: OperationOptions | AsyncOperationOptions,
113
+ input_: capo_workspaces_thin_client.types.delete_environment_request.DeleteEnvironmentRequest,
114
+ ) -> zapros.Request:
115
+ endpoint = resolve(
116
+ EndpointParams(
117
+ Region=options.region,
118
+ UseDualStack=options.use_dual_stack,
119
+ UseFIPS=options.use_fips,
120
+ Endpoint=options.endpoint,
121
+ )
122
+ ) # noqa: F841
123
+ url = endpoint.url.rstrip("/") + "/environments/{id}"
124
+ url = url.replace("{id}", quote(input_["id"], safe=""))
125
+ params: list[tuple[str, str]] = []
126
+ if "client_token" in input_:
127
+ params.append(("clientToken", input_["client_token"]))
128
+ headers: dict[str, str] = {k: ", ".join(v) for k, v in endpoint.headers.items()}
129
+ body: bytes | None = b""
130
+ signer = get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
131
+ normalized_url = zapros.URL(url)
132
+ for k, v in params:
133
+ normalized_url.search_params.append(k, v)
134
+ return zapros.Request(
135
+ normalized_url, "DELETE", headers=headers, body=body, context={"signer": signer}
136
+ )
137
+
138
+
139
+ def delete_environment(
140
+ options: OperationOptions,
141
+ input_: capo_workspaces_thin_client.types.delete_environment_request.DeleteEnvironmentRequest,
142
+ ) -> tuple[
143
+ capo_workspaces_thin_client.types.delete_environment_response.DeleteEnvironmentResponse,
144
+ zapros.Response,
145
+ ]:
146
+ response = options.client.handler.handle(build_request(options, input_))
147
+ try:
148
+ if response.status >= 300:
149
+ response.read()
150
+ handle_error(response)
151
+ return handle_response(response), response
152
+ except BaseException:
153
+ response.close()
154
+ raise
155
+
156
+
157
+ async def async_delete_environment(
158
+ options: AsyncOperationOptions,
159
+ input_: capo_workspaces_thin_client.types.delete_environment_request.DeleteEnvironmentRequest,
160
+ ) -> tuple[
161
+ capo_workspaces_thin_client.types.delete_environment_response.DeleteEnvironmentResponse,
162
+ zapros.Response,
163
+ ]:
164
+ response = await options.client.handler.ahandle(build_request(options, input_))
165
+ try:
166
+ if response.status >= 300:
167
+ await response.aread()
168
+ handle_error(response)
169
+ return await async_handle_response(response), response
170
+ except BaseException:
171
+ await response.aclose()
172
+ raise