aws-sdk-cloudwatchlogs 1.71.0

AWS SDK for Amazon CloudWatch Logs
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.

/// <p>This processor uses pattern matching to parse and structure unstructured data. This processor can also extract fields from log messages.</p>
/// <p>For more information about this processor including examples, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CloudWatch-Logs-Transformation.html#CloudWatch-Logs-Transformation-Grok"> grok</a> in the <i>CloudWatch Logs User Guide</i>.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Grok {
    /// <p>The path to the field in the log event that you want to parse. If you omit this value, the whole log message is parsed.</p>
    pub source: ::std::option::Option<::std::string::String>,
    /// <p>The grok pattern to match against the log event. For a list of supported grok patterns, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CloudWatch-Logs-Transformation.html#Grok-Patterns">Supported grok patterns</a>.</p>
    pub r#match: ::std::string::String,
}
impl Grok {
    /// <p>The path to the field in the log event that you want to parse. If you omit this value, the whole log message is parsed.</p>
    pub fn source(&self) -> ::std::option::Option<&str> {
        self.source.as_deref()
    }
    /// <p>The grok pattern to match against the log event. For a list of supported grok patterns, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CloudWatch-Logs-Transformation.html#Grok-Patterns">Supported grok patterns</a>.</p>
    pub fn r#match(&self) -> &str {
        use std::ops::Deref;
        self.r#match.deref()
    }
}
impl Grok {
    /// Creates a new builder-style object to manufacture [`Grok`](crate::types::Grok).
    pub fn builder() -> crate::types::builders::GrokBuilder {
        crate::types::builders::GrokBuilder::default()
    }
}

/// A builder for [`Grok`](crate::types::Grok).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct GrokBuilder {
    pub(crate) source: ::std::option::Option<::std::string::String>,
    pub(crate) r#match: ::std::option::Option<::std::string::String>,
}
impl GrokBuilder {
    /// <p>The path to the field in the log event that you want to parse. If you omit this value, the whole log message is parsed.</p>
    pub fn source(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.source = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The path to the field in the log event that you want to parse. If you omit this value, the whole log message is parsed.</p>
    pub fn set_source(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.source = input;
        self
    }
    /// <p>The path to the field in the log event that you want to parse. If you omit this value, the whole log message is parsed.</p>
    pub fn get_source(&self) -> &::std::option::Option<::std::string::String> {
        &self.source
    }
    /// <p>The grok pattern to match against the log event. For a list of supported grok patterns, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CloudWatch-Logs-Transformation.html#Grok-Patterns">Supported grok patterns</a>.</p>
    /// This field is required.
    pub fn r#match(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.r#match = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The grok pattern to match against the log event. For a list of supported grok patterns, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CloudWatch-Logs-Transformation.html#Grok-Patterns">Supported grok patterns</a>.</p>
    pub fn set_match(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.r#match = input;
        self
    }
    /// <p>The grok pattern to match against the log event. For a list of supported grok patterns, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CloudWatch-Logs-Transformation.html#Grok-Patterns">Supported grok patterns</a>.</p>
    pub fn get_match(&self) -> &::std::option::Option<::std::string::String> {
        &self.r#match
    }
    /// Consumes the builder and constructs a [`Grok`](crate::types::Grok).
    /// This method will fail if any of the following fields are not set:
    /// - [`r#match`](crate::types::builders::GrokBuilder::match)
    pub fn build(self) -> ::std::result::Result<crate::types::Grok, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Grok {
            source: self.source,
            r#match: self.r#match.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "r#match",
                    "r#match was not specified but it is required when building Grok",
                )
            })?,
        })
    }
}