aws-sdk-cloudwatchlogs 1.82.0

AWS SDK for Amazon CloudWatch Logs
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub use crate::operation::start_live_tail::_start_live_tail_output::StartLiveTailOutputBuilder;

pub use crate::operation::start_live_tail::_start_live_tail_input::StartLiveTailInputBuilder;

impl crate::operation::start_live_tail::builders::StartLiveTailInputBuilder {
    /// Sends a request with this input using the given client.
    pub async fn send_with(
        self,
        client: &crate::Client,
    ) -> ::std::result::Result<
        crate::operation::start_live_tail::StartLiveTailOutput,
        ::aws_smithy_runtime_api::client::result::SdkError<
            crate::operation::start_live_tail::StartLiveTailError,
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
        >,
    > {
        let mut fluent_builder = client.start_live_tail();
        fluent_builder.inner = self;
        fluent_builder.send().await
    }
}
/// Fluent builder constructing a request to `StartLiveTail`.
///
/// <p>Starts a Live Tail streaming session for one or more log groups. A Live Tail session returns a stream of log events that have been recently ingested in the log groups. For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CloudWatchLogs_LiveTail.html">Use Live Tail to view logs in near real time</a>.</p>
/// <p>The response to this operation is a response stream, over which the server sends live log events and the client receives them.</p>
/// <p>The following objects are sent over the stream:</p>
/// <ul>
/// <li>
/// <p>A single <a href="https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_LiveTailSessionStart.html">LiveTailSessionStart</a> object is sent at the start of the session.</p></li>
/// <li>
/// <p>Every second, a <a href="https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_LiveTailSessionUpdate.html">LiveTailSessionUpdate</a> object is sent. Each of these objects contains an array of the actual log events.</p>
/// <p>If no new log events were ingested in the past second, the <code>LiveTailSessionUpdate</code> object will contain an empty array.</p>
/// <p>The array of log events contained in a <code>LiveTailSessionUpdate</code> can include as many as 500 log events. If the number of log events matching the request exceeds 500 per second, the log events are sampled down to 500 log events to be included in each <code>LiveTailSessionUpdate</code> object.</p>
/// <p>If your client consumes the log events slower than the server produces them, CloudWatch Logs buffers up to 10 <code>LiveTailSessionUpdate</code> events or 5000 log events, after which it starts dropping the oldest events.</p></li>
/// <li>
/// <p>A <a href="https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_StartLiveTailResponseStream.html#CWL-Type-StartLiveTailResponseStream-SessionStreamingException">SessionStreamingException</a> object is returned if an unknown error occurs on the server side.</p></li>
/// <li>
/// <p>A <a href="https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_StartLiveTailResponseStream.html#CWL-Type-StartLiveTailResponseStream-SessionTimeoutException">SessionTimeoutException</a> object is returned when the session times out, after it has been kept open for three hours.</p></li>
/// </ul><note>
/// <p>The <code>StartLiveTail</code> API routes requests to <code>streaming-logs.<i>Region</i>.amazonaws.com</code> using SDK host prefix injection. VPC endpoint support is not available for this API.</p>
/// </note> <important>
/// <p>You can end a session before it times out by closing the session stream or by closing the client that is receiving the stream. The session also ends if the established connection between the client and the server breaks.</p>
/// </important>
/// <p>For examples of using an SDK to start a Live Tail session, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/example_cloudwatch-logs_StartLiveTail_section.html"> Start a Live Tail session using an Amazon Web Services SDK</a>.</p>
///
/// [`StartLiveTailOutput`](crate::operation::start_live_tail::StartLiveTailOutput) contains an event stream field as well as one or more non-event stream fields.
/// Due to its current implementation, the non-event stream fields are not fully deserialized
/// until the [`send`](Self::send) method completes. As a result, accessing these fields of the operation
/// output struct within an interceptor may return uninitialized values.
///
#[derive(::std::clone::Clone, ::std::fmt::Debug)]
pub struct StartLiveTailFluentBuilder {
    handle: ::std::sync::Arc<crate::client::Handle>,
    inner: crate::operation::start_live_tail::builders::StartLiveTailInputBuilder,
    config_override: ::std::option::Option<crate::config::Builder>,
}
impl
    crate::client::customize::internal::CustomizableSend<
        crate::operation::start_live_tail::StartLiveTailOutput,
        crate::operation::start_live_tail::StartLiveTailError,
    > for StartLiveTailFluentBuilder
{
    fn send(
        self,
        config_override: crate::config::Builder,
    ) -> crate::client::customize::internal::BoxFuture<
        crate::client::customize::internal::SendResult<
            crate::operation::start_live_tail::StartLiveTailOutput,
            crate::operation::start_live_tail::StartLiveTailError,
        >,
    > {
        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
    }
}
impl StartLiveTailFluentBuilder {
    /// Creates a new `StartLiveTailFluentBuilder`.
    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
        Self {
            handle,
            inner: ::std::default::Default::default(),
            config_override: ::std::option::Option::None,
        }
    }
    /// Access the StartLiveTail as a reference.
    pub fn as_input(&self) -> &crate::operation::start_live_tail::builders::StartLiveTailInputBuilder {
        &self.inner
    }
    /// Sends the request and returns the response.
    ///
    /// If an error occurs, an `SdkError` will be returned with additional details that
    /// can be matched against.
    ///
    /// By default, any retryable failures will be retried twice. Retry behavior
    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
    /// set when configuring the client.
    pub async fn send(
        self,
    ) -> ::std::result::Result<
        crate::operation::start_live_tail::StartLiveTailOutput,
        ::aws_smithy_runtime_api::client::result::SdkError<
            crate::operation::start_live_tail::StartLiveTailError,
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
        >,
    > {
        let input = self
            .inner
            .build()
            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
        let runtime_plugins = crate::operation::start_live_tail::StartLiveTail::operation_runtime_plugins(
            self.handle.runtime_plugins.clone(),
            &self.handle.conf,
            self.config_override,
        );
        let mut output = crate::operation::start_live_tail::StartLiveTail::orchestrate(&runtime_plugins, input).await?;

        // Converts any error encountered beyond this point into an `SdkError` response error
        // with an `HttpResponse`. However, since we have already exited the `orchestrate`
        // function, the original `HttpResponse` is no longer available and cannot be restored.
        // This means that header information from the original response has been lost.
        //
        // Note that the response body would have been consumed by the deserializer
        // regardless, even if the initial message was hypothetically processed during
        // the orchestrator's deserialization phase but later resulted in an error.
        fn response_error(
            err: impl ::std::convert::Into<::aws_smithy_runtime_api::box_error::BoxError>,
        ) -> ::aws_smithy_runtime_api::client::result::SdkError<
            crate::operation::start_live_tail::StartLiveTailError,
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
        > {
            ::aws_smithy_runtime_api::client::result::SdkError::response_error(
                err,
                ::aws_smithy_runtime_api::client::orchestrator::HttpResponse::new(
                    ::aws_smithy_runtime_api::http::StatusCode::try_from(200).expect("valid successful code"),
                    ::aws_smithy_types::body::SdkBody::empty(),
                ),
            )
        }

        let message = output.response_stream.try_recv_initial_response().await.map_err(response_error)?;

        match message {
            ::std::option::Option::Some(_message) => ::std::result::Result::Ok(output),
            ::std::option::Option::None => ::std::result::Result::Ok(output),
        }
    }

    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
    pub fn customize(
        self,
    ) -> crate::client::customize::CustomizableOperation<
        crate::operation::start_live_tail::StartLiveTailOutput,
        crate::operation::start_live_tail::StartLiveTailError,
        Self,
    > {
        crate::client::customize::CustomizableOperation::new(self)
    }
    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
        self.set_config_override(::std::option::Option::Some(config_override.into()));
        self
    }

    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
        self.config_override = config_override;
        self
    }
    ///
    /// Appends an item to `logGroupIdentifiers`.
    ///
    /// To override the contents of this collection use [`set_log_group_identifiers`](Self::set_log_group_identifiers).
    ///
    /// <p>An array where each item in the array is a log group to include in the Live Tail session.</p>
    /// <p>Specify each log group by its ARN.</p>
    /// <p>If you specify an ARN, the ARN can't end with an asterisk (*).</p><note>
    /// <p>You can include up to 10 log groups.</p>
    /// </note>
    pub fn log_group_identifiers(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.log_group_identifiers(input.into());
        self
    }
    /// <p>An array where each item in the array is a log group to include in the Live Tail session.</p>
    /// <p>Specify each log group by its ARN.</p>
    /// <p>If you specify an ARN, the ARN can't end with an asterisk (*).</p><note>
    /// <p>You can include up to 10 log groups.</p>
    /// </note>
    pub fn set_log_group_identifiers(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
        self.inner = self.inner.set_log_group_identifiers(input);
        self
    }
    /// <p>An array where each item in the array is a log group to include in the Live Tail session.</p>
    /// <p>Specify each log group by its ARN.</p>
    /// <p>If you specify an ARN, the ARN can't end with an asterisk (*).</p><note>
    /// <p>You can include up to 10 log groups.</p>
    /// </note>
    pub fn get_log_group_identifiers(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
        self.inner.get_log_group_identifiers()
    }
    ///
    /// Appends an item to `logStreamNames`.
    ///
    /// To override the contents of this collection use [`set_log_stream_names`](Self::set_log_stream_names).
    ///
    /// <p>If you specify this parameter, then only log events in the log streams that you specify here are included in the Live Tail session.</p>
    /// <p>If you specify this field, you can't also specify the <code>logStreamNamePrefixes</code> field.</p><note>
    /// <p>You can specify this parameter only if you specify only one log group in <code>logGroupIdentifiers</code>.</p>
    /// </note>
    pub fn log_stream_names(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.log_stream_names(input.into());
        self
    }
    /// <p>If you specify this parameter, then only log events in the log streams that you specify here are included in the Live Tail session.</p>
    /// <p>If you specify this field, you can't also specify the <code>logStreamNamePrefixes</code> field.</p><note>
    /// <p>You can specify this parameter only if you specify only one log group in <code>logGroupIdentifiers</code>.</p>
    /// </note>
    pub fn set_log_stream_names(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
        self.inner = self.inner.set_log_stream_names(input);
        self
    }
    /// <p>If you specify this parameter, then only log events in the log streams that you specify here are included in the Live Tail session.</p>
    /// <p>If you specify this field, you can't also specify the <code>logStreamNamePrefixes</code> field.</p><note>
    /// <p>You can specify this parameter only if you specify only one log group in <code>logGroupIdentifiers</code>.</p>
    /// </note>
    pub fn get_log_stream_names(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
        self.inner.get_log_stream_names()
    }
    ///
    /// Appends an item to `logStreamNamePrefixes`.
    ///
    /// To override the contents of this collection use [`set_log_stream_name_prefixes`](Self::set_log_stream_name_prefixes).
    ///
    /// <p>If you specify this parameter, then only log events in the log streams that have names that start with the prefixes that you specify here are included in the Live Tail session.</p>
    /// <p>If you specify this field, you can't also specify the <code>logStreamNames</code> field.</p><note>
    /// <p>You can specify this parameter only if you specify only one log group in <code>logGroupIdentifiers</code>.</p>
    /// </note>
    pub fn log_stream_name_prefixes(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.log_stream_name_prefixes(input.into());
        self
    }
    /// <p>If you specify this parameter, then only log events in the log streams that have names that start with the prefixes that you specify here are included in the Live Tail session.</p>
    /// <p>If you specify this field, you can't also specify the <code>logStreamNames</code> field.</p><note>
    /// <p>You can specify this parameter only if you specify only one log group in <code>logGroupIdentifiers</code>.</p>
    /// </note>
    pub fn set_log_stream_name_prefixes(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
        self.inner = self.inner.set_log_stream_name_prefixes(input);
        self
    }
    /// <p>If you specify this parameter, then only log events in the log streams that have names that start with the prefixes that you specify here are included in the Live Tail session.</p>
    /// <p>If you specify this field, you can't also specify the <code>logStreamNames</code> field.</p><note>
    /// <p>You can specify this parameter only if you specify only one log group in <code>logGroupIdentifiers</code>.</p>
    /// </note>
    pub fn get_log_stream_name_prefixes(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
        self.inner.get_log_stream_name_prefixes()
    }
    /// <p>An optional pattern to use to filter the results to include only log events that match the pattern. For example, a filter pattern of <code>error 404</code> causes only log events that include both <code>error</code> and <code>404</code> to be included in the Live Tail stream.</p>
    /// <p>Regular expression filter patterns are supported.</p>
    /// <p>For more information about filter pattern syntax, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html">Filter and Pattern Syntax</a>.</p>
    pub fn log_event_filter_pattern(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.inner = self.inner.log_event_filter_pattern(input.into());
        self
    }
    /// <p>An optional pattern to use to filter the results to include only log events that match the pattern. For example, a filter pattern of <code>error 404</code> causes only log events that include both <code>error</code> and <code>404</code> to be included in the Live Tail stream.</p>
    /// <p>Regular expression filter patterns are supported.</p>
    /// <p>For more information about filter pattern syntax, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html">Filter and Pattern Syntax</a>.</p>
    pub fn set_log_event_filter_pattern(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.inner = self.inner.set_log_event_filter_pattern(input);
        self
    }
    /// <p>An optional pattern to use to filter the results to include only log events that match the pattern. For example, a filter pattern of <code>error 404</code> causes only log events that include both <code>error</code> and <code>404</code> to be included in the Live Tail stream.</p>
    /// <p>Regular expression filter patterns are supported.</p>
    /// <p>For more information about filter pattern syntax, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html">Filter and Pattern Syntax</a>.</p>
    pub fn get_log_event_filter_pattern(&self) -> &::std::option::Option<::std::string::String> {
        self.inner.get_log_event_filter_pattern()
    }
}