Skip to main content

aws_sdk_cloudfront/types/
_key_group.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>A key group.</p>
4/// <p>A key group contains a list of public keys that you can use with <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PrivateContent.html">CloudFront signed URLs and signed cookies</a>.</p>
5#[non_exhaustive]
6#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
7pub struct KeyGroup {
8    /// <p>The identifier for the key group.</p>
9    pub id: ::std::string::String,
10    /// <p>The date and time when the key group was last modified.</p>
11    pub last_modified_time: ::aws_smithy_types::DateTime,
12    /// <p>The key group configuration.</p>
13    pub key_group_config: ::std::option::Option<crate::types::KeyGroupConfig>,
14}
15impl KeyGroup {
16    /// <p>The identifier for the key group.</p>
17    pub fn id(&self) -> &str {
18        use std::ops::Deref;
19        self.id.deref()
20    }
21    /// <p>The date and time when the key group was last modified.</p>
22    pub fn last_modified_time(&self) -> &::aws_smithy_types::DateTime {
23        &self.last_modified_time
24    }
25    /// <p>The key group configuration.</p>
26    pub fn key_group_config(&self) -> ::std::option::Option<&crate::types::KeyGroupConfig> {
27        self.key_group_config.as_ref()
28    }
29}
30impl KeyGroup {
31    /// Creates a new builder-style object to manufacture [`KeyGroup`](crate::types::KeyGroup).
32    pub fn builder() -> crate::types::builders::KeyGroupBuilder {
33        crate::types::builders::KeyGroupBuilder::default()
34    }
35}
36
37/// A builder for [`KeyGroup`](crate::types::KeyGroup).
38#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
39#[non_exhaustive]
40pub struct KeyGroupBuilder {
41    pub(crate) id: ::std::option::Option<::std::string::String>,
42    pub(crate) last_modified_time: ::std::option::Option<::aws_smithy_types::DateTime>,
43    pub(crate) key_group_config: ::std::option::Option<crate::types::KeyGroupConfig>,
44}
45impl KeyGroupBuilder {
46    /// <p>The identifier for the key group.</p>
47    /// This field is required.
48    pub fn id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
49        self.id = ::std::option::Option::Some(input.into());
50        self
51    }
52    /// <p>The identifier for the key group.</p>
53    pub fn set_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
54        self.id = input;
55        self
56    }
57    /// <p>The identifier for the key group.</p>
58    pub fn get_id(&self) -> &::std::option::Option<::std::string::String> {
59        &self.id
60    }
61    /// <p>The date and time when the key group was last modified.</p>
62    /// This field is required.
63    pub fn last_modified_time(mut self, input: ::aws_smithy_types::DateTime) -> Self {
64        self.last_modified_time = ::std::option::Option::Some(input);
65        self
66    }
67    /// <p>The date and time when the key group was last modified.</p>
68    pub fn set_last_modified_time(mut self, input: ::std::option::Option<::aws_smithy_types::DateTime>) -> Self {
69        self.last_modified_time = input;
70        self
71    }
72    /// <p>The date and time when the key group was last modified.</p>
73    pub fn get_last_modified_time(&self) -> &::std::option::Option<::aws_smithy_types::DateTime> {
74        &self.last_modified_time
75    }
76    /// <p>The key group configuration.</p>
77    /// This field is required.
78    pub fn key_group_config(mut self, input: crate::types::KeyGroupConfig) -> Self {
79        self.key_group_config = ::std::option::Option::Some(input);
80        self
81    }
82    /// <p>The key group configuration.</p>
83    pub fn set_key_group_config(mut self, input: ::std::option::Option<crate::types::KeyGroupConfig>) -> Self {
84        self.key_group_config = input;
85        self
86    }
87    /// <p>The key group configuration.</p>
88    pub fn get_key_group_config(&self) -> &::std::option::Option<crate::types::KeyGroupConfig> {
89        &self.key_group_config
90    }
91    /// Consumes the builder and constructs a [`KeyGroup`](crate::types::KeyGroup).
92    /// This method will fail if any of the following fields are not set:
93    /// - [`id`](crate::types::builders::KeyGroupBuilder::id)
94    /// - [`last_modified_time`](crate::types::builders::KeyGroupBuilder::last_modified_time)
95    pub fn build(self) -> ::std::result::Result<crate::types::KeyGroup, ::aws_smithy_types::error::operation::BuildError> {
96        ::std::result::Result::Ok(crate::types::KeyGroup {
97            id: self.id.ok_or_else(|| {
98                ::aws_smithy_types::error::operation::BuildError::missing_field(
99                    "id",
100                    "id was not specified but it is required when building KeyGroup",
101                )
102            })?,
103            last_modified_time: self.last_modified_time.ok_or_else(|| {
104                ::aws_smithy_types::error::operation::BuildError::missing_field(
105                    "last_modified_time",
106                    "last_modified_time was not specified but it is required when building KeyGroup",
107                )
108            })?,
109            key_group_config: self.key_group_config,
110        })
111    }
112}