// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
/// <p>An array of search criteria that targets managed nodes using a key-value pair that you specify.</p><note>
/// <p>One or more targets must be specified for maintenance window Run Command-type tasks. Depending on the task, targets are optional for other maintenance window task types (Automation, Lambda, and Step Functions). For more information about running tasks that don't specify targets, see <a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/maintenance-windows-targetless-tasks.html">Registering maintenance window tasks without targets</a> in the <i>Amazon Web Services Systems Manager User Guide</i>.</p>
/// </note>
/// <p>Supported formats include the following.</p>
/// <p><b>For all Systems Manager tools:</b></p>
/// <ul>
/// <li>
/// <p><code>Key=tag-key,Values=tag-value-1,tag-value-2</code></p></li>
/// </ul>
/// <p><b>For Automation and Change Manager:</b></p>
/// <ul>
/// <li>
/// <p><code>Key=tag:tag-key,Values=tag-value</code></p></li>
/// <li>
/// <p><code>Key=ResourceGroup,Values=resource-group-name</code></p></li>
/// <li>
/// <p><code>Key=ParameterValues,Values=value-1,value-2,value-3</code></p></li>
/// <li>
/// <p>To target all instances in the Amazon Web Services Region:</p>
/// <ul>
/// <li>
/// <p><code>Key=AWS::EC2::Instance,Values=*</code></p></li>
/// <li>
/// <p><code>Key=InstanceIds,Values=*</code></p></li>
/// </ul></li>
/// </ul>
/// <p><b>For Run Command and Maintenance Windows:</b></p>
/// <ul>
/// <li>
/// <p><code>Key=InstanceIds,Values=instance-id-1,instance-id-2,instance-id-3</code></p></li>
/// <li>
/// <p><code>Key=tag:tag-key,Values=tag-value-1,tag-value-2</code></p></li>
/// <li>
/// <p><code>Key=resource-groups:Name,Values=resource-group-name</code></p></li>
/// <li>
/// <p>Additionally, Maintenance Windows support targeting resource types:</p>
/// <ul>
/// <li>
/// <p><code>Key=resource-groups:ResourceTypeFilters,Values=resource-type-1,resource-type-2</code></p></li>
/// </ul></li>
/// </ul>
/// <p><b>For State Manager:</b></p>
/// <ul>
/// <li>
/// <p><code>Key=InstanceIds,Values=instance-id-1,instance-id-2,instance-id-3</code></p></li>
/// <li>
/// <p><code>Key=tag:tag-key,Values=tag-value-1,tag-value-2</code></p></li>
/// <li>
/// <p>To target all instances in the Amazon Web Services Region:</p>
/// <ul>
/// <li>
/// <p><code>Key=InstanceIds,Values=*</code></p></li>
/// </ul></li>
/// </ul>
/// <p>For more information about how to send commands that target managed nodes using <code>Key,Value</code> parameters, see <a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/send-commands-multiple.html#send-commands-targeting">Targeting multiple managed nodes</a> in the <i>Amazon Web Services Systems Manager User Guide</i>.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Target {
/// <p>User-defined criteria for sending commands that target managed nodes that meet the criteria.</p>
pub key: ::std::option::Option<::std::string::String>,
/// <p>User-defined criteria that maps to <code>Key</code>. For example, if you specified <code>tag:ServerRole</code>, you could specify <code>value:WebServer</code> to run a command on instances that include EC2 tags of <code>ServerRole,WebServer</code>.</p>
/// <p>Depending on the type of target, the maximum number of values for a key might be lower than the global maximum of 50.</p>
pub values: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
}
impl Target {
/// <p>User-defined criteria for sending commands that target managed nodes that meet the criteria.</p>
pub fn key(&self) -> ::std::option::Option<&str> {
self.key.as_deref()
}
/// <p>User-defined criteria that maps to <code>Key</code>. For example, if you specified <code>tag:ServerRole</code>, you could specify <code>value:WebServer</code> to run a command on instances that include EC2 tags of <code>ServerRole,WebServer</code>.</p>
/// <p>Depending on the type of target, the maximum number of values for a key might be lower than the global maximum of 50.</p>
///
/// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.values.is_none()`.
pub fn values(&self) -> &[::std::string::String] {
self.values.as_deref().unwrap_or_default()
}
}
impl Target {
/// Creates a new builder-style object to manufacture [`Target`](crate::types::Target).
pub fn builder() -> crate::types::builders::TargetBuilder {
crate::types::builders::TargetBuilder::default()
}
}
/// A builder for [`Target`](crate::types::Target).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct TargetBuilder {
pub(crate) key: ::std::option::Option<::std::string::String>,
pub(crate) values: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
}
impl TargetBuilder {
/// <p>User-defined criteria for sending commands that target managed nodes that meet the criteria.</p>
pub fn key(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.key = ::std::option::Option::Some(input.into());
self
}
/// <p>User-defined criteria for sending commands that target managed nodes that meet the criteria.</p>
pub fn set_key(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.key = input;
self
}
/// <p>User-defined criteria for sending commands that target managed nodes that meet the criteria.</p>
pub fn get_key(&self) -> &::std::option::Option<::std::string::String> {
&self.key
}
/// Appends an item to `values`.
///
/// To override the contents of this collection use [`set_values`](Self::set_values).
///
/// <p>User-defined criteria that maps to <code>Key</code>. For example, if you specified <code>tag:ServerRole</code>, you could specify <code>value:WebServer</code> to run a command on instances that include EC2 tags of <code>ServerRole,WebServer</code>.</p>
/// <p>Depending on the type of target, the maximum number of values for a key might be lower than the global maximum of 50.</p>
pub fn values(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
let mut v = self.values.unwrap_or_default();
v.push(input.into());
self.values = ::std::option::Option::Some(v);
self
}
/// <p>User-defined criteria that maps to <code>Key</code>. For example, if you specified <code>tag:ServerRole</code>, you could specify <code>value:WebServer</code> to run a command on instances that include EC2 tags of <code>ServerRole,WebServer</code>.</p>
/// <p>Depending on the type of target, the maximum number of values for a key might be lower than the global maximum of 50.</p>
pub fn set_values(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
self.values = input;
self
}
/// <p>User-defined criteria that maps to <code>Key</code>. For example, if you specified <code>tag:ServerRole</code>, you could specify <code>value:WebServer</code> to run a command on instances that include EC2 tags of <code>ServerRole,WebServer</code>.</p>
/// <p>Depending on the type of target, the maximum number of values for a key might be lower than the global maximum of 50.</p>
pub fn get_values(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
&self.values
}
/// Consumes the builder and constructs a [`Target`](crate::types::Target).
pub fn build(self) -> crate::types::Target {
crate::types::Target {
key: self.key,
values: self.values,
}
}
}