aws_sdk_dynamodb/operation/query/_query_output.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Represents the output of a <code>Query</code> operation.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct QueryOutput {
7 /// <p>An array of item attributes that match the query criteria. Each element in this array consists of an attribute name and the value for that attribute.</p>
8 pub items: ::std::option::Option<::std::vec::Vec<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>>>,
9 /// <p>The number of items in the response.</p>
10 /// <p>If you used a <code>QueryFilter</code> in the request, then <code>Count</code> is the number of items returned after the filter was applied, and <code>ScannedCount</code> is the number of matching items before the filter was applied.</p>
11 /// <p>If you did not use a filter in the request, then <code>Count</code> and <code>ScannedCount</code> are the same.</p>
12 pub count: i32,
13 /// <p>The number of items evaluated, before any <code>QueryFilter</code> is applied. A high <code>ScannedCount</code> value with few, or no, <code>Count</code> results indicates an inefficient <code>Query</code> operation. For more information, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Scan.html#Scan.Count">Count and ScannedCount</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
14 /// <p>If you did not use a filter in the request, then <code>ScannedCount</code> is the same as <code>Count</code>.</p>
15 pub scanned_count: i32,
16 /// <p>The primary key 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>
17 /// <p>If <code>LastEvaluatedKey</code> is empty, then the "last page" of results has been processed and there is no more data to be retrieved.</p>
18 /// <p>If <code>LastEvaluatedKey</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>LastEvaluatedKey</code> is empty.</p>
19 pub last_evaluated_key: ::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>>,
20 /// <p>The capacity units consumed by the <code>Query</code> operation. The data returned includes the total provisioned throughput consumed, along with statistics for the table and any indexes involved in the operation. <code>ConsumedCapacity</code> is only returned if the <code>ReturnConsumedCapacity</code> parameter was specified. For more information, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/read-write-operations.html#read-operation-consumption">Capacity unit consumption for read operations</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
21 pub consumed_capacity: ::std::option::Option<crate::types::ConsumedCapacity>,
22 _request_id: Option<String>,
23}
24impl QueryOutput {
25 /// <p>An array of item attributes that match the query criteria. Each element in this array consists of an attribute name and the value for that attribute.</p>
26 ///
27 /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.items.is_none()`.
28 pub fn items(&self) -> &[::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>] {
29 self.items.as_deref().unwrap_or_default()
30 }
31 /// <p>The number of items in the response.</p>
32 /// <p>If you used a <code>QueryFilter</code> in the request, then <code>Count</code> is the number of items returned after the filter was applied, and <code>ScannedCount</code> is the number of matching items before the filter was applied.</p>
33 /// <p>If you did not use a filter in the request, then <code>Count</code> and <code>ScannedCount</code> are the same.</p>
34 pub fn count(&self) -> i32 {
35 self.count
36 }
37 /// <p>The number of items evaluated, before any <code>QueryFilter</code> is applied. A high <code>ScannedCount</code> value with few, or no, <code>Count</code> results indicates an inefficient <code>Query</code> operation. For more information, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Scan.html#Scan.Count">Count and ScannedCount</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
38 /// <p>If you did not use a filter in the request, then <code>ScannedCount</code> is the same as <code>Count</code>.</p>
39 pub fn scanned_count(&self) -> i32 {
40 self.scanned_count
41 }
42 /// <p>The primary key 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>
43 /// <p>If <code>LastEvaluatedKey</code> is empty, then the "last page" of results has been processed and there is no more data to be retrieved.</p>
44 /// <p>If <code>LastEvaluatedKey</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>LastEvaluatedKey</code> is empty.</p>
45 pub fn last_evaluated_key(&self) -> ::std::option::Option<&::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>> {
46 self.last_evaluated_key.as_ref()
47 }
48 /// <p>The capacity units consumed by the <code>Query</code> operation. The data returned includes the total provisioned throughput consumed, along with statistics for the table and any indexes involved in the operation. <code>ConsumedCapacity</code> is only returned if the <code>ReturnConsumedCapacity</code> parameter was specified. For more information, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/read-write-operations.html#read-operation-consumption">Capacity unit consumption for read operations</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
49 pub fn consumed_capacity(&self) -> ::std::option::Option<&crate::types::ConsumedCapacity> {
50 self.consumed_capacity.as_ref()
51 }
52}
53impl ::aws_types::request_id::RequestId for QueryOutput {
54 fn request_id(&self) -> Option<&str> {
55 self._request_id.as_deref()
56 }
57}
58impl QueryOutput {
59 /// Creates a new builder-style object to manufacture [`QueryOutput`](crate::operation::query::QueryOutput).
60 pub fn builder() -> crate::operation::query::builders::QueryOutputBuilder {
61 crate::operation::query::builders::QueryOutputBuilder::default()
62 }
63}
64
65/// A builder for [`QueryOutput`](crate::operation::query::QueryOutput).
66#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
67#[non_exhaustive]
68pub struct QueryOutputBuilder {
69 pub(crate) items: ::std::option::Option<::std::vec::Vec<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>>>,
70 pub(crate) count: ::std::option::Option<i32>,
71 pub(crate) scanned_count: ::std::option::Option<i32>,
72 pub(crate) last_evaluated_key: ::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>>,
73 pub(crate) consumed_capacity: ::std::option::Option<crate::types::ConsumedCapacity>,
74 _request_id: Option<String>,
75}
76impl QueryOutputBuilder {
77 /// Appends an item to `items`.
78 ///
79 /// To override the contents of this collection use [`set_items`](Self::set_items).
80 ///
81 /// <p>An array of item attributes that match the query criteria. Each element in this array consists of an attribute name and the value for that attribute.</p>
82 pub fn items(mut self, input: ::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>) -> Self {
83 let mut v = self.items.unwrap_or_default();
84 v.push(input);
85 self.items = ::std::option::Option::Some(v);
86 self
87 }
88 /// <p>An array of item attributes that match the query criteria. Each element in this array consists of an attribute name and the value for that attribute.</p>
89 pub fn set_items(
90 mut self,
91 input: ::std::option::Option<::std::vec::Vec<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>>>,
92 ) -> Self {
93 self.items = input;
94 self
95 }
96 /// <p>An array of item attributes that match the query criteria. Each element in this array consists of an attribute name and the value for that attribute.</p>
97 pub fn get_items(
98 &self,
99 ) -> &::std::option::Option<::std::vec::Vec<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>>> {
100 &self.items
101 }
102 /// <p>The number of items in the response.</p>
103 /// <p>If you used a <code>QueryFilter</code> in the request, then <code>Count</code> is the number of items returned after the filter was applied, and <code>ScannedCount</code> is the number of matching items before the filter was applied.</p>
104 /// <p>If you did not use a filter in the request, then <code>Count</code> and <code>ScannedCount</code> are the same.</p>
105 pub fn count(mut self, input: i32) -> Self {
106 self.count = ::std::option::Option::Some(input);
107 self
108 }
109 /// <p>The number of items in the response.</p>
110 /// <p>If you used a <code>QueryFilter</code> in the request, then <code>Count</code> is the number of items returned after the filter was applied, and <code>ScannedCount</code> is the number of matching items before the filter was applied.</p>
111 /// <p>If you did not use a filter in the request, then <code>Count</code> and <code>ScannedCount</code> are the same.</p>
112 pub fn set_count(mut self, input: ::std::option::Option<i32>) -> Self {
113 self.count = input;
114 self
115 }
116 /// <p>The number of items in the response.</p>
117 /// <p>If you used a <code>QueryFilter</code> in the request, then <code>Count</code> is the number of items returned after the filter was applied, and <code>ScannedCount</code> is the number of matching items before the filter was applied.</p>
118 /// <p>If you did not use a filter in the request, then <code>Count</code> and <code>ScannedCount</code> are the same.</p>
119 pub fn get_count(&self) -> &::std::option::Option<i32> {
120 &self.count
121 }
122 /// <p>The number of items evaluated, before any <code>QueryFilter</code> is applied. A high <code>ScannedCount</code> value with few, or no, <code>Count</code> results indicates an inefficient <code>Query</code> operation. For more information, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Scan.html#Scan.Count">Count and ScannedCount</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
123 /// <p>If you did not use a filter in the request, then <code>ScannedCount</code> is the same as <code>Count</code>.</p>
124 pub fn scanned_count(mut self, input: i32) -> Self {
125 self.scanned_count = ::std::option::Option::Some(input);
126 self
127 }
128 /// <p>The number of items evaluated, before any <code>QueryFilter</code> is applied. A high <code>ScannedCount</code> value with few, or no, <code>Count</code> results indicates an inefficient <code>Query</code> operation. For more information, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Scan.html#Scan.Count">Count and ScannedCount</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
129 /// <p>If you did not use a filter in the request, then <code>ScannedCount</code> is the same as <code>Count</code>.</p>
130 pub fn set_scanned_count(mut self, input: ::std::option::Option<i32>) -> Self {
131 self.scanned_count = input;
132 self
133 }
134 /// <p>The number of items evaluated, before any <code>QueryFilter</code> is applied. A high <code>ScannedCount</code> value with few, or no, <code>Count</code> results indicates an inefficient <code>Query</code> operation. For more information, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Scan.html#Scan.Count">Count and ScannedCount</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
135 /// <p>If you did not use a filter in the request, then <code>ScannedCount</code> is the same as <code>Count</code>.</p>
136 pub fn get_scanned_count(&self) -> &::std::option::Option<i32> {
137 &self.scanned_count
138 }
139 /// Adds a key-value pair to `last_evaluated_key`.
140 ///
141 /// To override the contents of this collection use [`set_last_evaluated_key`](Self::set_last_evaluated_key).
142 ///
143 /// <p>The primary key 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>
144 /// <p>If <code>LastEvaluatedKey</code> is empty, then the "last page" of results has been processed and there is no more data to be retrieved.</p>
145 /// <p>If <code>LastEvaluatedKey</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>LastEvaluatedKey</code> is empty.</p>
146 pub fn last_evaluated_key(mut self, k: impl ::std::convert::Into<::std::string::String>, v: crate::types::AttributeValue) -> Self {
147 let mut hash_map = self.last_evaluated_key.unwrap_or_default();
148 hash_map.insert(k.into(), v);
149 self.last_evaluated_key = ::std::option::Option::Some(hash_map);
150 self
151 }
152 /// <p>The primary key 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>
153 /// <p>If <code>LastEvaluatedKey</code> is empty, then the "last page" of results has been processed and there is no more data to be retrieved.</p>
154 /// <p>If <code>LastEvaluatedKey</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>LastEvaluatedKey</code> is empty.</p>
155 pub fn set_last_evaluated_key(
156 mut self,
157 input: ::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>>,
158 ) -> Self {
159 self.last_evaluated_key = input;
160 self
161 }
162 /// <p>The primary key 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>
163 /// <p>If <code>LastEvaluatedKey</code> is empty, then the "last page" of results has been processed and there is no more data to be retrieved.</p>
164 /// <p>If <code>LastEvaluatedKey</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>LastEvaluatedKey</code> is empty.</p>
165 pub fn get_last_evaluated_key(&self) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>> {
166 &self.last_evaluated_key
167 }
168 /// <p>The capacity units consumed by the <code>Query</code> operation. The data returned includes the total provisioned throughput consumed, along with statistics for the table and any indexes involved in the operation. <code>ConsumedCapacity</code> is only returned if the <code>ReturnConsumedCapacity</code> parameter was specified. For more information, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/read-write-operations.html#read-operation-consumption">Capacity unit consumption for read operations</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
169 pub fn consumed_capacity(mut self, input: crate::types::ConsumedCapacity) -> Self {
170 self.consumed_capacity = ::std::option::Option::Some(input);
171 self
172 }
173 /// <p>The capacity units consumed by the <code>Query</code> operation. The data returned includes the total provisioned throughput consumed, along with statistics for the table and any indexes involved in the operation. <code>ConsumedCapacity</code> is only returned if the <code>ReturnConsumedCapacity</code> parameter was specified. For more information, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/read-write-operations.html#read-operation-consumption">Capacity unit consumption for read operations</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
174 pub fn set_consumed_capacity(mut self, input: ::std::option::Option<crate::types::ConsumedCapacity>) -> Self {
175 self.consumed_capacity = input;
176 self
177 }
178 /// <p>The capacity units consumed by the <code>Query</code> operation. The data returned includes the total provisioned throughput consumed, along with statistics for the table and any indexes involved in the operation. <code>ConsumedCapacity</code> is only returned if the <code>ReturnConsumedCapacity</code> parameter was specified. For more information, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/read-write-operations.html#read-operation-consumption">Capacity unit consumption for read operations</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
179 pub fn get_consumed_capacity(&self) -> &::std::option::Option<crate::types::ConsumedCapacity> {
180 &self.consumed_capacity
181 }
182 pub(crate) fn _request_id(mut self, request_id: impl Into<String>) -> Self {
183 self._request_id = Some(request_id.into());
184 self
185 }
186
187 pub(crate) fn _set_request_id(&mut self, request_id: Option<String>) -> &mut Self {
188 self._request_id = request_id;
189 self
190 }
191 /// Consumes the builder and constructs a [`QueryOutput`](crate::operation::query::QueryOutput).
192 pub fn build(self) -> crate::operation::query::QueryOutput {
193 crate::operation::query::QueryOutput {
194 items: self.items,
195 count: self.count.unwrap_or_default(),
196 scanned_count: self.scanned_count.unwrap_or_default(),
197 last_evaluated_key: self.last_evaluated_key,
198 consumed_capacity: self.consumed_capacity,
199 _request_id: self._request_id,
200 }
201 }
202}