acme_types/v2/
account.rs

1#[cfg(feature = "json")]
2use serde::{Deserialize, Serialize};
3
4/// Defines an ACME account registration object.
5///
6/// For more information, refer to [RFC 8555 § 7.3](https://datatracker.ietf.org/doc/html/rfc8555#section-7.3)
7#[derive(Clone, Debug)]
8#[cfg_attr(feature = "json", derive(Serialize, Deserialize))]
9pub struct NewAccount {
10    /// Array of URLs that can be used by the ACME provider to contact the client
11    #[cfg_attr(feature = "json", serde(skip_serializing_if = "Option::is_none"))]
12    pub contact: Option<String>,
13    /// Confirmation client has agreed to the ACME provider's Terms of Service
14    #[cfg_attr(feature = "json", serde(skip_serializing_if = "Option::is_none"))]
15    #[cfg_attr(feature = "json", serde(rename = "termsOfServiceAgreed"))]
16    pub terms_of_service_agreed: Option<bool>,
17    /// Prevent account creation if one does not exist
18    #[cfg_attr(feature = "json", serde(skip_serializing_if = "Option::is_none"))]
19    #[cfg_attr(feature = "json", serde(rename = "onlyReturnExisting"))]
20    pub only_return_existing: Option<bool>,
21    /// External account object
22    #[cfg_attr(feature = "json", serde(skip_serializing_if = "Option::is_none"))]
23    #[cfg_attr(feature = "json", serde(rename = "externalAccountBinding"))]
24    pub external_account_binding: Option<super::JsonWebSignature>,
25}
26
27#[cfg(feature = "json")]
28impl NewAccount {
29    /// Deserializes a NewAccount object from a JSON str
30    pub fn from_str(s: &str) -> Result<NewAccount, serde_json::error::Error> {
31        serde_json::from_str(s)
32    }
33
34    /// Serializes a NewAccount object to a JSON String
35    pub fn to_string(&self) -> Result<String, serde_json::error::Error> {
36        serde_json::to_string(self)
37    }
38}
39
40/// Defines an ACME account update object.
41///
42/// For more information, refer to [RFC 8555 § 7.3.2](https://datatracker.ietf.org/doc/html/rfc8555#section-7.3.2)
43#[derive(Clone, Debug)]
44#[cfg_attr(feature = "json", derive(Serialize, Deserialize))]
45pub struct AccountUpdate {
46    /// This field should not be set unless updating the ACME client's contact details.
47    ///
48    /// For more information, refer to [RFC 8555 § 7.3.2](https://datatracker.ietf.org/doc/html/rfc8555#section-7.3.2)
49    #[cfg_attr(feature = "json", serde(skip_serializing_if = "Option::is_none"))]
50    pub contact: Option<Vec<String>>,
51    /// This field should not be set unless deactivating the ACME client.
52    ///
53    /// For more information, refer to [RFC 8555 § 7.3.6](https://datatracker.ietf.org/doc/html/rfc8555#section-7.3.6)
54    #[cfg_attr(feature = "json", serde(skip_serializing_if = "Option::is_none"))]
55    pub status: Option<AccountStatus>,
56    /// This field should not be set unless the client is agreeing to the current ACME provider's Terms of Service.
57    ///
58    /// For more information, refer to [RFC 8555 § 7.3.3](https://datatracker.ietf.org/doc/html/rfc8555#section-7.3.3)
59    #[cfg_attr(feature = "json", serde(skip_serializing_if = "Option::is_none"))]
60    #[cfg_attr(feature = "json", serde(rename = "termsOfServiceAgreed"))]
61    pub terms_of_service_agreed: Option<bool>,
62}
63
64#[cfg(feature = "json")]
65impl AccountUpdate {
66    /// Deserializes an AccountUpdate object from a JSON str
67    pub fn from_str(s: &str) -> Result<AccountUpdate, serde_json::error::Error> {
68        serde_json::from_str(s)
69    }
70
71    /// Serializes an AccountUpdate object to a JSON String
72    pub fn to_string(&self) -> Result<String, serde_json::error::Error> {
73        serde_json::to_string(self)
74    }
75}
76
77/// Defines an ACME account resource.
78///
79/// For more information, refer to [RFC 8555 § 7.1.2](https://datatracker.ietf.org/doc/html/rfc8555#section-7.1.2)
80#[derive(Clone, Debug)]
81#[cfg_attr(feature = "json", derive(Serialize, Deserialize))]
82pub struct Account {
83    /// ACME account status
84    pub status: AccountStatus,
85    /// Array of URLs that can be used by the ACME provider to contact the client
86    #[cfg_attr(feature = "json", serde(skip_serializing_if = "Option::is_none"))]
87    pub contact: Option<Vec<String>>,
88    /// If set to true, indicates that the ACME account has agreed to the ACME provider's Terms of Service
89    #[cfg_attr(feature = "json", serde(skip_serializing_if = "Option::is_none"))]
90    #[cfg_attr(feature = "json", serde(rename = "termsOfServiceAgreed"))]
91    pub terms_of_service_agreed: Option<bool>,
92    /// External account object
93    #[cfg_attr(feature = "json", serde(skip_serializing_if = "Option::is_none"))]
94    #[cfg_attr(feature = "json", serde(rename = "externalAccountBinding"))]
95    pub external_account_binding: Option<super::JsonWebSignature>,
96    /// URL from which a list of orders submitted by the ACME account can be retrieved.
97    ///
98    /// For more information, refer to [RFC 8555 § 7.1.2.1](https://datatracker.ietf.org/doc/html/rfc8555#section-7.1.2.1)
99    pub orders: String,
100}
101
102#[cfg(feature = "json")]
103impl Account {
104    /// Deserializes an Account object from a JSON str
105    pub fn from_str(s: &str) -> Result<Account, serde_json::error::Error> {
106        serde_json::from_str(s)
107    }
108
109    /// Serializes an Account object to a JSON String
110    pub fn to_string(&self) -> Result<String, serde_json::error::Error> {
111        serde_json::to_string(self)
112    }
113}
114
115/// Defines an ACME account orders object.
116///
117/// For more information, refer to [RFC 8555 § 7.1.2.1](https://datatracker.ietf.org/doc/html/rfc8555#section-7.1.2.1)
118#[derive(Clone, Debug)]
119#[cfg_attr(feature = "json", derive(Serialize, Deserialize))]
120pub struct AccountOrders {
121    /// Array of URLs identifying orders belonging to the ACME account
122    pub orders: Vec<String>,
123}
124
125#[cfg(feature = "json")]
126impl AccountOrders {
127    /// Deserializes an AccountOrders object from a JSON str
128    pub fn from_str(s: &str) -> Result<AccountOrders, serde_json::error::Error> {
129        serde_json::from_str(s)
130    }
131
132    /// Serializes an AccountOrders object to a JSON String
133    pub fn to_string(&self) -> Result<String, serde_json::error::Error> {
134        serde_json::to_string(self)
135    }
136}
137
138/// Account resource status values
139///
140/// For more information, refer to [RFC 8555 § 7.1.6](https://datatracker.ietf.org/doc/html/rfc8555#section-7.1.6)
141#[derive(Clone, Debug)]
142#[cfg_attr(feature = "json", derive(Serialize, Deserialize))]
143pub enum AccountStatus {
144    #[cfg_attr(feature = "json", serde(rename = "valid"))]
145    Valid,
146    #[cfg_attr(feature = "json", serde(rename = "deactivated"))]
147    Deactivated,
148    #[cfg_attr(feature = "json", serde(rename = "revoked"))]
149    Revoked,
150}