capo-keyspacesstreams 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 (85) hide show
  1. capo_keyspacesstreams/__init__.py +74 -0
  2. capo_keyspacesstreams/_async.py +25 -0
  3. capo_keyspacesstreams/_auth/_identity.py +16 -0
  4. capo_keyspacesstreams/_auth/_providers.py +886 -0
  5. capo_keyspacesstreams/_auth/_signers.py +88 -0
  6. capo_keyspacesstreams/_auth/_sigv4.py +434 -0
  7. capo_keyspacesstreams/_auth/_zapros_handler.py +80 -0
  8. capo_keyspacesstreams/_iter.py +113 -0
  9. capo_keyspacesstreams/_operations/keyspaces_streams/get_records.py +171 -0
  10. capo_keyspacesstreams/_operations/keyspaces_streams/get_shard_iterator.py +170 -0
  11. capo_keyspacesstreams/_operations/keyspaces_streams/get_stream.py +174 -0
  12. capo_keyspacesstreams/_operations/keyspaces_streams/list_streams.py +170 -0
  13. capo_keyspacesstreams/_pagination.py +21 -0
  14. capo_keyspacesstreams/_protocol/__init__.py +1 -0
  15. capo_keyspacesstreams/_protocol/errors.py +93 -0
  16. capo_keyspacesstreams/_protocol/eventstream.py +238 -0
  17. capo_keyspacesstreams/_protocol/serialize.py +47 -0
  18. capo_keyspacesstreams/_protocol/xml.py +33 -0
  19. capo_keyspacesstreams/_rule_engine/__init__.py +0 -0
  20. capo_keyspacesstreams/_rule_engine/_aws_partition.py +160 -0
  21. capo_keyspacesstreams/_rule_engine/_endpoint_rule_set.py +65 -0
  22. capo_keyspacesstreams/_rule_engine/_endpoint_runtime.py +389 -0
  23. capo_keyspacesstreams/_services/_aws_config.py +156 -0
  24. capo_keyspacesstreams/_services/_pipeline.py +196 -0
  25. capo_keyspacesstreams/_services/async_keyspaces_streams.py +442 -0
  26. capo_keyspacesstreams/_services/keyspaces_streams.py +438 -0
  27. capo_keyspacesstreams/errors/__init__.py +32 -0
  28. capo_keyspacesstreams/errors/_base.py +94 -0
  29. capo_keyspacesstreams/errors/access_denied_exception.py +47 -0
  30. capo_keyspacesstreams/errors/internal_server_exception.py +47 -0
  31. capo_keyspacesstreams/errors/resource_not_found_exception.py +47 -0
  32. capo_keyspacesstreams/errors/throttling_exception.py +47 -0
  33. capo_keyspacesstreams/errors/validation_exception.py +72 -0
  34. capo_keyspacesstreams/py.typed +0 -0
  35. capo_keyspacesstreams/types/_prelude/blob.py +12 -0
  36. capo_keyspacesstreams/types/_prelude/timestamp.py +17 -0
  37. capo_keyspacesstreams/types/date.py +20 -0
  38. capo_keyspacesstreams/types/get_records_input.py +37 -0
  39. capo_keyspacesstreams/types/get_records_output.py +70 -0
  40. capo_keyspacesstreams/types/get_shard_iterator_input.py +70 -0
  41. capo_keyspacesstreams/types/get_shard_iterator_output.py +30 -0
  42. capo_keyspacesstreams/types/get_stream_input.py +63 -0
  43. capo_keyspacesstreams/types/get_stream_output.py +144 -0
  44. capo_keyspacesstreams/types/iterator_description.py +42 -0
  45. capo_keyspacesstreams/types/iterator_position.py +17 -0
  46. capo_keyspacesstreams/types/keyspace_name.py +5 -0
  47. capo_keyspacesstreams/types/keyspaces_cell.py +63 -0
  48. capo_keyspacesstreams/types/keyspaces_cell_list.py +35 -0
  49. capo_keyspacesstreams/types/keyspaces_cell_map.py +39 -0
  50. capo_keyspacesstreams/types/keyspaces_cell_map_definition.py +83 -0
  51. capo_keyspacesstreams/types/keyspaces_cell_value.py +333 -0
  52. capo_keyspacesstreams/types/keyspaces_cells.py +35 -0
  53. capo_keyspacesstreams/types/keyspaces_keys_map.py +39 -0
  54. capo_keyspacesstreams/types/keyspaces_metadata.py +29 -0
  55. capo_keyspacesstreams/types/keyspaces_row.py +83 -0
  56. capo_keyspacesstreams/types/keyspaces_udt_map.py +35 -0
  57. capo_keyspacesstreams/types/list_streams_input.py +50 -0
  58. capo_keyspacesstreams/types/list_streams_output.py +47 -0
  59. capo_keyspacesstreams/types/origin_type.py +18 -0
  60. capo_keyspacesstreams/types/record.py +146 -0
  61. capo_keyspacesstreams/types/record_list.py +29 -0
  62. capo_keyspacesstreams/types/sequence_number.py +5 -0
  63. capo_keyspacesstreams/types/sequence_number_range.py +38 -0
  64. capo_keyspacesstreams/types/shard.py +70 -0
  65. capo_keyspacesstreams/types/shard_description_list.py +29 -0
  66. capo_keyspacesstreams/types/shard_filter.py +47 -0
  67. capo_keyspacesstreams/types/shard_filter_type.py +14 -0
  68. capo_keyspacesstreams/types/shard_id.py +5 -0
  69. capo_keyspacesstreams/types/shard_id_list.py +17 -0
  70. capo_keyspacesstreams/types/shard_id_token.py +5 -0
  71. capo_keyspacesstreams/types/shard_iterator.py +5 -0
  72. capo_keyspacesstreams/types/shard_iterator_type.py +19 -0
  73. capo_keyspacesstreams/types/stream.py +54 -0
  74. capo_keyspacesstreams/types/stream_arn.py +5 -0
  75. capo_keyspacesstreams/types/stream_arn_token.py +5 -0
  76. capo_keyspacesstreams/types/stream_list.py +29 -0
  77. capo_keyspacesstreams/types/stream_status.py +19 -0
  78. capo_keyspacesstreams/types/stream_view_type.py +19 -0
  79. capo_keyspacesstreams/types/table_name.py +5 -0
  80. capo_keyspacesstreams/types/validation_exception_type.py +19 -0
  81. capo_keyspacesstreams-0.1.0.dist-info/METADATA +101 -0
  82. capo_keyspacesstreams-0.1.0.dist-info/RECORD +85 -0
  83. capo_keyspacesstreams-0.1.0.dist-info/WHEEL +5 -0
  84. capo_keyspacesstreams-0.1.0.dist-info/licenses/LICENSE +21 -0
  85. capo_keyspacesstreams-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,438 @@
1
+ """Generated from Smithy shape ``com.amazonaws.keyspacesstreams#KeyspacesStreams``."""
2
+
3
+ import warnings
4
+ from collections.abc import Iterator
5
+ from typing import TYPE_CHECKING, Any, Iterable, Optional
6
+
7
+ from typing_extensions import Self, TypedDict
8
+ from zapros import BaseHandler, Client
9
+
10
+ import capo_keyspacesstreams._auth._signers
11
+ import capo_keyspacesstreams._auth._sigv4
12
+ from capo_keyspacesstreams._auth._identity import Credentials
13
+ from capo_keyspacesstreams._auth._providers import (
14
+ CredentialsProvider,
15
+ IdentityProvider,
16
+ StaticAwsCredentialsProvider,
17
+ default_aws_credentials_chain,
18
+ )
19
+ from capo_keyspacesstreams._auth._zapros_handler import AuthMiddleware
20
+ from capo_keyspacesstreams._pagination import resolve_path as _resolve_path
21
+ from capo_keyspacesstreams._services._aws_config import aws_config
22
+ from capo_keyspacesstreams._services._pipeline import (
23
+ Interceptor,
24
+ OperationOptions,
25
+ OperationRequest,
26
+ OperationResponse,
27
+ execute_pipeline,
28
+ retry,
29
+ )
30
+
31
+ if TYPE_CHECKING:
32
+ import capo_keyspacesstreams.types.get_records_input
33
+ import capo_keyspacesstreams.types.get_records_output
34
+ import capo_keyspacesstreams.types.get_shard_iterator_input
35
+ import capo_keyspacesstreams.types.get_shard_iterator_output
36
+ import capo_keyspacesstreams.types.get_stream_input
37
+ import capo_keyspacesstreams.types.get_stream_output
38
+ import capo_keyspacesstreams.types.keyspace_name
39
+ import capo_keyspacesstreams.types.list_streams_input
40
+ import capo_keyspacesstreams.types.list_streams_output
41
+ import capo_keyspacesstreams.types.sequence_number
42
+ import capo_keyspacesstreams.types.shard
43
+ import capo_keyspacesstreams.types.shard_filter
44
+ import capo_keyspacesstreams.types.shard_id
45
+ import capo_keyspacesstreams.types.shard_id_token
46
+ import capo_keyspacesstreams.types.shard_iterator
47
+ import capo_keyspacesstreams.types.shard_iterator_type
48
+ import capo_keyspacesstreams.types.stream
49
+ import capo_keyspacesstreams.types.stream_arn
50
+ import capo_keyspacesstreams.types.stream_arn_token
51
+ import capo_keyspacesstreams.types.table_name
52
+
53
+
54
+ class KeyspacesStreamsClientConfig(TypedDict, total=False, closed=True):
55
+ operation_interceptors: Iterable[Interceptor[Any, Any]]
56
+ retry_max_attempts: int | None
57
+ use_fips: bool | None
58
+ endpoint: str | None
59
+ region: str | None
60
+ credentials_provider: IdentityProvider[Credentials] | None
61
+
62
+
63
+ class KeyspacesStreamsClient:
64
+ """A client for the ``KeyspacesStreams`` service.
65
+
66
+ Args:
67
+ http_handler: HTTP handler for sending requests. If not provided, creates a default handler.
68
+ operation_interceptors: Interceptors that wrap every operation call. If not provided, defaults to an empty list.
69
+ retry_max_attempts: Maximum number of times to retry a failed operation. Defaults to 3.
70
+ use_fips: The value of the ``AWS::UseFIPS`` endpoint parameter.
71
+ endpoint: The value of the ``SDK::Endpoint`` endpoint parameter.
72
+ region: The value of the ``AWS::Region`` endpoint parameter.
73
+ credentials: AWS credentials for request signing.
74
+ credentials_provider: Provider that resolves AWS credentials. Takes precedence over ``credentials``.
75
+ """
76
+
77
+ def __init__(
78
+ self,
79
+ http_handler: BaseHandler | None = None,
80
+ operation_interceptors: Iterable[Interceptor[Any, Any]] | None = None,
81
+ retry_max_attempts: int | None = None,
82
+ use_fips: bool | None = None,
83
+ endpoint: str | None = None,
84
+ region: str | None = None,
85
+ credentials: Credentials | None = None,
86
+ credentials_provider: CredentialsProvider | None = None,
87
+ ):
88
+ self._client = Client(http_handler).wrap_with_middleware(
89
+ lambda next: AuthMiddleware(next)
90
+ )
91
+ if credentials is not None and credentials_provider is not None:
92
+ warnings.warn(
93
+ "Both credentials and credentials_provider given; provider takes precedence"
94
+ )
95
+ resolved_credentials_provider: IdentityProvider[Credentials] | None = (
96
+ credentials_provider
97
+ )
98
+ if resolved_credentials_provider is None and credentials is not None:
99
+ resolved_credentials_provider = StaticAwsCredentialsProvider(credentials)
100
+ if resolved_credentials_provider is None and credentials is None:
101
+ resolved_credentials_provider = default_aws_credentials_chain(
102
+ Client(http_handler)
103
+ )
104
+ self._config = KeyspacesStreamsClientConfig(
105
+ {
106
+ "operation_interceptors": operation_interceptors or [],
107
+ "retry_max_attempts": retry_max_attempts,
108
+ "use_fips": use_fips,
109
+ "endpoint": endpoint,
110
+ "region": region,
111
+ "credentials_provider": resolved_credentials_provider,
112
+ }
113
+ )
114
+
115
+ def operation_options(
116
+ self, config_overrides: Optional[KeyspacesStreamsClientConfig] = None
117
+ ) -> tuple[Iterable[Interceptor[Any, Any]], OperationOptions]:
118
+ overrides: KeyspacesStreamsClientConfig = config_overrides or {}
119
+ interceptors_: list[Interceptor[Any, Any]] = [
120
+ *overrides.get(
121
+ "operation_interceptors", self._config.get("operation_interceptors", [])
122
+ ),
123
+ aws_config(),
124
+ retry(),
125
+ ]
126
+ options_: OperationOptions = OperationOptions(
127
+ client=self._client,
128
+ retry_max_attempts=overrides.get(
129
+ "retry_max_attempts", self._config.get("retry_max_attempts")
130
+ ),
131
+ use_fips=overrides.get("use_fips", self._config.get("use_fips")),
132
+ endpoint=overrides.get("endpoint", self._config.get("endpoint")),
133
+ region=overrides.get("region", self._config.get("region")),
134
+ credentials_provider=overrides.get(
135
+ "credentials_provider", self._config.get("credentials_provider")
136
+ ),
137
+ )
138
+ return interceptors_, options_
139
+
140
+ def get_records(
141
+ self,
142
+ shard_iterator: "capo_keyspacesstreams.types.shard_iterator.ShardIterator",
143
+ *,
144
+ config_overrides: Optional[KeyspacesStreamsClientConfig] = None,
145
+ max_results: Optional[int] = None,
146
+ ) -> "capo_keyspacesstreams.types.get_records_output.GetRecordsOutput":
147
+ """<p>Retrieves data records from a specified shard in an Amazon Keyspaces data stream. This operation returns a collection of data records from the shard, including the primary key columns and information about modifications made to the captured table data. Each record represents a single data modification in the Amazon Keyspaces table and includes metadata about when the change occurred.</p>
148
+
149
+ Args:
150
+ shard_iterator: <p> The unique identifier of the shard iterator. A shard iterator specifies the position in the shard from which you want to start reading data records sequentially. You obtain this value by calling the <code>GetShardIterator </code> operation. Each shard iterator is valid for 15 minutes after creation. </p>
151
+ max_results: <p> The maximum number of records to return in a single <code>GetRecords</code> request. The default value is 100. You can specify a limit between 1 and 1000, but the actual number returned might be less than the specified maximum if the size of the data for the returned records exceeds the internal size limit. </p>
152
+
153
+ Raises:
154
+ capo_keyspacesstreams.errors.access_denied_exception.AccessDeniedException: <p>You don't have sufficient access permissions to perform this operation. </p> <p>This exception occurs when your IAM user or role lacks the required permissions to access the Amazon Keyspaces resource or perform the requested action. Check your IAM policies and ensure they grant the necessary permissions.</p>
155
+ capo_keyspacesstreams.errors.internal_server_exception.InternalServerException: <p>The Amazon Keyspaces service encountered an unexpected error while processing the request. </p> <p>This internal server error is not related to your request parameters. Retry your request after a brief delay. If the issue persists, contact Amazon Web Services Support with details of your request to help identify and resolve the problem.</p>
156
+ capo_keyspacesstreams.errors.resource_not_found_exception.ResourceNotFoundException: <p>The requested resource doesn't exist or could not be found. </p> <p>This exception occurs when you attempt to access a keyspace, table, stream, or other Amazon Keyspaces resource that doesn't exist or that has been deleted. Verify that the resource identifier is correct and that the resource exists in your account.</p>
157
+ capo_keyspacesstreams.errors.throttling_exception.ThrottlingException: <p>The request rate is too high and exceeds the service's throughput limits. </p> <p>This exception occurs when you send too many requests in a short period of time. Implement exponential backoff in your retry strategy to handle this exception. Reducing your request frequency or distributing requests more evenly can help avoid throughput exceptions.</p> <p>This exception can also occur when more than two processes are reading from the same stream shard at the same time. Ensure that only one process reads from a stream shard at the same time. </p>
158
+ capo_keyspacesstreams.errors.validation_exception.ValidationException: <p>The request validation failed because one or more input parameters failed validation. </p> <p>This exception occurs when there are syntax errors in the request, field constraints are violated, or required parameters are missing. To help you fix the issue, the exception message provides details about which parameter failed and why.</p>
159
+ capo_keyspacesstreams.errors.UnknownServiceError: The service returned an error code this client does not model.
160
+ """
161
+
162
+ def _handler(
163
+ req: "OperationRequest[capo_keyspacesstreams.types.get_records_input.GetRecordsInput]",
164
+ ) -> OperationResponse[
165
+ "capo_keyspacesstreams.types.get_records_output.GetRecordsOutput"
166
+ ]:
167
+ import capo_keyspacesstreams._operations.keyspaces_streams.get_records
168
+
169
+ output, http_response = (
170
+ capo_keyspacesstreams._operations.keyspaces_streams.get_records.get_records(
171
+ req.options, req.input
172
+ )
173
+ )
174
+ return OperationResponse(output=output, response=http_response)
175
+
176
+ interceptors_, options_ = self.operation_options(config_overrides)
177
+ input_: capo_keyspacesstreams.types.get_records_input.GetRecordsInput = {
178
+ "shard_iterator": shard_iterator
179
+ }
180
+ if max_results is not None:
181
+ input_["max_results"] = max_results
182
+
183
+ response = execute_pipeline(
184
+ OperationRequest(input=input_, options=options_),
185
+ handler=_handler,
186
+ interceptors=list(interceptors_),
187
+ )
188
+ response.response.close()
189
+ return response.output
190
+
191
+ def get_shard_iterator(
192
+ self,
193
+ stream_arn: "capo_keyspacesstreams.types.stream_arn.StreamArn",
194
+ shard_id: "capo_keyspacesstreams.types.shard_id.ShardId",
195
+ shard_iterator_type: "capo_keyspacesstreams.types.shard_iterator_type.ShardIteratorType",
196
+ *,
197
+ config_overrides: Optional[KeyspacesStreamsClientConfig] = None,
198
+ sequence_number: Optional[
199
+ "capo_keyspacesstreams.types.sequence_number.SequenceNumber"
200
+ ] = None,
201
+ ) -> "capo_keyspacesstreams.types.get_shard_iterator_output.GetShardIteratorOutput":
202
+ """<p>Returns a shard iterator that serves as a bookmark for reading data from a specific position in an Amazon Keyspaces data stream's shard. The shard iterator specifies the shard position from which to start reading data records sequentially. You can specify whether to begin reading at the latest record, the oldest record, or at a particular sequence number within the shard.</p>
203
+
204
+ Args:
205
+ stream_arn: <p> The Amazon Resource Name (ARN) of the stream for which to get the shard iterator. The ARN uniquely identifies the stream within Amazon Keyspaces. </p>
206
+ shard_id: <p> The identifier of the shard within the stream. The shard ID uniquely identifies a subset of the stream's data records that you want to access. </p>
207
+ shard_iterator_type: <p> Determines how the shard iterator is positioned. Must be one of the following: </p> <ul> <li> <p> <code>TRIM_HORIZON</code> - Start reading at the last untrimmed record in the shard, which is the oldest data record in the shard.</p> </li> <li> <p> <code>AT_SEQUENCE_NUMBER</code> - Start reading exactly from the specified sequence number.</p> </li> <li> <p> <code>AFTER_SEQUENCE_NUMBER</code> - Start reading right after the specified sequence number. </p> </li> <li> <p> <code>LATEST</code> - Start reading just after the most recent record in the shard, so that you always read the most recent data. </p> </li> </ul>
208
+ sequence_number: <p> The sequence number of the data record in the shard from which to start reading. Required if <code>ShardIteratorType</code> is <code>AT_SEQUENCE_NUMBER</code> or <code>AFTER_SEQUENCE_NUMBER</code>. This parameter is ignored for other iterator types. </p>
209
+
210
+ Raises:
211
+ capo_keyspacesstreams.errors.access_denied_exception.AccessDeniedException: <p>You don't have sufficient access permissions to perform this operation. </p> <p>This exception occurs when your IAM user or role lacks the required permissions to access the Amazon Keyspaces resource or perform the requested action. Check your IAM policies and ensure they grant the necessary permissions.</p>
212
+ capo_keyspacesstreams.errors.internal_server_exception.InternalServerException: <p>The Amazon Keyspaces service encountered an unexpected error while processing the request. </p> <p>This internal server error is not related to your request parameters. Retry your request after a brief delay. If the issue persists, contact Amazon Web Services Support with details of your request to help identify and resolve the problem.</p>
213
+ capo_keyspacesstreams.errors.resource_not_found_exception.ResourceNotFoundException: <p>The requested resource doesn't exist or could not be found. </p> <p>This exception occurs when you attempt to access a keyspace, table, stream, or other Amazon Keyspaces resource that doesn't exist or that has been deleted. Verify that the resource identifier is correct and that the resource exists in your account.</p>
214
+ capo_keyspacesstreams.errors.throttling_exception.ThrottlingException: <p>The request rate is too high and exceeds the service's throughput limits. </p> <p>This exception occurs when you send too many requests in a short period of time. Implement exponential backoff in your retry strategy to handle this exception. Reducing your request frequency or distributing requests more evenly can help avoid throughput exceptions.</p> <p>This exception can also occur when more than two processes are reading from the same stream shard at the same time. Ensure that only one process reads from a stream shard at the same time. </p>
215
+ capo_keyspacesstreams.errors.validation_exception.ValidationException: <p>The request validation failed because one or more input parameters failed validation. </p> <p>This exception occurs when there are syntax errors in the request, field constraints are violated, or required parameters are missing. To help you fix the issue, the exception message provides details about which parameter failed and why.</p>
216
+ capo_keyspacesstreams.errors.UnknownServiceError: The service returned an error code this client does not model.
217
+ """
218
+
219
+ def _handler(
220
+ req: "OperationRequest[capo_keyspacesstreams.types.get_shard_iterator_input.GetShardIteratorInput]",
221
+ ) -> OperationResponse[
222
+ "capo_keyspacesstreams.types.get_shard_iterator_output.GetShardIteratorOutput"
223
+ ]:
224
+ import capo_keyspacesstreams._operations.keyspaces_streams.get_shard_iterator
225
+
226
+ output, http_response = (
227
+ capo_keyspacesstreams._operations.keyspaces_streams.get_shard_iterator.get_shard_iterator(
228
+ req.options, req.input
229
+ )
230
+ )
231
+ return OperationResponse(output=output, response=http_response)
232
+
233
+ interceptors_, options_ = self.operation_options(config_overrides)
234
+ input_: capo_keyspacesstreams.types.get_shard_iterator_input.GetShardIteratorInput = {
235
+ "stream_arn": stream_arn,
236
+ "shard_id": shard_id,
237
+ "shard_iterator_type": shard_iterator_type,
238
+ }
239
+ if sequence_number is not None:
240
+ input_["sequence_number"] = sequence_number
241
+
242
+ response = execute_pipeline(
243
+ OperationRequest(input=input_, options=options_),
244
+ handler=_handler,
245
+ interceptors=list(interceptors_),
246
+ )
247
+ response.response.close()
248
+ return response.output
249
+
250
+ def get_stream(
251
+ self,
252
+ stream_arn: "capo_keyspacesstreams.types.stream_arn.StreamArn",
253
+ *,
254
+ config_overrides: Optional[KeyspacesStreamsClientConfig] = None,
255
+ max_results: Optional[int] = None,
256
+ shard_filter: Optional[
257
+ "capo_keyspacesstreams.types.shard_filter.ShardFilter"
258
+ ] = None,
259
+ next_token: Optional[
260
+ "capo_keyspacesstreams.types.shard_id_token.ShardIdToken"
261
+ ] = None,
262
+ ) -> "capo_keyspacesstreams.types.get_stream_output.GetStreamOutput":
263
+ """<p>Returns detailed information about a specific data capture stream for an Amazon Keyspaces table. The information includes the stream's Amazon Resource Name (ARN), creation time, current status, retention period, shard composition, and associated table details. This operation helps you monitor and manage the configuration of your Amazon Keyspaces data streams.</p>
264
+
265
+ Args:
266
+ stream_arn: <p> The Amazon Resource Name (ARN) of the stream for which detailed information is requested. This uniquely identifies the specific stream you want to get information about. </p>
267
+ max_results: <p> The maximum number of shard objects to return in a single <code>GetStream</code> request. The default value is 100. The minimum value is 1 and the maximum value is 100. </p>
268
+ shard_filter: <p> Optional filter criteria to apply when retrieving shards. You can filter shards based on their parent <code>shardID</code> to get a list of children shards to narrow down the results returned by the <code>GetStream</code> operation. </p>
269
+ next_token: <p> An optional pagination token provided by a previous <code>GetStream</code> operation. If this parameter is specified, the response includes only records beyond the token, up to the value specified by <code>MaxResults</code>. </p>
270
+
271
+ Raises:
272
+ capo_keyspacesstreams.errors.access_denied_exception.AccessDeniedException: <p>You don't have sufficient access permissions to perform this operation. </p> <p>This exception occurs when your IAM user or role lacks the required permissions to access the Amazon Keyspaces resource or perform the requested action. Check your IAM policies and ensure they grant the necessary permissions.</p>
273
+ capo_keyspacesstreams.errors.internal_server_exception.InternalServerException: <p>The Amazon Keyspaces service encountered an unexpected error while processing the request. </p> <p>This internal server error is not related to your request parameters. Retry your request after a brief delay. If the issue persists, contact Amazon Web Services Support with details of your request to help identify and resolve the problem.</p>
274
+ capo_keyspacesstreams.errors.resource_not_found_exception.ResourceNotFoundException: <p>The requested resource doesn't exist or could not be found. </p> <p>This exception occurs when you attempt to access a keyspace, table, stream, or other Amazon Keyspaces resource that doesn't exist or that has been deleted. Verify that the resource identifier is correct and that the resource exists in your account.</p>
275
+ capo_keyspacesstreams.errors.throttling_exception.ThrottlingException: <p>The request rate is too high and exceeds the service's throughput limits. </p> <p>This exception occurs when you send too many requests in a short period of time. Implement exponential backoff in your retry strategy to handle this exception. Reducing your request frequency or distributing requests more evenly can help avoid throughput exceptions.</p> <p>This exception can also occur when more than two processes are reading from the same stream shard at the same time. Ensure that only one process reads from a stream shard at the same time. </p>
276
+ capo_keyspacesstreams.errors.validation_exception.ValidationException: <p>The request validation failed because one or more input parameters failed validation. </p> <p>This exception occurs when there are syntax errors in the request, field constraints are violated, or required parameters are missing. To help you fix the issue, the exception message provides details about which parameter failed and why.</p>
277
+ capo_keyspacesstreams.errors.UnknownServiceError: The service returned an error code this client does not model.
278
+ """
279
+
280
+ def _handler(
281
+ req: "OperationRequest[capo_keyspacesstreams.types.get_stream_input.GetStreamInput]",
282
+ ) -> OperationResponse[
283
+ "capo_keyspacesstreams.types.get_stream_output.GetStreamOutput"
284
+ ]:
285
+ import capo_keyspacesstreams._operations.keyspaces_streams.get_stream
286
+
287
+ output, http_response = (
288
+ capo_keyspacesstreams._operations.keyspaces_streams.get_stream.get_stream(
289
+ req.options, req.input
290
+ )
291
+ )
292
+ return OperationResponse(output=output, response=http_response)
293
+
294
+ interceptors_, options_ = self.operation_options(config_overrides)
295
+ input_: capo_keyspacesstreams.types.get_stream_input.GetStreamInput = {
296
+ "stream_arn": stream_arn
297
+ }
298
+ if max_results is not None:
299
+ input_["max_results"] = max_results
300
+ if shard_filter is not None:
301
+ input_["shard_filter"] = shard_filter
302
+ if next_token is not None:
303
+ input_["next_token"] = next_token
304
+
305
+ response = execute_pipeline(
306
+ OperationRequest(input=input_, options=options_),
307
+ handler=_handler,
308
+ interceptors=list(interceptors_),
309
+ )
310
+ response.response.close()
311
+ return response.output
312
+
313
+ def iter_get_stream(
314
+ self,
315
+ stream_arn: "capo_keyspacesstreams.types.stream_arn.StreamArn",
316
+ *,
317
+ config_overrides: Optional[KeyspacesStreamsClientConfig] = None,
318
+ max_results: Optional[int] = None,
319
+ shard_filter: Optional[
320
+ "capo_keyspacesstreams.types.shard_filter.ShardFilter"
321
+ ] = None,
322
+ next_token: Optional[
323
+ "capo_keyspacesstreams.types.shard_id_token.ShardIdToken"
324
+ ] = None,
325
+ ) -> "Iterator[capo_keyspacesstreams.types.shard.Shard]":
326
+ _token = next_token
327
+ while True:
328
+ _response = self.get_stream(
329
+ stream_arn,
330
+ config_overrides=config_overrides,
331
+ max_results=max_results,
332
+ shard_filter=shard_filter,
333
+ next_token=_token,
334
+ )
335
+ _page = _resolve_path(_response, ("shards",))
336
+ for _item in _page or []:
337
+ yield _item
338
+ _token = _resolve_path(_response, ("next_token",))
339
+ if not _token:
340
+ break
341
+
342
+ def list_streams(
343
+ self,
344
+ *,
345
+ config_overrides: Optional[KeyspacesStreamsClientConfig] = None,
346
+ keyspace_name: Optional[
347
+ "capo_keyspacesstreams.types.keyspace_name.KeyspaceName"
348
+ ] = None,
349
+ table_name: Optional["capo_keyspacesstreams.types.table_name.TableName"] = None,
350
+ max_results: Optional[int] = None,
351
+ next_token: Optional[
352
+ "capo_keyspacesstreams.types.stream_arn_token.StreamArnToken"
353
+ ] = None,
354
+ ) -> "capo_keyspacesstreams.types.list_streams_output.ListStreamsOutput":
355
+ """<p>Returns a list of all data capture streams associated with your Amazon Keyspaces account or for a specific keyspace or table. The response includes information such as stream ARNs, table associations, creation timestamps, and current status. This operation helps you discover and manage all active data streams in your Amazon Keyspaces environment.</p>
356
+
357
+ Args:
358
+ keyspace_name: <p> The name of the keyspace for which to list streams. If specified, only streams associated with tables in this keyspace are returned. If omitted, streams from all keyspaces are included in the results. </p>
359
+ table_name: <p> The name of the table for which to list streams. Must be used together with <code>keyspaceName</code>. If specified, only streams associated with this specific table are returned. </p>
360
+ max_results: <p> The maximum number of streams to return in a single <code>ListStreams</code> request. The default value is 100. The minimum value is 1 and the maximum value is 100. </p>
361
+ next_token: <p> An optional pagination token provided by a previous <code>ListStreams</code> operation. If this parameter is specified, the response includes only records beyond the token, up to the value specified by <code>maxResults</code>. </p>
362
+
363
+ Raises:
364
+ capo_keyspacesstreams.errors.access_denied_exception.AccessDeniedException: <p>You don't have sufficient access permissions to perform this operation. </p> <p>This exception occurs when your IAM user or role lacks the required permissions to access the Amazon Keyspaces resource or perform the requested action. Check your IAM policies and ensure they grant the necessary permissions.</p>
365
+ capo_keyspacesstreams.errors.internal_server_exception.InternalServerException: <p>The Amazon Keyspaces service encountered an unexpected error while processing the request. </p> <p>This internal server error is not related to your request parameters. Retry your request after a brief delay. If the issue persists, contact Amazon Web Services Support with details of your request to help identify and resolve the problem.</p>
366
+ capo_keyspacesstreams.errors.resource_not_found_exception.ResourceNotFoundException: <p>The requested resource doesn't exist or could not be found. </p> <p>This exception occurs when you attempt to access a keyspace, table, stream, or other Amazon Keyspaces resource that doesn't exist or that has been deleted. Verify that the resource identifier is correct and that the resource exists in your account.</p>
367
+ capo_keyspacesstreams.errors.throttling_exception.ThrottlingException: <p>The request rate is too high and exceeds the service's throughput limits. </p> <p>This exception occurs when you send too many requests in a short period of time. Implement exponential backoff in your retry strategy to handle this exception. Reducing your request frequency or distributing requests more evenly can help avoid throughput exceptions.</p> <p>This exception can also occur when more than two processes are reading from the same stream shard at the same time. Ensure that only one process reads from a stream shard at the same time. </p>
368
+ capo_keyspacesstreams.errors.validation_exception.ValidationException: <p>The request validation failed because one or more input parameters failed validation. </p> <p>This exception occurs when there are syntax errors in the request, field constraints are violated, or required parameters are missing. To help you fix the issue, the exception message provides details about which parameter failed and why.</p>
369
+ capo_keyspacesstreams.errors.UnknownServiceError: The service returned an error code this client does not model.
370
+ """
371
+
372
+ def _handler(
373
+ req: "OperationRequest[capo_keyspacesstreams.types.list_streams_input.ListStreamsInput]",
374
+ ) -> OperationResponse[
375
+ "capo_keyspacesstreams.types.list_streams_output.ListStreamsOutput"
376
+ ]:
377
+ import capo_keyspacesstreams._operations.keyspaces_streams.list_streams
378
+
379
+ output, http_response = (
380
+ capo_keyspacesstreams._operations.keyspaces_streams.list_streams.list_streams(
381
+ req.options, req.input
382
+ )
383
+ )
384
+ return OperationResponse(output=output, response=http_response)
385
+
386
+ interceptors_, options_ = self.operation_options(config_overrides)
387
+ input_: capo_keyspacesstreams.types.list_streams_input.ListStreamsInput = {}
388
+ if keyspace_name is not None:
389
+ input_["keyspace_name"] = keyspace_name
390
+ if table_name is not None:
391
+ input_["table_name"] = table_name
392
+ if max_results is not None:
393
+ input_["max_results"] = max_results
394
+ if next_token is not None:
395
+ input_["next_token"] = next_token
396
+
397
+ response = execute_pipeline(
398
+ OperationRequest(input=input_, options=options_),
399
+ handler=_handler,
400
+ interceptors=list(interceptors_),
401
+ )
402
+ response.response.close()
403
+ return response.output
404
+
405
+ def iter_list_streams(
406
+ self,
407
+ *,
408
+ config_overrides: Optional[KeyspacesStreamsClientConfig] = None,
409
+ keyspace_name: Optional[
410
+ "capo_keyspacesstreams.types.keyspace_name.KeyspaceName"
411
+ ] = None,
412
+ table_name: Optional["capo_keyspacesstreams.types.table_name.TableName"] = None,
413
+ max_results: Optional[int] = None,
414
+ next_token: Optional[
415
+ "capo_keyspacesstreams.types.stream_arn_token.StreamArnToken"
416
+ ] = None,
417
+ ) -> "Iterator[capo_keyspacesstreams.types.stream.Stream]":
418
+ _token = next_token
419
+ while True:
420
+ _response = self.list_streams(
421
+ config_overrides=config_overrides,
422
+ keyspace_name=keyspace_name,
423
+ table_name=table_name,
424
+ max_results=max_results,
425
+ next_token=_token,
426
+ )
427
+ _page = _resolve_path(_response, ("streams",))
428
+ for _item in _page or []:
429
+ yield _item
430
+ _token = _resolve_path(_response, ("next_token",))
431
+ if not _token:
432
+ break
433
+
434
+ def __enter__(self) -> Self:
435
+ return self
436
+
437
+ def __exit__(self, exc_type: Any, exc: Any, tb: Any):
438
+ self._client.close()
@@ -0,0 +1,32 @@
1
+ from __future__ import annotations
2
+
3
+ from ._base import (
4
+ DeserializationError as DeserializationError,
5
+ )
6
+ from ._base import (
7
+ KeyspacesStreamsError as KeyspacesStreamsError,
8
+ )
9
+ from ._base import (
10
+ SerializationError as SerializationError,
11
+ )
12
+ from ._base import (
13
+ ServiceError as ServiceError,
14
+ )
15
+ from ._base import (
16
+ UnknownServiceError as UnknownServiceError,
17
+ )
18
+ from ._base import (
19
+ WaiterFailedError as WaiterFailedError,
20
+ )
21
+ from ._base import (
22
+ WaiterTimeoutError as WaiterTimeoutError,
23
+ )
24
+ from .access_denied_exception import AccessDeniedException as AccessDeniedException
25
+ from .internal_server_exception import (
26
+ InternalServerException as InternalServerException,
27
+ )
28
+ from .resource_not_found_exception import (
29
+ ResourceNotFoundException as ResourceNotFoundException,
30
+ )
31
+ from .throttling_exception import ThrottlingException as ThrottlingException
32
+ from .validation_exception import ValidationException as ValidationException
@@ -0,0 +1,94 @@
1
+ from typing import Literal
2
+
3
+
4
+ class KeyspacesStreamsError(Exception):
5
+ """Base class for all KeyspacesStreams service errors."""
6
+
7
+
8
+ class ServiceError(KeyspacesStreamsError):
9
+ """Base class for all modeled service errors.
10
+
11
+ Args:
12
+ fault: ``"client"`` or ``"server"``.
13
+ is_throttling_error: Whether this error is a throttling error.
14
+ is_retryable: Whether this error is retryable.
15
+ code: The wire error code, or ``None``.
16
+ message: The error message, or ``None``.
17
+ """
18
+
19
+ code: str | None = None
20
+
21
+ def __init__(
22
+ self,
23
+ fault: Literal["client", "server"],
24
+ *,
25
+ is_throttling_error: bool,
26
+ is_retryable: bool,
27
+ code: str | None = None,
28
+ message: str | None = None,
29
+ ) -> None:
30
+ super().__init__(f"{code or '<no code>'}: {message or '<no message>'}")
31
+ self.fault = fault
32
+ self.is_throttling_error = is_throttling_error
33
+ self.is_retryable = is_retryable
34
+ self.code = code
35
+ self.message = message
36
+
37
+
38
+ class SerializationError(KeyspacesStreamsError):
39
+ """Raised when a value cannot be serialized."""
40
+
41
+
42
+ class DeserializationError(KeyspacesStreamsError):
43
+ """Raised when a value cannot be deserialized or a required member is missing."""
44
+
45
+
46
+ class UnknownServiceError(ServiceError):
47
+ """Raised when the server returns an error code the client does not model.
48
+
49
+ Args:
50
+ code: ``<Code>`` text from the response body, or ``None`` if absent.
51
+ message: ``<Message>`` text from the response body, or ``None``.
52
+ response: The original HTTP response object, for arbitrary inspection.
53
+ """
54
+
55
+ def __init__(
56
+ self, *, code: str | None, message: str | None, response: object
57
+ ) -> None:
58
+ _status = getattr(response, "status", 500)
59
+ _fault: Literal["client", "server"] = "client" if _status < 500 else "server"
60
+ _throttling = _status == 429
61
+ _retryable = _throttling or _status >= 500
62
+ super().__init__(
63
+ _fault,
64
+ is_throttling_error=_throttling,
65
+ is_retryable=_retryable,
66
+ code=code,
67
+ message=message,
68
+ )
69
+ self.response = response
70
+
71
+
72
+ class WaiterFailedError(KeyspacesStreamsError):
73
+ """Raised when a waiter hits an acceptor with ``state="failure"``.
74
+
75
+ Args:
76
+ waiter_name: snake_case waiter name (e.g. ``bucket_exists``).
77
+ reason: Short description of which acceptor fired.
78
+ """
79
+
80
+ def __init__(self, waiter_name: str, reason: str) -> None:
81
+ super().__init__(f"waiter {waiter_name} failed: {reason}")
82
+ self.waiter_name = waiter_name
83
+ self.reason = reason
84
+
85
+
86
+ class WaiterTimeoutError(KeyspacesStreamsError):
87
+ """Raised when a waiter exhausts ``max_wait_time`` without a terminal acceptor."""
88
+
89
+ def __init__(self, waiter_name: str, max_wait_time: float) -> None:
90
+ super().__init__(
91
+ f"waiter {waiter_name} timed out after {max_wait_time} seconds"
92
+ )
93
+ self.waiter_name = waiter_name
94
+ self.max_wait_time = max_wait_time
@@ -0,0 +1,47 @@
1
+ """Generated from Smithy shape ``com.amazonaws.keyspacesstreams#AccessDeniedException``."""
2
+
3
+ from typing_extensions import NotRequired, TypedDict
4
+
5
+ from capo_keyspacesstreams.errors import ServiceError
6
+
7
+
8
+ class AccessDeniedException_(TypedDict, closed=True):
9
+ message: NotRequired["str"]
10
+ """<p>You don't have sufficient permissions to perform this action.</p>"""
11
+
12
+
13
+ # --- awsJson1_0 ser/de ---
14
+ def serialize_aws_json_1_0(value: AccessDeniedException_) -> dict:
15
+ out: dict = {}
16
+ if "message" in value:
17
+ out["message"] = value["message"]
18
+ return out
19
+
20
+
21
+ def deserialize_aws_json_1_0(data: dict) -> AccessDeniedException_:
22
+ out: AccessDeniedException_ = {} # type: ignore[typeddict-item]
23
+ if data.get("message") is not None:
24
+ out["message"] = data["message"]
25
+ return out
26
+
27
+
28
+ class AccessDeniedException(ServiceError):
29
+ """Modeled error for Smithy shape ``com.amazonaws.keyspacesstreams#AccessDeniedException``."""
30
+
31
+ code: str | None = "AccessDeniedException"
32
+
33
+ def __init__(self, data: AccessDeniedException_, message: str | None = None):
34
+ super().__init__(
35
+ "client",
36
+ is_throttling_error=False,
37
+ is_retryable=False,
38
+ code="AccessDeniedException",
39
+ message=message,
40
+ )
41
+ self.data = data
42
+
43
+ @classmethod
44
+ def from_aws_json_1_0(
45
+ cls, data: dict, message: str | None = None
46
+ ) -> "AccessDeniedException":
47
+ return cls(deserialize_aws_json_1_0(data), message)