1#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub enum KmsOperation {
6 CreateKey,
8 DescribeKey,
10 ListKeys,
12 EnableKey,
14 DisableKey,
16 ScheduleKeyDeletion,
18 CancelKeyDeletion,
20 UpdateKeyDescription,
22 Encrypt,
24 Decrypt,
26 ReEncrypt,
28 GenerateDataKey,
30 GenerateDataKeyWithoutPlaintext,
32 GenerateDataKeyPair,
34 GenerateDataKeyPairWithoutPlaintext,
36 Sign,
38 Verify,
40 GetPublicKey,
42 GenerateMac,
44 VerifyMac,
46 GenerateRandom,
48 CreateAlias,
50 DeleteAlias,
52 ListAliases,
54 UpdateAlias,
56 TagResource,
58 UntagResource,
60 ListResourceTags,
62 GetKeyPolicy,
64 PutKeyPolicy,
66 ListKeyPolicies,
68 CreateGrant,
70 ListGrants,
72 RetireGrant,
74 RevokeGrant,
76 ListRetirableGrants,
78 EnableKeyRotation,
80 DisableKeyRotation,
82 GetKeyRotationStatus,
84}
85
86impl KmsOperation {
87 #[must_use]
89 pub fn as_str(&self) -> &'static str {
90 match self {
91 Self::CreateKey => "CreateKey",
92 Self::DescribeKey => "DescribeKey",
93 Self::ListKeys => "ListKeys",
94 Self::EnableKey => "EnableKey",
95 Self::DisableKey => "DisableKey",
96 Self::ScheduleKeyDeletion => "ScheduleKeyDeletion",
97 Self::CancelKeyDeletion => "CancelKeyDeletion",
98 Self::UpdateKeyDescription => "UpdateKeyDescription",
99 Self::Encrypt => "Encrypt",
100 Self::Decrypt => "Decrypt",
101 Self::ReEncrypt => "ReEncrypt",
102 Self::GenerateDataKey => "GenerateDataKey",
103 Self::GenerateDataKeyWithoutPlaintext => "GenerateDataKeyWithoutPlaintext",
104 Self::GenerateDataKeyPair => "GenerateDataKeyPair",
105 Self::GenerateDataKeyPairWithoutPlaintext => "GenerateDataKeyPairWithoutPlaintext",
106 Self::Sign => "Sign",
107 Self::Verify => "Verify",
108 Self::GetPublicKey => "GetPublicKey",
109 Self::GenerateMac => "GenerateMac",
110 Self::VerifyMac => "VerifyMac",
111 Self::GenerateRandom => "GenerateRandom",
112 Self::CreateAlias => "CreateAlias",
113 Self::DeleteAlias => "DeleteAlias",
114 Self::ListAliases => "ListAliases",
115 Self::UpdateAlias => "UpdateAlias",
116 Self::TagResource => "TagResource",
117 Self::UntagResource => "UntagResource",
118 Self::ListResourceTags => "ListResourceTags",
119 Self::GetKeyPolicy => "GetKeyPolicy",
120 Self::PutKeyPolicy => "PutKeyPolicy",
121 Self::ListKeyPolicies => "ListKeyPolicies",
122 Self::CreateGrant => "CreateGrant",
123 Self::ListGrants => "ListGrants",
124 Self::RetireGrant => "RetireGrant",
125 Self::RevokeGrant => "RevokeGrant",
126 Self::ListRetirableGrants => "ListRetirableGrants",
127 Self::EnableKeyRotation => "EnableKeyRotation",
128 Self::DisableKeyRotation => "DisableKeyRotation",
129 Self::GetKeyRotationStatus => "GetKeyRotationStatus",
130 }
131 }
132
133 #[must_use]
135 pub fn from_name(name: &str) -> Option<Self> {
136 match name {
137 "CreateKey" => Some(Self::CreateKey),
138 "DescribeKey" => Some(Self::DescribeKey),
139 "ListKeys" => Some(Self::ListKeys),
140 "EnableKey" => Some(Self::EnableKey),
141 "DisableKey" => Some(Self::DisableKey),
142 "ScheduleKeyDeletion" => Some(Self::ScheduleKeyDeletion),
143 "CancelKeyDeletion" => Some(Self::CancelKeyDeletion),
144 "UpdateKeyDescription" => Some(Self::UpdateKeyDescription),
145 "Encrypt" => Some(Self::Encrypt),
146 "Decrypt" => Some(Self::Decrypt),
147 "ReEncrypt" => Some(Self::ReEncrypt),
148 "GenerateDataKey" => Some(Self::GenerateDataKey),
149 "GenerateDataKeyWithoutPlaintext" => Some(Self::GenerateDataKeyWithoutPlaintext),
150 "GenerateDataKeyPair" => Some(Self::GenerateDataKeyPair),
151 "GenerateDataKeyPairWithoutPlaintext" => {
152 Some(Self::GenerateDataKeyPairWithoutPlaintext)
153 }
154 "Sign" => Some(Self::Sign),
155 "Verify" => Some(Self::Verify),
156 "GetPublicKey" => Some(Self::GetPublicKey),
157 "GenerateMac" => Some(Self::GenerateMac),
158 "VerifyMac" => Some(Self::VerifyMac),
159 "GenerateRandom" => Some(Self::GenerateRandom),
160 "CreateAlias" => Some(Self::CreateAlias),
161 "DeleteAlias" => Some(Self::DeleteAlias),
162 "ListAliases" => Some(Self::ListAliases),
163 "UpdateAlias" => Some(Self::UpdateAlias),
164 "TagResource" => Some(Self::TagResource),
165 "UntagResource" => Some(Self::UntagResource),
166 "ListResourceTags" => Some(Self::ListResourceTags),
167 "GetKeyPolicy" => Some(Self::GetKeyPolicy),
168 "PutKeyPolicy" => Some(Self::PutKeyPolicy),
169 "ListKeyPolicies" => Some(Self::ListKeyPolicies),
170 "CreateGrant" => Some(Self::CreateGrant),
171 "ListGrants" => Some(Self::ListGrants),
172 "RetireGrant" => Some(Self::RetireGrant),
173 "RevokeGrant" => Some(Self::RevokeGrant),
174 "ListRetirableGrants" => Some(Self::ListRetirableGrants),
175 "EnableKeyRotation" => Some(Self::EnableKeyRotation),
176 "DisableKeyRotation" => Some(Self::DisableKeyRotation),
177 "GetKeyRotationStatus" => Some(Self::GetKeyRotationStatus),
178 _ => None,
179 }
180 }
181}
182
183impl std::fmt::Display for KmsOperation {
184 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
185 f.write_str(self.as_str())
186 }
187}