rusoto_dynamodbstreams/generated.rs
1// =================================================================
2//
3// * WARNING *
4//
5// This file is generated!
6//
7// Changes made to this file will be overwritten. If changes are
8// required to the generated code, the service_crategen project
9// must be updated to generate the changes.
10//
11// =================================================================
12
13use std::error::Error;
14use std::fmt;
15
16use async_trait::async_trait;
17use rusoto_core::credential::ProvideAwsCredentials;
18use rusoto_core::region;
19use rusoto_core::request::{BufferedHttpResponse, DispatchSignedRequest};
20use rusoto_core::{Client, RusotoError};
21
22use rusoto_core::proto;
23use rusoto_core::request::HttpResponse;
24use rusoto_core::signature::SignedRequest;
25#[allow(unused_imports)]
26use serde::{Deserialize, Serialize};
27
28impl DynamoDbStreamsClient {
29 fn new_signed_request(&self, http_method: &str, request_uri: &str) -> SignedRequest {
30 let mut request = SignedRequest::new(http_method, "dynamodb", &self.region, request_uri);
31 request.set_endpoint_prefix("streams.dynamodb".to_string());
32
33 request.set_content_type("application/x-amz-json-1.0".to_owned());
34
35 request
36 }
37
38 async fn sign_and_dispatch<E>(
39 &self,
40 request: SignedRequest,
41 from_response: fn(BufferedHttpResponse) -> RusotoError<E>,
42 ) -> Result<HttpResponse, RusotoError<E>> {
43 let mut response = self.client.sign_and_dispatch(request).await?;
44 if !response.status.is_success() {
45 let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
46 return Err(from_response(response));
47 }
48
49 Ok(response)
50 }
51}
52
53use serde_json;
54/// <p>Represents the data for an attribute. You can set one, and only one, of the elements.</p> <p>Each attribute in an item is a name-value pair. An attribute can be single-valued or multi-valued set. For example, a book item can have title and authors attributes. Each book has one title but can have many authors. The multi-valued attribute is a set; duplicate values are not allowed.</p>
55#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
56#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
57pub struct AttributeValue {
58 /// <p>A Binary data type.</p>
59 #[serde(rename = "B")]
60 #[serde(
61 deserialize_with = "::rusoto_core::serialization::SerdeBlob::deserialize_blob",
62 serialize_with = "::rusoto_core::serialization::SerdeBlob::serialize_blob",
63 default
64 )]
65 #[serde(skip_serializing_if = "Option::is_none")]
66 pub b: Option<bytes::Bytes>,
67 /// <p>A Boolean data type.</p>
68 #[serde(rename = "BOOL")]
69 #[serde(skip_serializing_if = "Option::is_none")]
70 pub bool: Option<bool>,
71 /// <p>A Binary Set data type.</p>
72 #[serde(rename = "BS")]
73 #[serde(
74 deserialize_with = "::rusoto_core::serialization::SerdeBlobList::deserialize_blob_list",
75 serialize_with = "::rusoto_core::serialization::SerdeBlobList::serialize_blob_list",
76 default
77 )]
78 #[serde(skip_serializing_if = "Option::is_none")]
79 pub bs: Option<Vec<bytes::Bytes>>,
80 /// <p>A List data type.</p>
81 #[serde(rename = "L")]
82 #[serde(skip_serializing_if = "Option::is_none")]
83 pub l: Option<Vec<AttributeValue>>,
84 /// <p>A Map data type.</p>
85 #[serde(rename = "M")]
86 #[serde(skip_serializing_if = "Option::is_none")]
87 pub m: Option<::std::collections::HashMap<String, AttributeValue>>,
88 /// <p>A Number data type.</p>
89 #[serde(rename = "N")]
90 #[serde(skip_serializing_if = "Option::is_none")]
91 pub n: Option<String>,
92 /// <p>A Number Set data type.</p>
93 #[serde(rename = "NS")]
94 #[serde(skip_serializing_if = "Option::is_none")]
95 pub ns: Option<Vec<String>>,
96 /// <p>A Null data type.</p>
97 #[serde(rename = "NULL")]
98 #[serde(skip_serializing_if = "Option::is_none")]
99 pub null: Option<bool>,
100 /// <p>A String data type.</p>
101 #[serde(rename = "S")]
102 #[serde(skip_serializing_if = "Option::is_none")]
103 pub s: Option<String>,
104 /// <p>A String Set data type.</p>
105 #[serde(rename = "SS")]
106 #[serde(skip_serializing_if = "Option::is_none")]
107 pub ss: Option<Vec<String>>,
108}
109
110/// <p>Represents the input of a <code>DescribeStream</code> operation.</p>
111#[derive(Clone, Debug, Default, PartialEq, Serialize)]
112#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
113pub struct DescribeStreamInput {
114 /// <p>The shard ID of the first item that this operation will evaluate. Use the value that was returned for <code>LastEvaluatedShardId</code> in the previous operation. </p>
115 #[serde(rename = "ExclusiveStartShardId")]
116 #[serde(skip_serializing_if = "Option::is_none")]
117 pub exclusive_start_shard_id: Option<String>,
118 /// <p>The maximum number of shard objects to return. The upper limit is 100.</p>
119 #[serde(rename = "Limit")]
120 #[serde(skip_serializing_if = "Option::is_none")]
121 pub limit: Option<i64>,
122 /// <p>The Amazon Resource Name (ARN) for the stream.</p>
123 #[serde(rename = "StreamArn")]
124 pub stream_arn: String,
125}
126
127/// <p>Represents the output of a <code>DescribeStream</code> operation.</p>
128#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
129#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
130pub struct DescribeStreamOutput {
131 /// <p>A complete description of the stream, including its creation date and time, the DynamoDB table associated with the stream, the shard IDs within the stream, and the beginning and ending sequence numbers of stream records within the shards.</p>
132 #[serde(rename = "StreamDescription")]
133 #[serde(skip_serializing_if = "Option::is_none")]
134 pub stream_description: Option<StreamDescription>,
135}
136
137/// <p>Represents the input of a <code>GetRecords</code> operation.</p>
138#[derive(Clone, Debug, Default, PartialEq, Serialize)]
139#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
140pub struct GetRecordsInput {
141 /// <p>The maximum number of records to return from the shard. The upper limit is 1000.</p>
142 #[serde(rename = "Limit")]
143 #[serde(skip_serializing_if = "Option::is_none")]
144 pub limit: Option<i64>,
145 /// <p>A shard iterator that was retrieved from a previous GetShardIterator operation. This iterator can be used to access the stream records in this shard.</p>
146 #[serde(rename = "ShardIterator")]
147 pub shard_iterator: String,
148}
149
150/// <p>Represents the output of a <code>GetRecords</code> operation.</p>
151#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
152#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
153pub struct GetRecordsOutput {
154 /// <p>The next position in the shard from which to start sequentially reading stream records. If set to <code>null</code>, the shard has been closed and the requested iterator will not return any more data.</p>
155 #[serde(rename = "NextShardIterator")]
156 #[serde(skip_serializing_if = "Option::is_none")]
157 pub next_shard_iterator: Option<String>,
158 /// <p>The stream records from the shard, which were retrieved using the shard iterator.</p>
159 #[serde(rename = "Records")]
160 #[serde(skip_serializing_if = "Option::is_none")]
161 pub records: Option<Vec<Record>>,
162}
163
164/// <p>Represents the input of a <code>GetShardIterator</code> operation.</p>
165#[derive(Clone, Debug, Default, PartialEq, Serialize)]
166#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
167pub struct GetShardIteratorInput {
168 /// <p>The sequence number of a stream record in the shard from which to start reading.</p>
169 #[serde(rename = "SequenceNumber")]
170 #[serde(skip_serializing_if = "Option::is_none")]
171 pub sequence_number: Option<String>,
172 /// <p>The identifier of the shard. The iterator will be returned for this shard ID.</p>
173 #[serde(rename = "ShardId")]
174 pub shard_id: String,
175 /// <p><p>Determines how the shard iterator is used to start reading stream records from the shard:</p> <ul> <li> <p> <code>AT<em>SEQUENCE</em>NUMBER</code> - Start reading exactly from the position denoted by a specific sequence number.</p> </li> <li> <p> <code>AFTER<em>SEQUENCE</em>NUMBER</code> - Start reading right after the position denoted by a specific sequence number.</p> </li> <li> <p> <code>TRIM_HORIZON</code> - Start reading at the last (untrimmed) stream record, which is the oldest record in the shard. In DynamoDB Streams, there is a 24 hour limit on data retention. Stream records whose age exceeds this limit are subject to removal (trimming) from the stream.</p> </li> <li> <p> <code>LATEST</code> - Start reading just after the most recent stream record in the shard, so that you always read the most recent data in the shard.</p> </li> </ul></p>
176 #[serde(rename = "ShardIteratorType")]
177 pub shard_iterator_type: String,
178 /// <p>The Amazon Resource Name (ARN) for the stream.</p>
179 #[serde(rename = "StreamArn")]
180 pub stream_arn: String,
181}
182
183/// <p>Represents the output of a <code>GetShardIterator</code> operation.</p>
184#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
185#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
186pub struct GetShardIteratorOutput {
187 /// <p>The position in the shard from which to start reading stream records sequentially. A shard iterator specifies this position using the sequence number of a stream record in a shard.</p>
188 #[serde(rename = "ShardIterator")]
189 #[serde(skip_serializing_if = "Option::is_none")]
190 pub shard_iterator: Option<String>,
191}
192
193/// <p>Contains details about the type of identity that made the request.</p>
194#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
195#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
196pub struct Identity {
197 /// <p>A unique identifier for the entity that made the call. For Time To Live, the principalId is "dynamodb.amazonaws.com".</p>
198 #[serde(rename = "PrincipalId")]
199 #[serde(skip_serializing_if = "Option::is_none")]
200 pub principal_id: Option<String>,
201 /// <p>The type of the identity. For Time To Live, the type is "Service".</p>
202 #[serde(rename = "Type")]
203 #[serde(skip_serializing_if = "Option::is_none")]
204 pub type_: Option<String>,
205}
206
207/// <p><p>Represents <i>a single element</i> of a key schema. A key schema specifies the attributes that make up the primary key of a table, or the key attributes of an index.</p> <p>A <code>KeySchemaElement</code> represents exactly one attribute of the primary key. For example, a simple primary key (partition key) would be represented by one <code>KeySchemaElement</code>. A composite primary key (partition key and sort key) would require one <code>KeySchemaElement</code> for the partition key, and another <code>KeySchemaElement</code> for the sort key.</p> <note> <p>The partition key of an item is also known as its <i>hash attribute</i>. The term "hash attribute" derives from DynamoDB's usage of an internal hash function to evenly distribute data items across partitions, based on their partition key values.</p> <p>The sort key of an item is also known as its <i>range attribute</i>. The term "range attribute" derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.</p> </note></p>
208#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
209#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
210pub struct KeySchemaElement {
211 /// <p>The name of a key attribute.</p>
212 #[serde(rename = "AttributeName")]
213 pub attribute_name: String,
214 /// <p>The attribute data, consisting of the data type and the attribute value itself.</p>
215 #[serde(rename = "KeyType")]
216 pub key_type: String,
217}
218
219/// <p>Represents the input of a <code>ListStreams</code> operation.</p>
220#[derive(Clone, Debug, Default, PartialEq, Serialize)]
221#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
222pub struct ListStreamsInput {
223 /// <p>The ARN (Amazon Resource Name) of the first item that this operation will evaluate. Use the value that was returned for <code>LastEvaluatedStreamArn</code> in the previous operation. </p>
224 #[serde(rename = "ExclusiveStartStreamArn")]
225 #[serde(skip_serializing_if = "Option::is_none")]
226 pub exclusive_start_stream_arn: Option<String>,
227 /// <p>The maximum number of streams to return. The upper limit is 100.</p>
228 #[serde(rename = "Limit")]
229 #[serde(skip_serializing_if = "Option::is_none")]
230 pub limit: Option<i64>,
231 /// <p>If this parameter is provided, then only the streams associated with this table name are returned.</p>
232 #[serde(rename = "TableName")]
233 #[serde(skip_serializing_if = "Option::is_none")]
234 pub table_name: Option<String>,
235}
236
237/// <p>Represents the output of a <code>ListStreams</code> operation.</p>
238#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
239#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
240pub struct ListStreamsOutput {
241 /// <p>The stream ARN of the item where the operation stopped, inclusive of the previous result set. Use this value to start a new operation, excluding this value in the new request.</p> <p>If <code>LastEvaluatedStreamArn</code> is empty, then the "last page" of results has been processed and there is no more data to be retrieved.</p> <p>If <code>LastEvaluatedStreamArn</code> is not empty, it does not necessarily mean that there is more data in the result set. The only way to know when you have reached the end of the result set is when <code>LastEvaluatedStreamArn</code> is empty.</p>
242 #[serde(rename = "LastEvaluatedStreamArn")]
243 #[serde(skip_serializing_if = "Option::is_none")]
244 pub last_evaluated_stream_arn: Option<String>,
245 /// <p>A list of stream descriptors associated with the current account and endpoint.</p>
246 #[serde(rename = "Streams")]
247 #[serde(skip_serializing_if = "Option::is_none")]
248 pub streams: Option<Vec<Stream>>,
249}
250
251/// <p>A description of a unique event within a stream.</p>
252#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
253#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
254pub struct Record {
255 /// <p>The region in which the <code>GetRecords</code> request was received.</p>
256 #[serde(rename = "awsRegion")]
257 #[serde(skip_serializing_if = "Option::is_none")]
258 pub aws_region: Option<String>,
259 /// <p>The main body of the stream record, containing all of the DynamoDB-specific fields.</p>
260 #[serde(rename = "dynamodb")]
261 #[serde(skip_serializing_if = "Option::is_none")]
262 pub dynamodb: Option<StreamRecord>,
263 /// <p>A globally unique identifier for the event that was recorded in this stream record.</p>
264 #[serde(rename = "eventID")]
265 #[serde(skip_serializing_if = "Option::is_none")]
266 pub event_id: Option<String>,
267 /// <p><p>The type of data modification that was performed on the DynamoDB table:</p> <ul> <li> <p> <code>INSERT</code> - a new item was added to the table.</p> </li> <li> <p> <code>MODIFY</code> - one or more of an existing item's attributes were modified.</p> </li> <li> <p> <code>REMOVE</code> - the item was deleted from the table</p> </li> </ul></p>
268 #[serde(rename = "eventName")]
269 #[serde(skip_serializing_if = "Option::is_none")]
270 pub event_name: Option<String>,
271 /// <p>The AWS service from which the stream record originated. For DynamoDB Streams, this is <code>aws:dynamodb</code>.</p>
272 #[serde(rename = "eventSource")]
273 #[serde(skip_serializing_if = "Option::is_none")]
274 pub event_source: Option<String>,
275 /// <p>The version number of the stream record format. This number is updated whenever the structure of <code>Record</code> is modified.</p> <p>Client applications must not assume that <code>eventVersion</code> will remain at a particular value, as this number is subject to change at any time. In general, <code>eventVersion</code> will only increase as the low-level DynamoDB Streams API evolves.</p>
276 #[serde(rename = "eventVersion")]
277 #[serde(skip_serializing_if = "Option::is_none")]
278 pub event_version: Option<String>,
279 /// <p><p>Items that are deleted by the Time to Live process after expiration have the following fields: </p> <ul> <li> <p>Records[].userIdentity.type</p> <p>"Service"</p> </li> <li> <p>Records[].userIdentity.principalId</p> <p>"dynamodb.amazonaws.com"</p> </li> </ul></p>
280 #[serde(rename = "userIdentity")]
281 #[serde(skip_serializing_if = "Option::is_none")]
282 pub user_identity: Option<Identity>,
283}
284
285/// <p>The beginning and ending sequence numbers for the stream records contained within a shard.</p>
286#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
287#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
288pub struct SequenceNumberRange {
289 /// <p>The last sequence number.</p>
290 #[serde(rename = "EndingSequenceNumber")]
291 #[serde(skip_serializing_if = "Option::is_none")]
292 pub ending_sequence_number: Option<String>,
293 /// <p>The first sequence number.</p>
294 #[serde(rename = "StartingSequenceNumber")]
295 #[serde(skip_serializing_if = "Option::is_none")]
296 pub starting_sequence_number: Option<String>,
297}
298
299/// <p>A uniquely identified group of stream records within a stream.</p>
300#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
301#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
302pub struct Shard {
303 /// <p>The shard ID of the current shard's parent.</p>
304 #[serde(rename = "ParentShardId")]
305 #[serde(skip_serializing_if = "Option::is_none")]
306 pub parent_shard_id: Option<String>,
307 /// <p>The range of possible sequence numbers for the shard.</p>
308 #[serde(rename = "SequenceNumberRange")]
309 #[serde(skip_serializing_if = "Option::is_none")]
310 pub sequence_number_range: Option<SequenceNumberRange>,
311 /// <p>The system-generated identifier for this shard.</p>
312 #[serde(rename = "ShardId")]
313 #[serde(skip_serializing_if = "Option::is_none")]
314 pub shard_id: Option<String>,
315}
316
317/// <p>Represents all of the data describing a particular stream.</p>
318#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
319#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
320pub struct Stream {
321 /// <p>The Amazon Resource Name (ARN) for the stream.</p>
322 #[serde(rename = "StreamArn")]
323 #[serde(skip_serializing_if = "Option::is_none")]
324 pub stream_arn: Option<String>,
325 /// <p><p>A timestamp, in ISO 8601 format, for this stream.</p> <p>Note that <code>LatestStreamLabel</code> is not a unique identifier for the stream, because it is possible that a stream from another table might have the same timestamp. However, the combination of the following three elements is guaranteed to be unique:</p> <ul> <li> <p>the AWS customer ID.</p> </li> <li> <p>the table name</p> </li> <li> <p>the <code>StreamLabel</code> </p> </li> </ul></p>
326 #[serde(rename = "StreamLabel")]
327 #[serde(skip_serializing_if = "Option::is_none")]
328 pub stream_label: Option<String>,
329 /// <p>The DynamoDB table with which the stream is associated.</p>
330 #[serde(rename = "TableName")]
331 #[serde(skip_serializing_if = "Option::is_none")]
332 pub table_name: Option<String>,
333}
334
335/// <p>Represents all of the data describing a particular stream.</p>
336#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
337#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
338pub struct StreamDescription {
339 /// <p>The date and time when the request to create this stream was issued.</p>
340 #[serde(rename = "CreationRequestDateTime")]
341 #[serde(skip_serializing_if = "Option::is_none")]
342 pub creation_request_date_time: Option<f64>,
343 /// <p>The key attribute(s) of the stream's DynamoDB table.</p>
344 #[serde(rename = "KeySchema")]
345 #[serde(skip_serializing_if = "Option::is_none")]
346 pub key_schema: Option<Vec<KeySchemaElement>>,
347 /// <p>The shard ID of the item where the operation stopped, inclusive of the previous result set. Use this value to start a new operation, excluding this value in the new request.</p> <p>If <code>LastEvaluatedShardId</code> is empty, then the "last page" of results has been processed and there is currently no more data to be retrieved.</p> <p>If <code>LastEvaluatedShardId</code> is not empty, it does not necessarily mean that there is more data in the result set. The only way to know when you have reached the end of the result set is when <code>LastEvaluatedShardId</code> is empty.</p>
348 #[serde(rename = "LastEvaluatedShardId")]
349 #[serde(skip_serializing_if = "Option::is_none")]
350 pub last_evaluated_shard_id: Option<String>,
351 /// <p>The shards that comprise the stream.</p>
352 #[serde(rename = "Shards")]
353 #[serde(skip_serializing_if = "Option::is_none")]
354 pub shards: Option<Vec<Shard>>,
355 /// <p>The Amazon Resource Name (ARN) for the stream.</p>
356 #[serde(rename = "StreamArn")]
357 #[serde(skip_serializing_if = "Option::is_none")]
358 pub stream_arn: Option<String>,
359 /// <p><p>A timestamp, in ISO 8601 format, for this stream.</p> <p>Note that <code>LatestStreamLabel</code> is not a unique identifier for the stream, because it is possible that a stream from another table might have the same timestamp. However, the combination of the following three elements is guaranteed to be unique:</p> <ul> <li> <p>the AWS customer ID.</p> </li> <li> <p>the table name</p> </li> <li> <p>the <code>StreamLabel</code> </p> </li> </ul></p>
360 #[serde(rename = "StreamLabel")]
361 #[serde(skip_serializing_if = "Option::is_none")]
362 pub stream_label: Option<String>,
363 /// <p><p>Indicates the current status of the stream:</p> <ul> <li> <p> <code>ENABLING</code> - Streams is currently being enabled on the DynamoDB table.</p> </li> <li> <p> <code>ENABLED</code> - the stream is enabled.</p> </li> <li> <p> <code>DISABLING</code> - Streams is currently being disabled on the DynamoDB table.</p> </li> <li> <p> <code>DISABLED</code> - the stream is disabled.</p> </li> </ul></p>
364 #[serde(rename = "StreamStatus")]
365 #[serde(skip_serializing_if = "Option::is_none")]
366 pub stream_status: Option<String>,
367 /// <p><p>Indicates the format of the records within this stream:</p> <ul> <li> <p> <code>KEYS<em>ONLY</code> - only the key attributes of items that were modified in the DynamoDB table.</p> </li> <li> <p> <code>NEW</em>IMAGE</code> - entire items from the table, as they appeared after they were modified.</p> </li> <li> <p> <code>OLD<em>IMAGE</code> - entire items from the table, as they appeared before they were modified.</p> </li> <li> <p> <code>NEW</em>AND<em>OLD</em>IMAGES</code> - both the new and the old images of the items from the table.</p> </li> </ul></p>
368 #[serde(rename = "StreamViewType")]
369 #[serde(skip_serializing_if = "Option::is_none")]
370 pub stream_view_type: Option<String>,
371 /// <p>The DynamoDB table with which the stream is associated.</p>
372 #[serde(rename = "TableName")]
373 #[serde(skip_serializing_if = "Option::is_none")]
374 pub table_name: Option<String>,
375}
376
377/// <p>A description of a single data modification that was performed on an item in a DynamoDB table.</p>
378#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
379#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
380pub struct StreamRecord {
381 /// <p>The approximate date and time when the stream record was created, in <a href="http://www.epochconverter.com/">UNIX epoch time</a> format.</p>
382 #[serde(rename = "ApproximateCreationDateTime")]
383 #[serde(skip_serializing_if = "Option::is_none")]
384 pub approximate_creation_date_time: Option<f64>,
385 /// <p>The primary key attribute(s) for the DynamoDB item that was modified.</p>
386 #[serde(rename = "Keys")]
387 #[serde(skip_serializing_if = "Option::is_none")]
388 pub keys: Option<::std::collections::HashMap<String, AttributeValue>>,
389 /// <p>The item in the DynamoDB table as it appeared after it was modified.</p>
390 #[serde(rename = "NewImage")]
391 #[serde(skip_serializing_if = "Option::is_none")]
392 pub new_image: Option<::std::collections::HashMap<String, AttributeValue>>,
393 /// <p>The item in the DynamoDB table as it appeared before it was modified.</p>
394 #[serde(rename = "OldImage")]
395 #[serde(skip_serializing_if = "Option::is_none")]
396 pub old_image: Option<::std::collections::HashMap<String, AttributeValue>>,
397 /// <p>The sequence number of the stream record.</p>
398 #[serde(rename = "SequenceNumber")]
399 #[serde(skip_serializing_if = "Option::is_none")]
400 pub sequence_number: Option<String>,
401 /// <p>The size of the stream record, in bytes.</p>
402 #[serde(rename = "SizeBytes")]
403 #[serde(skip_serializing_if = "Option::is_none")]
404 pub size_bytes: Option<i64>,
405 /// <p><p>The type of data from the modified DynamoDB item that was captured in this stream record:</p> <ul> <li> <p> <code>KEYS<em>ONLY</code> - only the key attributes of the modified item.</p> </li> <li> <p> <code>NEW</em>IMAGE</code> - the entire item, as it appeared after it was modified.</p> </li> <li> <p> <code>OLD<em>IMAGE</code> - the entire item, as it appeared before it was modified.</p> </li> <li> <p> <code>NEW</em>AND<em>OLD</em>IMAGES</code> - both the new and the old item images of the item.</p> </li> </ul></p>
406 #[serde(rename = "StreamViewType")]
407 #[serde(skip_serializing_if = "Option::is_none")]
408 pub stream_view_type: Option<String>,
409}
410
411/// Errors returned by DescribeStream
412#[derive(Debug, PartialEq)]
413pub enum DescribeStreamError {
414 /// <p>An error occurred on the server side.</p>
415 InternalServerError(String),
416 /// <p>The operation tried to access a nonexistent stream.</p>
417 ResourceNotFound(String),
418}
419
420impl DescribeStreamError {
421 pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DescribeStreamError> {
422 if let Some(err) = proto::json::Error::parse(&res) {
423 match err.typ.as_str() {
424 "InternalServerError" => {
425 return RusotoError::Service(DescribeStreamError::InternalServerError(err.msg))
426 }
427 "ResourceNotFoundException" => {
428 return RusotoError::Service(DescribeStreamError::ResourceNotFound(err.msg))
429 }
430 "ValidationException" => return RusotoError::Validation(err.msg),
431 _ => {}
432 }
433 }
434 RusotoError::Unknown(res)
435 }
436}
437impl fmt::Display for DescribeStreamError {
438 #[allow(unused_variables)]
439 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
440 match *self {
441 DescribeStreamError::InternalServerError(ref cause) => write!(f, "{}", cause),
442 DescribeStreamError::ResourceNotFound(ref cause) => write!(f, "{}", cause),
443 }
444 }
445}
446impl Error for DescribeStreamError {}
447/// Errors returned by GetRecords
448#[derive(Debug, PartialEq)]
449pub enum GetRecordsError {
450 /// <p>The shard iterator has expired and can no longer be used to retrieve stream records. A shard iterator expires 15 minutes after it is retrieved using the <code>GetShardIterator</code> action.</p>
451 ExpiredIterator(String),
452 /// <p>An error occurred on the server side.</p>
453 InternalServerError(String),
454 /// <p>Your request rate is too high. The AWS SDKs for DynamoDB automatically retry requests that receive this exception. Your request is eventually successful, unless your retry queue is too large to finish. Reduce the frequency of requests and use exponential backoff. For more information, go to <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ErrorHandling.html#APIRetries">Error Retries and Exponential Backoff</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
455 LimitExceeded(String),
456 /// <p>The operation tried to access a nonexistent stream.</p>
457 ResourceNotFound(String),
458 /// <p><p>The operation attempted to read past the oldest stream record in a shard.</p> <p>In DynamoDB Streams, there is a 24 hour limit on data retention. Stream records whose age exceeds this limit are subject to removal (trimming) from the stream. You might receive a TrimmedDataAccessException if:</p> <ul> <li><p>You request a shard iterator with a sequence number older than the trim point (24 hours).</p> </li> <li><p>You obtain a shard iterator, but before you use the iterator in a <code>GetRecords</code> request, a stream record in the shard exceeds the 24 hour period and is trimmed. This causes the iterator to access a record that no longer exists.</p> </li> </ul></p>
459 TrimmedDataAccess(String),
460}
461
462impl GetRecordsError {
463 pub fn from_response(res: BufferedHttpResponse) -> RusotoError<GetRecordsError> {
464 if let Some(err) = proto::json::Error::parse(&res) {
465 match err.typ.as_str() {
466 "ExpiredIteratorException" => {
467 return RusotoError::Service(GetRecordsError::ExpiredIterator(err.msg))
468 }
469 "InternalServerError" => {
470 return RusotoError::Service(GetRecordsError::InternalServerError(err.msg))
471 }
472 "LimitExceededException" => {
473 return RusotoError::Service(GetRecordsError::LimitExceeded(err.msg))
474 }
475 "ResourceNotFoundException" => {
476 return RusotoError::Service(GetRecordsError::ResourceNotFound(err.msg))
477 }
478 "TrimmedDataAccessException" => {
479 return RusotoError::Service(GetRecordsError::TrimmedDataAccess(err.msg))
480 }
481 "ValidationException" => return RusotoError::Validation(err.msg),
482 _ => {}
483 }
484 }
485 RusotoError::Unknown(res)
486 }
487}
488impl fmt::Display for GetRecordsError {
489 #[allow(unused_variables)]
490 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
491 match *self {
492 GetRecordsError::ExpiredIterator(ref cause) => write!(f, "{}", cause),
493 GetRecordsError::InternalServerError(ref cause) => write!(f, "{}", cause),
494 GetRecordsError::LimitExceeded(ref cause) => write!(f, "{}", cause),
495 GetRecordsError::ResourceNotFound(ref cause) => write!(f, "{}", cause),
496 GetRecordsError::TrimmedDataAccess(ref cause) => write!(f, "{}", cause),
497 }
498 }
499}
500impl Error for GetRecordsError {}
501/// Errors returned by GetShardIterator
502#[derive(Debug, PartialEq)]
503pub enum GetShardIteratorError {
504 /// <p>An error occurred on the server side.</p>
505 InternalServerError(String),
506 /// <p>The operation tried to access a nonexistent stream.</p>
507 ResourceNotFound(String),
508 /// <p><p>The operation attempted to read past the oldest stream record in a shard.</p> <p>In DynamoDB Streams, there is a 24 hour limit on data retention. Stream records whose age exceeds this limit are subject to removal (trimming) from the stream. You might receive a TrimmedDataAccessException if:</p> <ul> <li><p>You request a shard iterator with a sequence number older than the trim point (24 hours).</p> </li> <li><p>You obtain a shard iterator, but before you use the iterator in a <code>GetRecords</code> request, a stream record in the shard exceeds the 24 hour period and is trimmed. This causes the iterator to access a record that no longer exists.</p> </li> </ul></p>
509 TrimmedDataAccess(String),
510}
511
512impl GetShardIteratorError {
513 pub fn from_response(res: BufferedHttpResponse) -> RusotoError<GetShardIteratorError> {
514 if let Some(err) = proto::json::Error::parse(&res) {
515 match err.typ.as_str() {
516 "InternalServerError" => {
517 return RusotoError::Service(GetShardIteratorError::InternalServerError(
518 err.msg,
519 ))
520 }
521 "ResourceNotFoundException" => {
522 return RusotoError::Service(GetShardIteratorError::ResourceNotFound(err.msg))
523 }
524 "TrimmedDataAccessException" => {
525 return RusotoError::Service(GetShardIteratorError::TrimmedDataAccess(err.msg))
526 }
527 "ValidationException" => return RusotoError::Validation(err.msg),
528 _ => {}
529 }
530 }
531 RusotoError::Unknown(res)
532 }
533}
534impl fmt::Display for GetShardIteratorError {
535 #[allow(unused_variables)]
536 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
537 match *self {
538 GetShardIteratorError::InternalServerError(ref cause) => write!(f, "{}", cause),
539 GetShardIteratorError::ResourceNotFound(ref cause) => write!(f, "{}", cause),
540 GetShardIteratorError::TrimmedDataAccess(ref cause) => write!(f, "{}", cause),
541 }
542 }
543}
544impl Error for GetShardIteratorError {}
545/// Errors returned by ListStreams
546#[derive(Debug, PartialEq)]
547pub enum ListStreamsError {
548 /// <p>An error occurred on the server side.</p>
549 InternalServerError(String),
550 /// <p>The operation tried to access a nonexistent stream.</p>
551 ResourceNotFound(String),
552}
553
554impl ListStreamsError {
555 pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListStreamsError> {
556 if let Some(err) = proto::json::Error::parse(&res) {
557 match err.typ.as_str() {
558 "InternalServerError" => {
559 return RusotoError::Service(ListStreamsError::InternalServerError(err.msg))
560 }
561 "ResourceNotFoundException" => {
562 return RusotoError::Service(ListStreamsError::ResourceNotFound(err.msg))
563 }
564 "ValidationException" => return RusotoError::Validation(err.msg),
565 _ => {}
566 }
567 }
568 RusotoError::Unknown(res)
569 }
570}
571impl fmt::Display for ListStreamsError {
572 #[allow(unused_variables)]
573 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
574 match *self {
575 ListStreamsError::InternalServerError(ref cause) => write!(f, "{}", cause),
576 ListStreamsError::ResourceNotFound(ref cause) => write!(f, "{}", cause),
577 }
578 }
579}
580impl Error for ListStreamsError {}
581/// Trait representing the capabilities of the Amazon DynamoDB Streams API. Amazon DynamoDB Streams clients implement this trait.
582#[async_trait]
583pub trait DynamoDbStreams {
584 /// <p>Returns information about a stream, including the current status of the stream, its Amazon Resource Name (ARN), the composition of its shards, and its corresponding DynamoDB table.</p> <note> <p>You can call <code>DescribeStream</code> at a maximum rate of 10 times per second.</p> </note> <p>Each shard in the stream has a <code>SequenceNumberRange</code> associated with it. If the <code>SequenceNumberRange</code> has a <code>StartingSequenceNumber</code> but no <code>EndingSequenceNumber</code>, then the shard is still open (able to receive more stream records). If both <code>StartingSequenceNumber</code> and <code>EndingSequenceNumber</code> are present, then that shard is closed and can no longer receive more data.</p>
585 async fn describe_stream(
586 &self,
587 input: DescribeStreamInput,
588 ) -> Result<DescribeStreamOutput, RusotoError<DescribeStreamError>>;
589
590 /// <p><p>Retrieves the stream records from a given shard.</p> <p>Specify a shard iterator using the <code>ShardIterator</code> parameter. The shard iterator specifies the position in the shard from which you want to start reading stream records sequentially. If there are no stream records available in the portion of the shard that the iterator points to, <code>GetRecords</code> returns an empty list. Note that it might take multiple calls to get to a portion of the shard that contains stream records.</p> <note> <p> <code>GetRecords</code> can retrieve a maximum of 1 MB of data or 1000 stream records, whichever comes first.</p> </note></p>
591 async fn get_records(
592 &self,
593 input: GetRecordsInput,
594 ) -> Result<GetRecordsOutput, RusotoError<GetRecordsError>>;
595
596 /// <p><p>Returns a shard iterator. A shard iterator provides information about how to retrieve the stream records from within a shard. Use the shard iterator in a subsequent <code>GetRecords</code> request to read the stream records from the shard.</p> <note> <p>A shard iterator expires 15 minutes after it is returned to the requester.</p> </note></p>
597 async fn get_shard_iterator(
598 &self,
599 input: GetShardIteratorInput,
600 ) -> Result<GetShardIteratorOutput, RusotoError<GetShardIteratorError>>;
601
602 /// <p><p>Returns an array of stream ARNs associated with the current account and endpoint. If the <code>TableName</code> parameter is present, then <code>ListStreams</code> will return only the streams ARNs for that table.</p> <note> <p>You can call <code>ListStreams</code> at a maximum rate of 5 times per second.</p> </note></p>
603 async fn list_streams(
604 &self,
605 input: ListStreamsInput,
606 ) -> Result<ListStreamsOutput, RusotoError<ListStreamsError>>;
607}
608/// A client for the Amazon DynamoDB Streams API.
609#[derive(Clone)]
610pub struct DynamoDbStreamsClient {
611 client: Client,
612 region: region::Region,
613}
614
615impl DynamoDbStreamsClient {
616 /// Creates a client backed by the default tokio event loop.
617 ///
618 /// The client will use the default credentials provider and tls client.
619 pub fn new(region: region::Region) -> DynamoDbStreamsClient {
620 DynamoDbStreamsClient {
621 client: Client::shared(),
622 region,
623 }
624 }
625
626 pub fn new_with<P, D>(
627 request_dispatcher: D,
628 credentials_provider: P,
629 region: region::Region,
630 ) -> DynamoDbStreamsClient
631 where
632 P: ProvideAwsCredentials + Send + Sync + 'static,
633 D: DispatchSignedRequest + Send + Sync + 'static,
634 {
635 DynamoDbStreamsClient {
636 client: Client::new_with(credentials_provider, request_dispatcher),
637 region,
638 }
639 }
640
641 pub fn new_with_client(client: Client, region: region::Region) -> DynamoDbStreamsClient {
642 DynamoDbStreamsClient { client, region }
643 }
644}
645
646#[async_trait]
647impl DynamoDbStreams for DynamoDbStreamsClient {
648 /// <p>Returns information about a stream, including the current status of the stream, its Amazon Resource Name (ARN), the composition of its shards, and its corresponding DynamoDB table.</p> <note> <p>You can call <code>DescribeStream</code> at a maximum rate of 10 times per second.</p> </note> <p>Each shard in the stream has a <code>SequenceNumberRange</code> associated with it. If the <code>SequenceNumberRange</code> has a <code>StartingSequenceNumber</code> but no <code>EndingSequenceNumber</code>, then the shard is still open (able to receive more stream records). If both <code>StartingSequenceNumber</code> and <code>EndingSequenceNumber</code> are present, then that shard is closed and can no longer receive more data.</p>
649 async fn describe_stream(
650 &self,
651 input: DescribeStreamInput,
652 ) -> Result<DescribeStreamOutput, RusotoError<DescribeStreamError>> {
653 let mut request = self.new_signed_request("POST", "/");
654 request.add_header("x-amz-target", "DynamoDBStreams_20120810.DescribeStream");
655 let encoded = serde_json::to_string(&input).unwrap();
656 request.set_payload(Some(encoded));
657
658 let response = self
659 .sign_and_dispatch(request, DescribeStreamError::from_response)
660 .await?;
661 let mut response = response;
662 let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
663 proto::json::ResponsePayload::new(&response).deserialize::<DescribeStreamOutput, _>()
664 }
665
666 /// <p><p>Retrieves the stream records from a given shard.</p> <p>Specify a shard iterator using the <code>ShardIterator</code> parameter. The shard iterator specifies the position in the shard from which you want to start reading stream records sequentially. If there are no stream records available in the portion of the shard that the iterator points to, <code>GetRecords</code> returns an empty list. Note that it might take multiple calls to get to a portion of the shard that contains stream records.</p> <note> <p> <code>GetRecords</code> can retrieve a maximum of 1 MB of data or 1000 stream records, whichever comes first.</p> </note></p>
667 async fn get_records(
668 &self,
669 input: GetRecordsInput,
670 ) -> Result<GetRecordsOutput, RusotoError<GetRecordsError>> {
671 let mut request = self.new_signed_request("POST", "/");
672 request.add_header("x-amz-target", "DynamoDBStreams_20120810.GetRecords");
673 let encoded = serde_json::to_string(&input).unwrap();
674 request.set_payload(Some(encoded));
675
676 let response = self
677 .sign_and_dispatch(request, GetRecordsError::from_response)
678 .await?;
679 let mut response = response;
680 let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
681 proto::json::ResponsePayload::new(&response).deserialize::<GetRecordsOutput, _>()
682 }
683
684 /// <p><p>Returns a shard iterator. A shard iterator provides information about how to retrieve the stream records from within a shard. Use the shard iterator in a subsequent <code>GetRecords</code> request to read the stream records from the shard.</p> <note> <p>A shard iterator expires 15 minutes after it is returned to the requester.</p> </note></p>
685 async fn get_shard_iterator(
686 &self,
687 input: GetShardIteratorInput,
688 ) -> Result<GetShardIteratorOutput, RusotoError<GetShardIteratorError>> {
689 let mut request = self.new_signed_request("POST", "/");
690 request.add_header("x-amz-target", "DynamoDBStreams_20120810.GetShardIterator");
691 let encoded = serde_json::to_string(&input).unwrap();
692 request.set_payload(Some(encoded));
693
694 let response = self
695 .sign_and_dispatch(request, GetShardIteratorError::from_response)
696 .await?;
697 let mut response = response;
698 let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
699 proto::json::ResponsePayload::new(&response).deserialize::<GetShardIteratorOutput, _>()
700 }
701
702 /// <p><p>Returns an array of stream ARNs associated with the current account and endpoint. If the <code>TableName</code> parameter is present, then <code>ListStreams</code> will return only the streams ARNs for that table.</p> <note> <p>You can call <code>ListStreams</code> at a maximum rate of 5 times per second.</p> </note></p>
703 async fn list_streams(
704 &self,
705 input: ListStreamsInput,
706 ) -> Result<ListStreamsOutput, RusotoError<ListStreamsError>> {
707 let mut request = self.new_signed_request("POST", "/");
708 request.add_header("x-amz-target", "DynamoDBStreams_20120810.ListStreams");
709 let encoded = serde_json::to_string(&input).unwrap();
710 request.set_payload(Some(encoded));
711
712 let response = self
713 .sign_and_dispatch(request, ListStreamsError::from_response)
714 .await?;
715 let mut response = response;
716 let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
717 proto::json::ResponsePayload::new(&response).deserialize::<ListStreamsOutput, _>()
718 }
719}