aws_sdk_cloudwatchlogs/operation/start_query/builders.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::start_query::_start_query_output::StartQueryOutputBuilder;
3
4pub use crate::operation::start_query::_start_query_input::StartQueryInputBuilder;
5
6impl crate::operation::start_query::builders::StartQueryInputBuilder {
7 /// Sends a request with this input using the given client.
8 pub async fn send_with(
9 self,
10 client: &crate::Client,
11 ) -> ::std::result::Result<
12 crate::operation::start_query::StartQueryOutput,
13 ::aws_smithy_runtime_api::client::result::SdkError<
14 crate::operation::start_query::StartQueryError,
15 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16 >,
17 > {
18 let mut fluent_builder = client.start_query();
19 fluent_builder.inner = self;
20 fluent_builder.send().await
21 }
22}
23/// Fluent builder constructing a request to `StartQuery`.
24///
25/// <p>Starts a query of one or more log groups using CloudWatch Logs Insights. You specify the log groups and time range to query and the query string to use.</p>
26/// <p>For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax.html">CloudWatch Logs Insights Query Syntax</a>.</p>
27/// <p>After you run a query using <code>StartQuery</code>, the query results are stored by CloudWatch Logs. You can use <a href="https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_GetQueryResults.html">GetQueryResults</a> to retrieve the results of a query, using the <code>queryId</code> that <code>StartQuery</code> returns.</p><note>
28/// <p>To specify the log groups to query, a <code>StartQuery</code> operation must include one of the following:</p>
29/// <ul>
30/// <li>
31/// <p>Either exactly one of the following parameters: <code>logGroupName</code>, <code>logGroupNames</code>, or <code>logGroupIdentifiers</code></p></li>
32/// <li>
33/// <p>Or the <code>queryString</code> must include a <code>SOURCE</code> command to select log groups for the query. The <code>SOURCE</code> command can select log groups based on log group name prefix, account ID, and log class.</p>
34/// <p>For more information about the <code>SOURCE</code> command, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax-Source.html">SOURCE</a>.</p></li>
35/// </ul>
36/// </note>
37/// <p>If you have associated a KMS key with the query results in this account, then <a href="https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_StartQuery.html">StartQuery</a> uses that key to encrypt the results when it stores them. If no key is associated with query results, the query results are encrypted with the default CloudWatch Logs encryption method.</p>
38/// <p>Queries time out after 60 minutes of runtime. If your queries are timing out, reduce the time range being searched or partition your query into a number of queries.</p>
39/// <p>If you are using CloudWatch cross-account observability, you can use this operation in a monitoring account to start a query in a linked source account. For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Unified-Cross-Account.html">CloudWatch cross-account observability</a>. For a cross-account <code>StartQuery</code> operation, the query definition must be defined in the monitoring account.</p>
40/// <p>You can have up to 30 concurrent CloudWatch Logs insights queries, including queries that have been added to dashboards.</p>
41#[derive(::std::clone::Clone, ::std::fmt::Debug)]
42pub struct StartQueryFluentBuilder {
43 handle: ::std::sync::Arc<crate::client::Handle>,
44 inner: crate::operation::start_query::builders::StartQueryInputBuilder,
45 config_override: ::std::option::Option<crate::config::Builder>,
46}
47impl
48 crate::client::customize::internal::CustomizableSend<
49 crate::operation::start_query::StartQueryOutput,
50 crate::operation::start_query::StartQueryError,
51 > for StartQueryFluentBuilder
52{
53 fn send(
54 self,
55 config_override: crate::config::Builder,
56 ) -> crate::client::customize::internal::BoxFuture<
57 crate::client::customize::internal::SendResult<
58 crate::operation::start_query::StartQueryOutput,
59 crate::operation::start_query::StartQueryError,
60 >,
61 > {
62 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
63 }
64}
65impl StartQueryFluentBuilder {
66 /// Creates a new `StartQueryFluentBuilder`.
67 pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
68 Self {
69 handle,
70 inner: ::std::default::Default::default(),
71 config_override: ::std::option::Option::None,
72 }
73 }
74 /// Access the StartQuery as a reference.
75 pub fn as_input(&self) -> &crate::operation::start_query::builders::StartQueryInputBuilder {
76 &self.inner
77 }
78 /// Sends the request and returns the response.
79 ///
80 /// If an error occurs, an `SdkError` will be returned with additional details that
81 /// can be matched against.
82 ///
83 /// By default, any retryable failures will be retried twice. Retry behavior
84 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
85 /// set when configuring the client.
86 pub async fn send(
87 self,
88 ) -> ::std::result::Result<
89 crate::operation::start_query::StartQueryOutput,
90 ::aws_smithy_runtime_api::client::result::SdkError<
91 crate::operation::start_query::StartQueryError,
92 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
93 >,
94 > {
95 let input = self
96 .inner
97 .build()
98 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
99 let runtime_plugins = crate::operation::start_query::StartQuery::operation_runtime_plugins(
100 self.handle.runtime_plugins.clone(),
101 &self.handle.conf,
102 self.config_override,
103 );
104 crate::operation::start_query::StartQuery::orchestrate(&runtime_plugins, input).await
105 }
106
107 /// Consumes this builder, creating a customizable operation that can be modified before being sent.
108 pub fn customize(
109 self,
110 ) -> crate::client::customize::CustomizableOperation<
111 crate::operation::start_query::StartQueryOutput,
112 crate::operation::start_query::StartQueryError,
113 Self,
114 > {
115 crate::client::customize::CustomizableOperation::new(self)
116 }
117 pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
118 self.set_config_override(::std::option::Option::Some(config_override.into()));
119 self
120 }
121
122 pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
123 self.config_override = config_override;
124 self
125 }
126 /// <p>Specify the query language to use for this query. The options are Logs Insights QL, OpenSearch PPL, and OpenSearch SQL. For more information about the query languages that CloudWatch Logs supports, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_AnalyzeLogData_Languages.html">Supported query languages</a>.</p>
127 pub fn query_language(mut self, input: crate::types::QueryLanguage) -> Self {
128 self.inner = self.inner.query_language(input);
129 self
130 }
131 /// <p>Specify the query language to use for this query. The options are Logs Insights QL, OpenSearch PPL, and OpenSearch SQL. For more information about the query languages that CloudWatch Logs supports, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_AnalyzeLogData_Languages.html">Supported query languages</a>.</p>
132 pub fn set_query_language(mut self, input: ::std::option::Option<crate::types::QueryLanguage>) -> Self {
133 self.inner = self.inner.set_query_language(input);
134 self
135 }
136 /// <p>Specify the query language to use for this query. The options are Logs Insights QL, OpenSearch PPL, and OpenSearch SQL. For more information about the query languages that CloudWatch Logs supports, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_AnalyzeLogData_Languages.html">Supported query languages</a>.</p>
137 pub fn get_query_language(&self) -> &::std::option::Option<crate::types::QueryLanguage> {
138 self.inner.get_query_language()
139 }
140 /// <p>The log group on which to perform the query.</p><note>
141 /// <p>A <code>StartQuery</code> operation must include exactly one of the following parameters: <code>logGroupName</code>, <code>logGroupNames</code>, or <code>logGroupIdentifiers</code>. The exception is queries using the OpenSearch Service SQL query language, where you specify the log group names inside the <code>querystring</code> instead of here.</p>
142 /// </note>
143 pub fn log_group_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
144 self.inner = self.inner.log_group_name(input.into());
145 self
146 }
147 /// <p>The log group on which to perform the query.</p><note>
148 /// <p>A <code>StartQuery</code> operation must include exactly one of the following parameters: <code>logGroupName</code>, <code>logGroupNames</code>, or <code>logGroupIdentifiers</code>. The exception is queries using the OpenSearch Service SQL query language, where you specify the log group names inside the <code>querystring</code> instead of here.</p>
149 /// </note>
150 pub fn set_log_group_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
151 self.inner = self.inner.set_log_group_name(input);
152 self
153 }
154 /// <p>The log group on which to perform the query.</p><note>
155 /// <p>A <code>StartQuery</code> operation must include exactly one of the following parameters: <code>logGroupName</code>, <code>logGroupNames</code>, or <code>logGroupIdentifiers</code>. The exception is queries using the OpenSearch Service SQL query language, where you specify the log group names inside the <code>querystring</code> instead of here.</p>
156 /// </note>
157 pub fn get_log_group_name(&self) -> &::std::option::Option<::std::string::String> {
158 self.inner.get_log_group_name()
159 }
160 ///
161 /// Appends an item to `logGroupNames`.
162 ///
163 /// To override the contents of this collection use [`set_log_group_names`](Self::set_log_group_names).
164 ///
165 /// <p>The list of log groups to be queried. You can include up to 50 log groups.</p><note>
166 /// <p>A <code>StartQuery</code> operation must include exactly one of the following parameters: <code>logGroupName</code>, <code>logGroupNames</code>, or <code>logGroupIdentifiers</code>. The exception is queries using the OpenSearch Service SQL query language, where you specify the log group names inside the <code>querystring</code> instead of here.</p>
167 /// </note>
168 pub fn log_group_names(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
169 self.inner = self.inner.log_group_names(input.into());
170 self
171 }
172 /// <p>The list of log groups to be queried. You can include up to 50 log groups.</p><note>
173 /// <p>A <code>StartQuery</code> operation must include exactly one of the following parameters: <code>logGroupName</code>, <code>logGroupNames</code>, or <code>logGroupIdentifiers</code>. The exception is queries using the OpenSearch Service SQL query language, where you specify the log group names inside the <code>querystring</code> instead of here.</p>
174 /// </note>
175 pub fn set_log_group_names(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
176 self.inner = self.inner.set_log_group_names(input);
177 self
178 }
179 /// <p>The list of log groups to be queried. You can include up to 50 log groups.</p><note>
180 /// <p>A <code>StartQuery</code> operation must include exactly one of the following parameters: <code>logGroupName</code>, <code>logGroupNames</code>, or <code>logGroupIdentifiers</code>. The exception is queries using the OpenSearch Service SQL query language, where you specify the log group names inside the <code>querystring</code> instead of here.</p>
181 /// </note>
182 pub fn get_log_group_names(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
183 self.inner.get_log_group_names()
184 }
185 ///
186 /// Appends an item to `logGroupIdentifiers`.
187 ///
188 /// To override the contents of this collection use [`set_log_group_identifiers`](Self::set_log_group_identifiers).
189 ///
190 /// <p>The list of log groups to query. You can include up to 50 log groups.</p>
191 /// <p>You can specify them by the log group name or ARN. If a log group that you're querying is in a source account and you're using a monitoring account, you must specify the ARN of the log group here. The query definition must also be defined in the monitoring account.</p>
192 /// <p>If you specify an ARN, use the format arn:aws:logs:<i>region</i>:<i>account-id</i>:log-group:<i>log_group_name</i> Don't include an * at the end.</p>
193 /// <p>A <code>StartQuery</code> operation must include exactly one of the following parameters: <code>logGroupName</code>, <code>logGroupNames</code>, or <code>logGroupIdentifiers</code>. The exception is queries using the OpenSearch Service SQL query language, where you specify the log group names inside the <code>querystring</code> instead of here.</p>
194 pub fn log_group_identifiers(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
195 self.inner = self.inner.log_group_identifiers(input.into());
196 self
197 }
198 /// <p>The list of log groups to query. You can include up to 50 log groups.</p>
199 /// <p>You can specify them by the log group name or ARN. If a log group that you're querying is in a source account and you're using a monitoring account, you must specify the ARN of the log group here. The query definition must also be defined in the monitoring account.</p>
200 /// <p>If you specify an ARN, use the format arn:aws:logs:<i>region</i>:<i>account-id</i>:log-group:<i>log_group_name</i> Don't include an * at the end.</p>
201 /// <p>A <code>StartQuery</code> operation must include exactly one of the following parameters: <code>logGroupName</code>, <code>logGroupNames</code>, or <code>logGroupIdentifiers</code>. The exception is queries using the OpenSearch Service SQL query language, where you specify the log group names inside the <code>querystring</code> instead of here.</p>
202 pub fn set_log_group_identifiers(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
203 self.inner = self.inner.set_log_group_identifiers(input);
204 self
205 }
206 /// <p>The list of log groups to query. You can include up to 50 log groups.</p>
207 /// <p>You can specify them by the log group name or ARN. If a log group that you're querying is in a source account and you're using a monitoring account, you must specify the ARN of the log group here. The query definition must also be defined in the monitoring account.</p>
208 /// <p>If you specify an ARN, use the format arn:aws:logs:<i>region</i>:<i>account-id</i>:log-group:<i>log_group_name</i> Don't include an * at the end.</p>
209 /// <p>A <code>StartQuery</code> operation must include exactly one of the following parameters: <code>logGroupName</code>, <code>logGroupNames</code>, or <code>logGroupIdentifiers</code>. The exception is queries using the OpenSearch Service SQL query language, where you specify the log group names inside the <code>querystring</code> instead of here.</p>
210 pub fn get_log_group_identifiers(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
211 self.inner.get_log_group_identifiers()
212 }
213 /// <p>The beginning of the time range to query. The range is inclusive, so the specified start time is included in the query. Specified as epoch time, the number of seconds since <code>January 1, 1970, 00:00:00 UTC</code>.</p>
214 pub fn start_time(mut self, input: i64) -> Self {
215 self.inner = self.inner.start_time(input);
216 self
217 }
218 /// <p>The beginning of the time range to query. The range is inclusive, so the specified start time is included in the query. Specified as epoch time, the number of seconds since <code>January 1, 1970, 00:00:00 UTC</code>.</p>
219 pub fn set_start_time(mut self, input: ::std::option::Option<i64>) -> Self {
220 self.inner = self.inner.set_start_time(input);
221 self
222 }
223 /// <p>The beginning of the time range to query. The range is inclusive, so the specified start time is included in the query. Specified as epoch time, the number of seconds since <code>January 1, 1970, 00:00:00 UTC</code>.</p>
224 pub fn get_start_time(&self) -> &::std::option::Option<i64> {
225 self.inner.get_start_time()
226 }
227 /// <p>The end of the time range to query. The range is inclusive, so the specified end time is included in the query. Specified as epoch time, the number of seconds since <code>January 1, 1970, 00:00:00 UTC</code>.</p>
228 pub fn end_time(mut self, input: i64) -> Self {
229 self.inner = self.inner.end_time(input);
230 self
231 }
232 /// <p>The end of the time range to query. The range is inclusive, so the specified end time is included in the query. Specified as epoch time, the number of seconds since <code>January 1, 1970, 00:00:00 UTC</code>.</p>
233 pub fn set_end_time(mut self, input: ::std::option::Option<i64>) -> Self {
234 self.inner = self.inner.set_end_time(input);
235 self
236 }
237 /// <p>The end of the time range to query. The range is inclusive, so the specified end time is included in the query. Specified as epoch time, the number of seconds since <code>January 1, 1970, 00:00:00 UTC</code>.</p>
238 pub fn get_end_time(&self) -> &::std::option::Option<i64> {
239 self.inner.get_end_time()
240 }
241 /// <p>The query string to use. For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax.html">CloudWatch Logs Insights Query Syntax</a>.</p>
242 pub fn query_string(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
243 self.inner = self.inner.query_string(input.into());
244 self
245 }
246 /// <p>The query string to use. For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax.html">CloudWatch Logs Insights Query Syntax</a>.</p>
247 pub fn set_query_string(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
248 self.inner = self.inner.set_query_string(input);
249 self
250 }
251 /// <p>The query string to use. For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax.html">CloudWatch Logs Insights Query Syntax</a>.</p>
252 pub fn get_query_string(&self) -> &::std::option::Option<::std::string::String> {
253 self.inner.get_query_string()
254 }
255 /// <p>The maximum number of log events to return in the query. If the query string uses the <code>fields</code> command, only the specified fields and their values are returned. The default is 10,000.</p>
256 pub fn limit(mut self, input: i32) -> Self {
257 self.inner = self.inner.limit(input);
258 self
259 }
260 /// <p>The maximum number of log events to return in the query. If the query string uses the <code>fields</code> command, only the specified fields and their values are returned. The default is 10,000.</p>
261 pub fn set_limit(mut self, input: ::std::option::Option<i32>) -> Self {
262 self.inner = self.inner.set_limit(input);
263 self
264 }
265 /// <p>The maximum number of log events to return in the query. If the query string uses the <code>fields</code> command, only the specified fields and their values are returned. The default is 10,000.</p>
266 pub fn get_limit(&self) -> &::std::option::Option<i32> {
267 self.inner.get_limit()
268 }
269}