Skip to main content

nominal_api/conjure/objects/authorization/
create_api_key_request.rs

1#[derive(
2    Debug,
3    Clone,
4    conjure_object::serde::Serialize,
5    conjure_object::serde::Deserialize,
6    PartialEq,
7    Eq,
8    PartialOrd,
9    Ord,
10    Hash
11)]
12#[serde(crate = "conjure_object::serde")]
13#[conjure_object::private::staged_builder::staged_builder]
14#[builder(crate = conjure_object::private::staged_builder, update, inline)]
15pub struct CreateApiKeyRequest {
16    #[builder(into)]
17    #[serde(rename = "apiKeyName")]
18    api_key_name: String,
19    #[builder(default, into)]
20    #[serde(
21        rename = "expiresAfterDays",
22        skip_serializing_if = "Option::is_none",
23        default
24    )]
25    expires_after_days: Option<conjure_object::SafeLong>,
26}
27impl CreateApiKeyRequest {
28    /// Constructs a new instance of the type.
29    #[inline]
30    pub fn new(api_key_name: impl Into<String>) -> Self {
31        Self::builder().api_key_name(api_key_name).build()
32    }
33    /// The name of the API key to create.
34    #[inline]
35    pub fn api_key_name(&self) -> &str {
36        &*self.api_key_name
37    }
38    /// The number of days after which the API key will expire.
39    /// If omitted, the API key will not expire.
40    #[inline]
41    pub fn expires_after_days(&self) -> Option<conjure_object::SafeLong> {
42        self.expires_after_days.as_ref().map(|o| *o)
43    }
44}