aws_sdk_ecr/types/_replication_rule.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>An array of objects representing the replication destinations and repository filters for a replication configuration.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct ReplicationRule {
7 /// <p>An array of objects representing the destination for a replication rule.</p>
8 pub destinations: ::std::vec::Vec<crate::types::ReplicationDestination>,
9 /// <p>An array of objects representing the filters for a replication rule. Specifying a repository filter for a replication rule provides a method for controlling which repositories in a private registry are replicated.</p>
10 pub repository_filters: ::std::option::Option<::std::vec::Vec<crate::types::RepositoryFilter>>,
11}
12impl ReplicationRule {
13 /// <p>An array of objects representing the destination for a replication rule.</p>
14 pub fn destinations(&self) -> &[crate::types::ReplicationDestination] {
15 use std::ops::Deref;
16 self.destinations.deref()
17 }
18 /// <p>An array of objects representing the filters for a replication rule. Specifying a repository filter for a replication rule provides a method for controlling which repositories in a private registry are replicated.</p>
19 ///
20 /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.repository_filters.is_none()`.
21 pub fn repository_filters(&self) -> &[crate::types::RepositoryFilter] {
22 self.repository_filters.as_deref().unwrap_or_default()
23 }
24}
25impl ReplicationRule {
26 /// Creates a new builder-style object to manufacture [`ReplicationRule`](crate::types::ReplicationRule).
27 pub fn builder() -> crate::types::builders::ReplicationRuleBuilder {
28 crate::types::builders::ReplicationRuleBuilder::default()
29 }
30}
31
32/// A builder for [`ReplicationRule`](crate::types::ReplicationRule).
33#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
34#[non_exhaustive]
35pub struct ReplicationRuleBuilder {
36 pub(crate) destinations: ::std::option::Option<::std::vec::Vec<crate::types::ReplicationDestination>>,
37 pub(crate) repository_filters: ::std::option::Option<::std::vec::Vec<crate::types::RepositoryFilter>>,
38}
39impl ReplicationRuleBuilder {
40 /// Appends an item to `destinations`.
41 ///
42 /// To override the contents of this collection use [`set_destinations`](Self::set_destinations).
43 ///
44 /// <p>An array of objects representing the destination for a replication rule.</p>
45 pub fn destinations(mut self, input: crate::types::ReplicationDestination) -> Self {
46 let mut v = self.destinations.unwrap_or_default();
47 v.push(input);
48 self.destinations = ::std::option::Option::Some(v);
49 self
50 }
51 /// <p>An array of objects representing the destination for a replication rule.</p>
52 pub fn set_destinations(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::ReplicationDestination>>) -> Self {
53 self.destinations = input;
54 self
55 }
56 /// <p>An array of objects representing the destination for a replication rule.</p>
57 pub fn get_destinations(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::ReplicationDestination>> {
58 &self.destinations
59 }
60 /// Appends an item to `repository_filters`.
61 ///
62 /// To override the contents of this collection use [`set_repository_filters`](Self::set_repository_filters).
63 ///
64 /// <p>An array of objects representing the filters for a replication rule. Specifying a repository filter for a replication rule provides a method for controlling which repositories in a private registry are replicated.</p>
65 pub fn repository_filters(mut self, input: crate::types::RepositoryFilter) -> Self {
66 let mut v = self.repository_filters.unwrap_or_default();
67 v.push(input);
68 self.repository_filters = ::std::option::Option::Some(v);
69 self
70 }
71 /// <p>An array of objects representing the filters for a replication rule. Specifying a repository filter for a replication rule provides a method for controlling which repositories in a private registry are replicated.</p>
72 pub fn set_repository_filters(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::RepositoryFilter>>) -> Self {
73 self.repository_filters = input;
74 self
75 }
76 /// <p>An array of objects representing the filters for a replication rule. Specifying a repository filter for a replication rule provides a method for controlling which repositories in a private registry are replicated.</p>
77 pub fn get_repository_filters(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::RepositoryFilter>> {
78 &self.repository_filters
79 }
80 /// Consumes the builder and constructs a [`ReplicationRule`](crate::types::ReplicationRule).
81 /// This method will fail if any of the following fields are not set:
82 /// - [`destinations`](crate::types::builders::ReplicationRuleBuilder::destinations)
83 pub fn build(self) -> ::std::result::Result<crate::types::ReplicationRule, ::aws_smithy_types::error::operation::BuildError> {
84 ::std::result::Result::Ok(crate::types::ReplicationRule {
85 destinations: self.destinations.ok_or_else(|| {
86 ::aws_smithy_types::error::operation::BuildError::missing_field(
87 "destinations",
88 "destinations was not specified but it is required when building ReplicationRule",
89 )
90 })?,
91 repository_filters: self.repository_filters,
92 })
93 }
94}