capo-lambda-microvms 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 (180) hide show
  1. capo_lambda_microvms/__init__.py +73 -0
  2. capo_lambda_microvms/_async.py +25 -0
  3. capo_lambda_microvms/_auth/_identity.py +16 -0
  4. capo_lambda_microvms/_auth/_providers.py +886 -0
  5. capo_lambda_microvms/_auth/_signers.py +125 -0
  6. capo_lambda_microvms/_auth/_sigv4.py +579 -0
  7. capo_lambda_microvms/_auth/_zapros_handler.py +80 -0
  8. capo_lambda_microvms/_body.py +221 -0
  9. capo_lambda_microvms/_iter.py +113 -0
  10. capo_lambda_microvms/_operations/lambda_microvms/create_microvm_auth_token.py +181 -0
  11. capo_lambda_microvms/_operations/lambda_microvms/create_microvm_image.py +190 -0
  12. capo_lambda_microvms/_operations/lambda_microvms/create_microvm_shell_auth_token.py +181 -0
  13. capo_lambda_microvms/_operations/lambda_microvms/delete_microvm_image.py +170 -0
  14. capo_lambda_microvms/_operations/lambda_microvms/delete_microvm_image_version.py +174 -0
  15. capo_lambda_microvms/_operations/lambda_microvms/get_microvm.py +171 -0
  16. capo_lambda_microvms/_operations/lambda_microvms/get_microvm_image.py +170 -0
  17. capo_lambda_microvms/_operations/lambda_microvms/get_microvm_image_build.py +177 -0
  18. capo_lambda_microvms/_operations/lambda_microvms/get_microvm_image_version.py +179 -0
  19. capo_lambda_microvms/_operations/lambda_microvms/list_managed_microvm_image_versions.py +172 -0
  20. capo_lambda_microvms/_operations/lambda_microvms/list_managed_microvm_images.py +162 -0
  21. capo_lambda_microvms/_operations/lambda_microvms/list_microvm_image_builds.py +196 -0
  22. capo_lambda_microvms/_operations/lambda_microvms/list_microvm_image_versions.py +172 -0
  23. capo_lambda_microvms/_operations/lambda_microvms/list_microvm_images.py +164 -0
  24. capo_lambda_microvms/_operations/lambda_microvms/list_microvms.py +175 -0
  25. capo_lambda_microvms/_operations/lambda_microvms/list_tags.py +182 -0
  26. capo_lambda_microvms/_operations/lambda_microvms/resume_microvm.py +167 -0
  27. capo_lambda_microvms/_operations/lambda_microvms/run_microvm.py +187 -0
  28. capo_lambda_microvms/_operations/lambda_microvms/suspend_microvm.py +167 -0
  29. capo_lambda_microvms/_operations/lambda_microvms/tag_resource.py +164 -0
  30. capo_lambda_microvms/_operations/lambda_microvms/terminate_microvm.py +167 -0
  31. capo_lambda_microvms/_operations/lambda_microvms/untag_resource.py +162 -0
  32. capo_lambda_microvms/_operations/lambda_microvms/update_microvm_image.py +191 -0
  33. capo_lambda_microvms/_operations/lambda_microvms/update_microvm_image_version.py +190 -0
  34. capo_lambda_microvms/_pagination.py +21 -0
  35. capo_lambda_microvms/_protocol/__init__.py +1 -0
  36. capo_lambda_microvms/_protocol/errors.py +93 -0
  37. capo_lambda_microvms/_protocol/eventstream.py +240 -0
  38. capo_lambda_microvms/_protocol/serialize.py +47 -0
  39. capo_lambda_microvms/_protocol/xml.py +33 -0
  40. capo_lambda_microvms/_resources/lambda_microvms/microvm.py +983 -0
  41. capo_lambda_microvms/_resources/lambda_microvms/microvm_image.py +1394 -0
  42. capo_lambda_microvms/_rule_engine/__init__.py +0 -0
  43. capo_lambda_microvms/_rule_engine/_aws_partition.py +160 -0
  44. capo_lambda_microvms/_rule_engine/_endpoint_rule_set.py +135 -0
  45. capo_lambda_microvms/_rule_engine/_endpoint_runtime.py +389 -0
  46. capo_lambda_microvms/_services/_aws_config.py +160 -0
  47. capo_lambda_microvms/_services/_pipeline.py +247 -0
  48. capo_lambda_microvms/_services/async_lambda_microvms.py +1822 -0
  49. capo_lambda_microvms/_services/lambda_microvms.py +1798 -0
  50. capo_lambda_microvms/errors/__init__.py +49 -0
  51. capo_lambda_microvms/errors/_base.py +94 -0
  52. capo_lambda_microvms/errors/access_denied_exception.py +46 -0
  53. capo_lambda_microvms/errors/conflict_exception.py +56 -0
  54. capo_lambda_microvms/errors/insufficient_capacity_exception.py +49 -0
  55. capo_lambda_microvms/errors/internal_server_exception.py +48 -0
  56. capo_lambda_microvms/errors/invalid_parameter_value_exception.py +54 -0
  57. capo_lambda_microvms/errors/resource_conflict_exception.py +52 -0
  58. capo_lambda_microvms/errors/resource_not_found_exception.py +59 -0
  59. capo_lambda_microvms/errors/service_exception.py +50 -0
  60. capo_lambda_microvms/errors/service_quota_exceeded_exception.py +72 -0
  61. capo_lambda_microvms/errors/throttling_exception.py +58 -0
  62. capo_lambda_microvms/errors/too_many_requests_exception.py +52 -0
  63. capo_lambda_microvms/errors/validation_exception.py +44 -0
  64. capo_lambda_microvms/py.typed +0 -0
  65. capo_lambda_microvms/types/_prelude/blob.py +12 -0
  66. capo_lambda_microvms/types/_prelude/timestamp.py +17 -0
  67. capo_lambda_microvms/types/architecture.py +14 -0
  68. capo_lambda_microvms/types/auth_token_key.py +5 -0
  69. capo_lambda_microvms/types/auth_token_value.py +5 -0
  70. capo_lambda_microvms/types/build_state.py +19 -0
  71. capo_lambda_microvms/types/capability.py +15 -0
  72. capo_lambda_microvms/types/capability_list.py +29 -0
  73. capo_lambda_microvms/types/chipset.py +14 -0
  74. capo_lambda_microvms/types/cloud_watch_logging.py +34 -0
  75. capo_lambda_microvms/types/code_artifact.py +32 -0
  76. capo_lambda_microvms/types/cpu_configuration.py +39 -0
  77. capo_lambda_microvms/types/cpu_configuration_list.py +31 -0
  78. capo_lambda_microvms/types/create_microvm_auth_token_request.py +62 -0
  79. capo_lambda_microvms/types/create_microvm_auth_token_response.py +39 -0
  80. capo_lambda_microvms/types/create_microvm_image_request.py +219 -0
  81. capo_lambda_microvms/types/create_microvm_image_response.py +294 -0
  82. capo_lambda_microvms/types/create_microvm_shell_auth_token_request.py +38 -0
  83. capo_lambda_microvms/types/create_microvm_shell_auth_token_response.py +41 -0
  84. capo_lambda_microvms/types/delete_microvm_image_input.py +26 -0
  85. capo_lambda_microvms/types/delete_microvm_image_output.py +49 -0
  86. capo_lambda_microvms/types/delete_microvm_image_version_input.py +29 -0
  87. capo_lambda_microvms/types/delete_microvm_image_version_output.py +65 -0
  88. capo_lambda_microvms/types/environment_variable_key.py +5 -0
  89. capo_lambda_microvms/types/environment_variable_map.py +29 -0
  90. capo_lambda_microvms/types/environment_variable_value.py +5 -0
  91. capo_lambda_microvms/types/get_microvm_image_build_input.py +31 -0
  92. capo_lambda_microvms/types/get_microvm_image_build_output.py +144 -0
  93. capo_lambda_microvms/types/get_microvm_image_input.py +26 -0
  94. capo_lambda_microvms/types/get_microvm_image_output.py +117 -0
  95. capo_lambda_microvms/types/get_microvm_image_version_input.py +29 -0
  96. capo_lambda_microvms/types/get_microvm_image_version_output.py +308 -0
  97. capo_lambda_microvms/types/get_microvm_request.py +26 -0
  98. capo_lambda_microvms/types/get_microvm_response.py +188 -0
  99. capo_lambda_microvms/types/hook_state.py +18 -0
  100. capo_lambda_microvms/types/hooks.py +65 -0
  101. capo_lambda_microvms/types/idle_policy.py +40 -0
  102. capo_lambda_microvms/types/image_name.py +6 -0
  103. capo_lambda_microvms/types/list_managed_microvm_image_versions_input.py +31 -0
  104. capo_lambda_microvms/types/list_managed_microvm_image_versions_output.py +52 -0
  105. capo_lambda_microvms/types/list_managed_microvm_images_input.py +26 -0
  106. capo_lambda_microvms/types/list_managed_microvm_images_output.py +50 -0
  107. capo_lambda_microvms/types/list_microvm_image_builds_input.py +44 -0
  108. capo_lambda_microvms/types/list_microvm_image_builds_output.py +50 -0
  109. capo_lambda_microvms/types/list_microvm_image_versions_input.py +31 -0
  110. capo_lambda_microvms/types/list_microvm_image_versions_output.py +50 -0
  111. capo_lambda_microvms/types/list_microvm_images_request.py +31 -0
  112. capo_lambda_microvms/types/list_microvm_images_response.py +48 -0
  113. capo_lambda_microvms/types/list_microvms_request.py +33 -0
  114. capo_lambda_microvms/types/list_microvms_response.py +46 -0
  115. capo_lambda_microvms/types/list_of_port_specification.py +31 -0
  116. capo_lambda_microvms/types/list_tags_request.py +24 -0
  117. capo_lambda_microvms/types/list_tags_response.py +32 -0
  118. capo_lambda_microvms/types/logging.py +65 -0
  119. capo_lambda_microvms/types/logging_disabled.py +18 -0
  120. capo_lambda_microvms/types/managed_microvm_image_summary.py +66 -0
  121. capo_lambda_microvms/types/managed_microvm_image_summary_list.py +39 -0
  122. capo_lambda_microvms/types/managed_microvm_image_version.py +94 -0
  123. capo_lambda_microvms/types/managed_microvm_image_version_list.py +39 -0
  124. capo_lambda_microvms/types/managed_microvm_image_version_status.py +18 -0
  125. capo_lambda_microvms/types/microvm_hooks.py +108 -0
  126. capo_lambda_microvms/types/microvm_identifier.py +6 -0
  127. capo_lambda_microvms/types/microvm_image_arn.py +6 -0
  128. capo_lambda_microvms/types/microvm_image_build_summaries.py +37 -0
  129. capo_lambda_microvms/types/microvm_image_build_summary.py +125 -0
  130. capo_lambda_microvms/types/microvm_image_hooks.py +66 -0
  131. capo_lambda_microvms/types/microvm_image_identifier.py +6 -0
  132. capo_lambda_microvms/types/microvm_image_state.py +24 -0
  133. capo_lambda_microvms/types/microvm_image_summaries.py +35 -0
  134. capo_lambda_microvms/types/microvm_image_summary.py +90 -0
  135. capo_lambda_microvms/types/microvm_image_version_state.py +22 -0
  136. capo_lambda_microvms/types/microvm_image_version_status.py +17 -0
  137. capo_lambda_microvms/types/microvm_image_version_summary.py +300 -0
  138. capo_lambda_microvms/types/microvm_image_version_summary_list.py +39 -0
  139. capo_lambda_microvms/types/microvm_item.py +82 -0
  140. capo_lambda_microvms/types/microvm_item_list.py +29 -0
  141. capo_lambda_microvms/types/microvm_state.py +22 -0
  142. capo_lambda_microvms/types/network_connector.py +5 -0
  143. capo_lambda_microvms/types/network_connector_list.py +19 -0
  144. capo_lambda_microvms/types/non_blank_string.py +6 -0
  145. capo_lambda_microvms/types/port_number.py +6 -0
  146. capo_lambda_microvms/types/port_range.py +38 -0
  147. capo_lambda_microvms/types/port_specification.py +63 -0
  148. capo_lambda_microvms/types/positive_integer.py +5 -0
  149. capo_lambda_microvms/types/resources.py +26 -0
  150. capo_lambda_microvms/types/resources_list.py +29 -0
  151. capo_lambda_microvms/types/resume_microvm_request.py +26 -0
  152. capo_lambda_microvms/types/resume_microvm_response.py +18 -0
  153. capo_lambda_microvms/types/role_arn.py +6 -0
  154. capo_lambda_microvms/types/run_hook_payload.py +5 -0
  155. capo_lambda_microvms/types/run_microvm_request.py +139 -0
  156. capo_lambda_microvms/types/run_microvm_response.py +188 -0
  157. capo_lambda_microvms/types/snapshot_build.py +35 -0
  158. capo_lambda_microvms/types/string.py +5 -0
  159. capo_lambda_microvms/types/suspend_microvm_request.py +26 -0
  160. capo_lambda_microvms/types/suspend_microvm_response.py +18 -0
  161. capo_lambda_microvms/types/tag_key.py +5 -0
  162. capo_lambda_microvms/types/tag_key_list.py +17 -0
  163. capo_lambda_microvms/types/tag_resource_request.py +38 -0
  164. capo_lambda_microvms/types/tag_value.py +5 -0
  165. capo_lambda_microvms/types/taggable_resource.py +6 -0
  166. capo_lambda_microvms/types/tags.py +29 -0
  167. capo_lambda_microvms/types/terminate_microvm_request.py +26 -0
  168. capo_lambda_microvms/types/terminate_microvm_response.py +18 -0
  169. capo_lambda_microvms/types/token_parts.py +29 -0
  170. capo_lambda_microvms/types/untag_resource_request.py +27 -0
  171. capo_lambda_microvms/types/update_microvm_image_request.py +205 -0
  172. capo_lambda_microvms/types/update_microvm_image_response.py +284 -0
  173. capo_lambda_microvms/types/update_microvm_image_version_request.py +51 -0
  174. capo_lambda_microvms/types/update_microvm_image_version_response.py +312 -0
  175. capo_lambda_microvms/types/version.py +5 -0
  176. capo_lambda_microvms-0.1.0.dist-info/METADATA +103 -0
  177. capo_lambda_microvms-0.1.0.dist-info/RECORD +180 -0
  178. capo_lambda_microvms-0.1.0.dist-info/WHEEL +5 -0
  179. capo_lambda_microvms-0.1.0.dist-info/licenses/LICENSE +21 -0
  180. capo_lambda_microvms-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,174 @@
1
+ """Generated from Smithy shape ``com.amazonaws.lambdamicrovms#DeleteMicrovmImageVersion``."""
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_lambda_microvms._auth._signers
13
+ import capo_lambda_microvms._auth._sigv4
14
+ import capo_lambda_microvms._protocol.eventstream
15
+ import capo_lambda_microvms.errors.access_denied_exception
16
+ import capo_lambda_microvms.errors.conflict_exception
17
+ import capo_lambda_microvms.errors.internal_server_exception
18
+ import capo_lambda_microvms.errors.resource_not_found_exception
19
+ import capo_lambda_microvms.errors.throttling_exception
20
+ import capo_lambda_microvms.errors.validation_exception
21
+ import capo_lambda_microvms.types.delete_microvm_image_version_input
22
+ import capo_lambda_microvms.types.delete_microvm_image_version_output
23
+ import capo_lambda_microvms.types.microvm_image_version_state
24
+ from capo_lambda_microvms._protocol.errors import parse_error_metadata_json
25
+ from capo_lambda_microvms._rule_engine._endpoint_rule_set import EndpointParams, resolve
26
+ from capo_lambda_microvms._services._pipeline import (
27
+ AsyncOperationOptions,
28
+ OperationOptions,
29
+ )
30
+ from capo_lambda_microvms.errors import UnknownServiceError
31
+
32
+
33
+ def handle_error(response: zapros.Response) -> Never:
34
+ data = json.loads(response.read())
35
+ code, message = parse_error_metadata_json(response, data)
36
+ match code:
37
+ case "AccessDeniedException":
38
+ raise capo_lambda_microvms.errors.access_denied_exception.AccessDeniedException.from_json(
39
+ data, message
40
+ )
41
+ case "InternalServerException":
42
+ raise capo_lambda_microvms.errors.internal_server_exception.InternalServerException.from_json(
43
+ data, message
44
+ )
45
+ case "ThrottlingException":
46
+ raise capo_lambda_microvms.errors.throttling_exception.ThrottlingException.from_json(
47
+ data, message
48
+ )
49
+ case "ValidationException":
50
+ raise capo_lambda_microvms.errors.validation_exception.ValidationException.from_json(
51
+ data, message
52
+ )
53
+ case "ConflictException":
54
+ raise capo_lambda_microvms.errors.conflict_exception.ConflictException.from_json(
55
+ data, message
56
+ )
57
+ case "ResourceNotFoundException":
58
+ raise capo_lambda_microvms.errors.resource_not_found_exception.ResourceNotFoundException.from_json(
59
+ data, message
60
+ )
61
+ case _:
62
+ raise UnknownServiceError(code=code, message=message, response=response)
63
+
64
+
65
+ def handle_response(
66
+ response: zapros.Response,
67
+ ) -> capo_lambda_microvms.types.delete_microvm_image_version_output.DeleteMicrovmImageVersionOutput:
68
+ out: capo_lambda_microvms.types.delete_microvm_image_version_output.DeleteMicrovmImageVersionOutput = capo_lambda_microvms.types.delete_microvm_image_version_output.deserialize_json(
69
+ json.loads(response.read())
70
+ )
71
+ return out
72
+
73
+
74
+ async def async_handle_response(
75
+ response: zapros.Response,
76
+ ) -> capo_lambda_microvms.types.delete_microvm_image_version_output.DeleteMicrovmImageVersionOutput:
77
+ out: capo_lambda_microvms.types.delete_microvm_image_version_output.DeleteMicrovmImageVersionOutput = capo_lambda_microvms.types.delete_microvm_image_version_output.deserialize_json(
78
+ json.loads(await response.aread())
79
+ )
80
+ return out
81
+
82
+
83
+ def get_signer(
84
+ options: AsyncOperationOptions | OperationOptions,
85
+ auth_schemes: list[dict[str, Any]] | None = None,
86
+ ) -> capo_lambda_microvms._auth._signers.Signer | None:
87
+ name_to_schema = {s["name"]: s for s in (auth_schemes or [])} # noqa: F841
88
+ if (
89
+ options.credentials_provider is not None
90
+ and name_to_schema
91
+ and not name_to_schema.keys() & {"sigv4", "sigv4-s3express"}
92
+ ):
93
+ raise RuntimeError(
94
+ "Endpoint requires an unsupported auth scheme: " + ", ".join(name_to_schema)
95
+ )
96
+ if options.credentials_provider is not None:
97
+ endpoint_scheme = name_to_schema.get("sigv4") or name_to_schema.get(
98
+ "sigv4-s3express"
99
+ )
100
+ if endpoint_scheme is not None or not name_to_schema:
101
+ sigv4_config = capo_lambda_microvms._auth._sigv4.build_sigv4_auth_scheme(
102
+ "lambda", options.region, endpoint_scheme
103
+ )
104
+ if sigv4_config is not None:
105
+ return capo_lambda_microvms._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_lambda_microvms.types.delete_microvm_image_version_input.DeleteMicrovmImageVersionInput,
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 = (
124
+ endpoint.url.rstrip("/")
125
+ + "/2025-09-09/microvm-images/{imageIdentifier}/versions/{imageVersion}"
126
+ )
127
+ url = url.replace("{imageIdentifier}", quote(input_["image_identifier"], safe=""))
128
+ url = url.replace("{imageVersion}", quote(input_["image_version"], safe=""))
129
+ params: list[tuple[str, str]] = []
130
+ headers: dict[str, str] = {k: ", ".join(v) for k, v in endpoint.headers.items()}
131
+ body: bytes | None = b""
132
+ signer = get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
133
+ normalized_url = zapros.URL(url)
134
+ for k, v in params:
135
+ normalized_url.search_params.append(k, v)
136
+ return zapros.Request(
137
+ normalized_url, "DELETE", headers=headers, body=body, context={"signer": signer}
138
+ )
139
+
140
+
141
+ def delete_microvm_image_version(
142
+ options: OperationOptions,
143
+ input_: capo_lambda_microvms.types.delete_microvm_image_version_input.DeleteMicrovmImageVersionInput,
144
+ ) -> tuple[
145
+ capo_lambda_microvms.types.delete_microvm_image_version_output.DeleteMicrovmImageVersionOutput,
146
+ zapros.Response,
147
+ ]:
148
+ response = options.client.handler.handle(build_request(options, input_))
149
+ try:
150
+ if response.status >= 300:
151
+ response.read()
152
+ handle_error(response)
153
+ return handle_response(response), response
154
+ except BaseException:
155
+ response.close()
156
+ raise
157
+
158
+
159
+ async def async_delete_microvm_image_version(
160
+ options: AsyncOperationOptions,
161
+ input_: capo_lambda_microvms.types.delete_microvm_image_version_input.DeleteMicrovmImageVersionInput,
162
+ ) -> tuple[
163
+ capo_lambda_microvms.types.delete_microvm_image_version_output.DeleteMicrovmImageVersionOutput,
164
+ zapros.Response,
165
+ ]:
166
+ response = await options.client.handler.ahandle(build_request(options, input_))
167
+ try:
168
+ if response.status >= 300:
169
+ await response.aread()
170
+ handle_error(response)
171
+ return await async_handle_response(response), response
172
+ except BaseException:
173
+ await response.aclose()
174
+ raise
@@ -0,0 +1,171 @@
1
+ """Generated from Smithy shape ``com.amazonaws.lambdamicrovms#GetMicrovm``."""
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_lambda_microvms._auth._signers
13
+ import capo_lambda_microvms._auth._sigv4
14
+ import capo_lambda_microvms._protocol.eventstream
15
+ import capo_lambda_microvms.errors.access_denied_exception
16
+ import capo_lambda_microvms.errors.internal_server_exception
17
+ import capo_lambda_microvms.errors.resource_not_found_exception
18
+ import capo_lambda_microvms.errors.throttling_exception
19
+ import capo_lambda_microvms.errors.validation_exception
20
+ import capo_lambda_microvms.types.get_microvm_request
21
+ import capo_lambda_microvms.types.get_microvm_response
22
+ import capo_lambda_microvms.types.idle_policy
23
+ import capo_lambda_microvms.types.microvm_state
24
+ import capo_lambda_microvms.types.network_connector_list
25
+ from capo_lambda_microvms._protocol.errors import parse_error_metadata_json
26
+ from capo_lambda_microvms._rule_engine._endpoint_rule_set import EndpointParams, resolve
27
+ from capo_lambda_microvms._services._pipeline import (
28
+ AsyncOperationOptions,
29
+ OperationOptions,
30
+ )
31
+ from capo_lambda_microvms.errors import UnknownServiceError
32
+
33
+
34
+ def handle_error(response: zapros.Response) -> Never:
35
+ data = json.loads(response.read())
36
+ code, message = parse_error_metadata_json(response, data)
37
+ match code:
38
+ case "AccessDeniedException":
39
+ raise capo_lambda_microvms.errors.access_denied_exception.AccessDeniedException.from_json(
40
+ data, message
41
+ )
42
+ case "InternalServerException":
43
+ raise capo_lambda_microvms.errors.internal_server_exception.InternalServerException.from_json(
44
+ data, message
45
+ )
46
+ case "ThrottlingException":
47
+ raise capo_lambda_microvms.errors.throttling_exception.ThrottlingException.from_json(
48
+ data, message
49
+ )
50
+ case "ValidationException":
51
+ raise capo_lambda_microvms.errors.validation_exception.ValidationException.from_json(
52
+ data, message
53
+ )
54
+ case "ResourceNotFoundException":
55
+ raise capo_lambda_microvms.errors.resource_not_found_exception.ResourceNotFoundException.from_json(
56
+ data, message
57
+ )
58
+ case _:
59
+ raise UnknownServiceError(code=code, message=message, response=response)
60
+
61
+
62
+ def handle_response(
63
+ response: zapros.Response,
64
+ ) -> capo_lambda_microvms.types.get_microvm_response.GetMicrovmResponse:
65
+ out: capo_lambda_microvms.types.get_microvm_response.GetMicrovmResponse = (
66
+ capo_lambda_microvms.types.get_microvm_response.deserialize_json(
67
+ json.loads(response.read())
68
+ )
69
+ )
70
+ return out
71
+
72
+
73
+ async def async_handle_response(
74
+ response: zapros.Response,
75
+ ) -> capo_lambda_microvms.types.get_microvm_response.GetMicrovmResponse:
76
+ out: capo_lambda_microvms.types.get_microvm_response.GetMicrovmResponse = (
77
+ capo_lambda_microvms.types.get_microvm_response.deserialize_json(
78
+ json.loads(await response.aread())
79
+ )
80
+ )
81
+ return out
82
+
83
+
84
+ def get_signer(
85
+ options: AsyncOperationOptions | OperationOptions,
86
+ auth_schemes: list[dict[str, Any]] | None = None,
87
+ ) -> capo_lambda_microvms._auth._signers.Signer | None:
88
+ name_to_schema = {s["name"]: s for s in (auth_schemes or [])} # noqa: F841
89
+ if (
90
+ options.credentials_provider is not None
91
+ and name_to_schema
92
+ and not name_to_schema.keys() & {"sigv4", "sigv4-s3express"}
93
+ ):
94
+ raise RuntimeError(
95
+ "Endpoint requires an unsupported auth scheme: " + ", ".join(name_to_schema)
96
+ )
97
+ if options.credentials_provider is not None:
98
+ endpoint_scheme = name_to_schema.get("sigv4") or name_to_schema.get(
99
+ "sigv4-s3express"
100
+ )
101
+ if endpoint_scheme is not None or not name_to_schema:
102
+ sigv4_config = capo_lambda_microvms._auth._sigv4.build_sigv4_auth_scheme(
103
+ "lambda", options.region, endpoint_scheme
104
+ )
105
+ if sigv4_config is not None:
106
+ return capo_lambda_microvms._auth._signers.SigV4Signer(
107
+ options.credentials_provider, auth_scheme=sigv4_config
108
+ )
109
+ raise RuntimeError("Auth was not resolved")
110
+
111
+
112
+ def build_request(
113
+ options: OperationOptions | AsyncOperationOptions,
114
+ input_: capo_lambda_microvms.types.get_microvm_request.GetMicrovmRequest,
115
+ ) -> zapros.Request:
116
+ endpoint = resolve(
117
+ EndpointParams(
118
+ Region=options.region,
119
+ UseDualStack=options.use_dual_stack,
120
+ UseFIPS=options.use_fips,
121
+ Endpoint=options.endpoint,
122
+ )
123
+ ) # noqa: F841
124
+ url = endpoint.url.rstrip("/") + "/2025-09-09/microvms/{microvmIdentifier}"
125
+ url = url.replace(
126
+ "{microvmIdentifier}", quote(input_["microvm_identifier"], safe="")
127
+ )
128
+ params: list[tuple[str, str]] = []
129
+ headers: dict[str, str] = {k: ", ".join(v) for k, v in endpoint.headers.items()}
130
+ body: bytes | None = b""
131
+ signer = get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
132
+ normalized_url = zapros.URL(url)
133
+ for k, v in params:
134
+ normalized_url.search_params.append(k, v)
135
+ return zapros.Request(
136
+ normalized_url, "GET", headers=headers, body=body, context={"signer": signer}
137
+ )
138
+
139
+
140
+ def get_microvm(
141
+ options: OperationOptions,
142
+ input_: capo_lambda_microvms.types.get_microvm_request.GetMicrovmRequest,
143
+ ) -> tuple[
144
+ capo_lambda_microvms.types.get_microvm_response.GetMicrovmResponse, 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_get_microvm(
158
+ options: AsyncOperationOptions,
159
+ input_: capo_lambda_microvms.types.get_microvm_request.GetMicrovmRequest,
160
+ ) -> tuple[
161
+ capo_lambda_microvms.types.get_microvm_response.GetMicrovmResponse, zapros.Response
162
+ ]:
163
+ response = await options.client.handler.ahandle(build_request(options, input_))
164
+ try:
165
+ if response.status >= 300:
166
+ await response.aread()
167
+ handle_error(response)
168
+ return await async_handle_response(response), response
169
+ except BaseException:
170
+ await response.aclose()
171
+ raise
@@ -0,0 +1,170 @@
1
+ """Generated from Smithy shape ``com.amazonaws.lambdamicrovms#GetMicrovmImage``."""
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_lambda_microvms._auth._signers
13
+ import capo_lambda_microvms._auth._sigv4
14
+ import capo_lambda_microvms._protocol.eventstream
15
+ import capo_lambda_microvms.errors.access_denied_exception
16
+ import capo_lambda_microvms.errors.internal_server_exception
17
+ import capo_lambda_microvms.errors.resource_not_found_exception
18
+ import capo_lambda_microvms.errors.throttling_exception
19
+ import capo_lambda_microvms.errors.validation_exception
20
+ import capo_lambda_microvms.types.get_microvm_image_input
21
+ import capo_lambda_microvms.types.get_microvm_image_output
22
+ import capo_lambda_microvms.types.microvm_image_state
23
+ import capo_lambda_microvms.types.tags
24
+ from capo_lambda_microvms._protocol.errors import parse_error_metadata_json
25
+ from capo_lambda_microvms._rule_engine._endpoint_rule_set import EndpointParams, resolve
26
+ from capo_lambda_microvms._services._pipeline import (
27
+ AsyncOperationOptions,
28
+ OperationOptions,
29
+ )
30
+ from capo_lambda_microvms.errors import UnknownServiceError
31
+
32
+
33
+ def handle_error(response: zapros.Response) -> Never:
34
+ data = json.loads(response.read())
35
+ code, message = parse_error_metadata_json(response, data)
36
+ match code:
37
+ case "AccessDeniedException":
38
+ raise capo_lambda_microvms.errors.access_denied_exception.AccessDeniedException.from_json(
39
+ data, message
40
+ )
41
+ case "InternalServerException":
42
+ raise capo_lambda_microvms.errors.internal_server_exception.InternalServerException.from_json(
43
+ data, message
44
+ )
45
+ case "ThrottlingException":
46
+ raise capo_lambda_microvms.errors.throttling_exception.ThrottlingException.from_json(
47
+ data, message
48
+ )
49
+ case "ValidationException":
50
+ raise capo_lambda_microvms.errors.validation_exception.ValidationException.from_json(
51
+ data, message
52
+ )
53
+ case "ResourceNotFoundException":
54
+ raise capo_lambda_microvms.errors.resource_not_found_exception.ResourceNotFoundException.from_json(
55
+ data, message
56
+ )
57
+ case _:
58
+ raise UnknownServiceError(code=code, message=message, response=response)
59
+
60
+
61
+ def handle_response(
62
+ response: zapros.Response,
63
+ ) -> capo_lambda_microvms.types.get_microvm_image_output.GetMicrovmImageOutput:
64
+ out: capo_lambda_microvms.types.get_microvm_image_output.GetMicrovmImageOutput = (
65
+ capo_lambda_microvms.types.get_microvm_image_output.deserialize_json(
66
+ json.loads(response.read())
67
+ )
68
+ )
69
+ return out
70
+
71
+
72
+ async def async_handle_response(
73
+ response: zapros.Response,
74
+ ) -> capo_lambda_microvms.types.get_microvm_image_output.GetMicrovmImageOutput:
75
+ out: capo_lambda_microvms.types.get_microvm_image_output.GetMicrovmImageOutput = (
76
+ capo_lambda_microvms.types.get_microvm_image_output.deserialize_json(
77
+ json.loads(await response.aread())
78
+ )
79
+ )
80
+ return out
81
+
82
+
83
+ def get_signer(
84
+ options: AsyncOperationOptions | OperationOptions,
85
+ auth_schemes: list[dict[str, Any]] | None = None,
86
+ ) -> capo_lambda_microvms._auth._signers.Signer | None:
87
+ name_to_schema = {s["name"]: s for s in (auth_schemes or [])} # noqa: F841
88
+ if (
89
+ options.credentials_provider is not None
90
+ and name_to_schema
91
+ and not name_to_schema.keys() & {"sigv4", "sigv4-s3express"}
92
+ ):
93
+ raise RuntimeError(
94
+ "Endpoint requires an unsupported auth scheme: " + ", ".join(name_to_schema)
95
+ )
96
+ if options.credentials_provider is not None:
97
+ endpoint_scheme = name_to_schema.get("sigv4") or name_to_schema.get(
98
+ "sigv4-s3express"
99
+ )
100
+ if endpoint_scheme is not None or not name_to_schema:
101
+ sigv4_config = capo_lambda_microvms._auth._sigv4.build_sigv4_auth_scheme(
102
+ "lambda", options.region, endpoint_scheme
103
+ )
104
+ if sigv4_config is not None:
105
+ return capo_lambda_microvms._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_lambda_microvms.types.get_microvm_image_input.GetMicrovmImageInput,
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("/") + "/2025-09-09/microvm-images/{imageIdentifier}"
124
+ url = url.replace("{imageIdentifier}", quote(input_["image_identifier"], safe=""))
125
+ params: list[tuple[str, str]] = []
126
+ headers: dict[str, str] = {k: ", ".join(v) for k, v in endpoint.headers.items()}
127
+ body: bytes | None = b""
128
+ signer = get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
129
+ normalized_url = zapros.URL(url)
130
+ for k, v in params:
131
+ normalized_url.search_params.append(k, v)
132
+ return zapros.Request(
133
+ normalized_url, "GET", headers=headers, body=body, context={"signer": signer}
134
+ )
135
+
136
+
137
+ def get_microvm_image(
138
+ options: OperationOptions,
139
+ input_: capo_lambda_microvms.types.get_microvm_image_input.GetMicrovmImageInput,
140
+ ) -> tuple[
141
+ capo_lambda_microvms.types.get_microvm_image_output.GetMicrovmImageOutput,
142
+ zapros.Response,
143
+ ]:
144
+ response = options.client.handler.handle(build_request(options, input_))
145
+ try:
146
+ if response.status >= 300:
147
+ response.read()
148
+ handle_error(response)
149
+ return handle_response(response), response
150
+ except BaseException:
151
+ response.close()
152
+ raise
153
+
154
+
155
+ async def async_get_microvm_image(
156
+ options: AsyncOperationOptions,
157
+ input_: capo_lambda_microvms.types.get_microvm_image_input.GetMicrovmImageInput,
158
+ ) -> tuple[
159
+ capo_lambda_microvms.types.get_microvm_image_output.GetMicrovmImageOutput,
160
+ zapros.Response,
161
+ ]:
162
+ response = await options.client.handler.ahandle(build_request(options, input_))
163
+ try:
164
+ if response.status >= 300:
165
+ await response.aread()
166
+ handle_error(response)
167
+ return await async_handle_response(response), response
168
+ except BaseException:
169
+ await response.aclose()
170
+ raise
@@ -0,0 +1,177 @@
1
+ """Generated from Smithy shape ``com.amazonaws.lambdamicrovms#GetMicrovmImageBuild``."""
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_lambda_microvms._auth._signers
13
+ import capo_lambda_microvms._auth._sigv4
14
+ import capo_lambda_microvms._protocol.eventstream
15
+ import capo_lambda_microvms.errors.access_denied_exception
16
+ import capo_lambda_microvms.errors.internal_server_exception
17
+ import capo_lambda_microvms.errors.resource_not_found_exception
18
+ import capo_lambda_microvms.errors.throttling_exception
19
+ import capo_lambda_microvms.errors.validation_exception
20
+ import capo_lambda_microvms.types.architecture
21
+ import capo_lambda_microvms.types.build_state
22
+ import capo_lambda_microvms.types.chipset
23
+ import capo_lambda_microvms.types.get_microvm_image_build_input
24
+ import capo_lambda_microvms.types.get_microvm_image_build_output
25
+ import capo_lambda_microvms.types.snapshot_build
26
+ from capo_lambda_microvms._protocol.errors import parse_error_metadata_json
27
+ from capo_lambda_microvms._rule_engine._endpoint_rule_set import EndpointParams, resolve
28
+ from capo_lambda_microvms._services._pipeline import (
29
+ AsyncOperationOptions,
30
+ OperationOptions,
31
+ )
32
+ from capo_lambda_microvms.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_lambda_microvms.errors.access_denied_exception.AccessDeniedException.from_json(
41
+ data, message
42
+ )
43
+ case "InternalServerException":
44
+ raise capo_lambda_microvms.errors.internal_server_exception.InternalServerException.from_json(
45
+ data, message
46
+ )
47
+ case "ThrottlingException":
48
+ raise capo_lambda_microvms.errors.throttling_exception.ThrottlingException.from_json(
49
+ data, message
50
+ )
51
+ case "ValidationException":
52
+ raise capo_lambda_microvms.errors.validation_exception.ValidationException.from_json(
53
+ data, message
54
+ )
55
+ case "ResourceNotFoundException":
56
+ raise capo_lambda_microvms.errors.resource_not_found_exception.ResourceNotFoundException.from_json(
57
+ data, message
58
+ )
59
+ case _:
60
+ raise UnknownServiceError(code=code, message=message, response=response)
61
+
62
+
63
+ def handle_response(
64
+ response: zapros.Response,
65
+ ) -> (
66
+ capo_lambda_microvms.types.get_microvm_image_build_output.GetMicrovmImageBuildOutput
67
+ ):
68
+ out: capo_lambda_microvms.types.get_microvm_image_build_output.GetMicrovmImageBuildOutput = capo_lambda_microvms.types.get_microvm_image_build_output.deserialize_json(
69
+ json.loads(response.read())
70
+ )
71
+ return out
72
+
73
+
74
+ async def async_handle_response(
75
+ response: zapros.Response,
76
+ ) -> (
77
+ capo_lambda_microvms.types.get_microvm_image_build_output.GetMicrovmImageBuildOutput
78
+ ):
79
+ out: capo_lambda_microvms.types.get_microvm_image_build_output.GetMicrovmImageBuildOutput = capo_lambda_microvms.types.get_microvm_image_build_output.deserialize_json(
80
+ json.loads(await response.aread())
81
+ )
82
+ return out
83
+
84
+
85
+ def get_signer(
86
+ options: AsyncOperationOptions | OperationOptions,
87
+ auth_schemes: list[dict[str, Any]] | None = None,
88
+ ) -> capo_lambda_microvms._auth._signers.Signer | None:
89
+ name_to_schema = {s["name"]: s for s in (auth_schemes or [])} # noqa: F841
90
+ if (
91
+ options.credentials_provider is not None
92
+ and name_to_schema
93
+ and not name_to_schema.keys() & {"sigv4", "sigv4-s3express"}
94
+ ):
95
+ raise RuntimeError(
96
+ "Endpoint requires an unsupported auth scheme: " + ", ".join(name_to_schema)
97
+ )
98
+ if options.credentials_provider is not None:
99
+ endpoint_scheme = name_to_schema.get("sigv4") or name_to_schema.get(
100
+ "sigv4-s3express"
101
+ )
102
+ if endpoint_scheme is not None or not name_to_schema:
103
+ sigv4_config = capo_lambda_microvms._auth._sigv4.build_sigv4_auth_scheme(
104
+ "lambda", options.region, endpoint_scheme
105
+ )
106
+ if sigv4_config is not None:
107
+ return capo_lambda_microvms._auth._signers.SigV4Signer(
108
+ options.credentials_provider, auth_scheme=sigv4_config
109
+ )
110
+ raise RuntimeError("Auth was not resolved")
111
+
112
+
113
+ def build_request(
114
+ options: OperationOptions | AsyncOperationOptions,
115
+ input_: capo_lambda_microvms.types.get_microvm_image_build_input.GetMicrovmImageBuildInput,
116
+ ) -> zapros.Request:
117
+ endpoint = resolve(
118
+ EndpointParams(
119
+ Region=options.region,
120
+ UseDualStack=options.use_dual_stack,
121
+ UseFIPS=options.use_fips,
122
+ Endpoint=options.endpoint,
123
+ )
124
+ ) # noqa: F841
125
+ url = (
126
+ endpoint.url.rstrip("/")
127
+ + "/2025-09-09/microvm-images/{imageIdentifier}/versions/{imageVersion}/builds/{buildId}"
128
+ )
129
+ url = url.replace("{imageIdentifier}", quote(input_["image_identifier"], safe=""))
130
+ url = url.replace("{imageVersion}", quote(input_["image_version"], safe=""))
131
+ url = url.replace("{buildId}", quote(input_["build_id"], safe=""))
132
+ params: list[tuple[str, str]] = []
133
+ headers: dict[str, str] = {k: ", ".join(v) for k, v in endpoint.headers.items()}
134
+ body: bytes | None = b""
135
+ signer = get_signer(options, auth_schemes=endpoint.properties.get("authSchemes"))
136
+ normalized_url = zapros.URL(url)
137
+ for k, v in params:
138
+ normalized_url.search_params.append(k, v)
139
+ return zapros.Request(
140
+ normalized_url, "GET", headers=headers, body=body, context={"signer": signer}
141
+ )
142
+
143
+
144
+ def get_microvm_image_build(
145
+ options: OperationOptions,
146
+ input_: capo_lambda_microvms.types.get_microvm_image_build_input.GetMicrovmImageBuildInput,
147
+ ) -> tuple[
148
+ capo_lambda_microvms.types.get_microvm_image_build_output.GetMicrovmImageBuildOutput,
149
+ zapros.Response,
150
+ ]:
151
+ response = options.client.handler.handle(build_request(options, input_))
152
+ try:
153
+ if response.status >= 300:
154
+ response.read()
155
+ handle_error(response)
156
+ return handle_response(response), response
157
+ except BaseException:
158
+ response.close()
159
+ raise
160
+
161
+
162
+ async def async_get_microvm_image_build(
163
+ options: AsyncOperationOptions,
164
+ input_: capo_lambda_microvms.types.get_microvm_image_build_input.GetMicrovmImageBuildInput,
165
+ ) -> tuple[
166
+ capo_lambda_microvms.types.get_microvm_image_build_output.GetMicrovmImageBuildOutput,
167
+ zapros.Response,
168
+ ]:
169
+ response = await options.client.handler.ahandle(build_request(options, input_))
170
+ try:
171
+ if response.status >= 300:
172
+ await response.aread()
173
+ handle_error(response)
174
+ return await async_handle_response(response), response
175
+ except BaseException:
176
+ await response.aclose()
177
+ raise