66use AsyncAws \Core \Input ;
77use AsyncAws \Core \Request ;
88use AsyncAws \Core \Stream \StreamFactory ;
9+ use AsyncAws \Kms \Enum \DryRunModifierType ;
910use AsyncAws \Kms \Enum \EncryptionAlgorithmSpec ;
1011use AsyncAws \Kms \ValueObject \RecipientInfo ;
1112
@@ -14,7 +15,8 @@ final class DecryptRequest extends Input
1415 /**
1516 * Ciphertext to be decrypted. The blob includes metadata.
1617 *
17- * @required
18+ * This parameter is required in all cases except when `DryRun` is `true` and `DryRunModifiers` is set to
19+ * `IGNORE_CIPHERTEXT`.
1820 *
1921 * @var string|null
2022 */
@@ -60,9 +62,10 @@ final class DecryptRequest extends Input
6062 * Enter a key ID of the KMS key that was used to encrypt the ciphertext. If you identify a different KMS key, the
6163 * `Decrypt` operation throws an `IncorrectKeyException`.
6264 *
63- * This parameter is required only when the ciphertext was encrypted under an asymmetric KMS key. If you used a
64- * symmetric encryption KMS key, KMS can get the KMS key from metadata that it adds to the symmetric ciphertext blob.
65- * However, it is always recommended as a best practice. This practice ensures that you use the KMS key that you intend.
65+ * This parameter is required only when the ciphertext was encrypted under an asymmetric KMS key or when `DryRun` is
66+ * `true` and `DryRunModifiers` is set to `IGNORE_CIPHERTEXT`. If you used a symmetric encryption KMS key, KMS can get
67+ * the KMS key from metadata that it adds to the symmetric ciphertext blob. However, it is always recommended as a best
68+ * practice. This practice ensures that you use the KMS key that you intend.
6669 *
6770 * To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix it with
6871 * `"alias/"`. To specify a KMS key in a different Amazon Web Services account, you must use the key ARN or alias ARN.
@@ -128,15 +131,32 @@ final class DecryptRequest extends Input
128131 */
129132 private $ dryRun ;
130133
134+ /**
135+ * Specifies the modifiers to apply to the dry run operation. `DryRunModifiers` is an optional parameter that only
136+ * applies when `DryRun` is set to `true`.
137+ *
138+ * When set to `IGNORE_CIPHERTEXT`, KMS performs only authorization validation without ciphertext validation. This
139+ * allows you to test permissions without requiring a valid ciphertext blob.
140+ *
141+ * To learn more about how to use this parameter, see Testing your permissions [^1] in the *Key Management Service
142+ * Developer Guide*.
143+ *
144+ * [^1]: https://docs.aws.amazon.com/kms/latest/developerguide/testing-permissions.html
145+ *
146+ * @var list<DryRunModifierType::*>|null
147+ */
148+ private $ dryRunModifiers ;
149+
131150 /**
132151 * @param array{
133- * CiphertextBlob?: string,
152+ * CiphertextBlob?: string|null ,
134153 * EncryptionContext?: array<string, string>|null,
135154 * GrantTokens?: string[]|null,
136155 * KeyId?: string|null,
137156 * EncryptionAlgorithm?: EncryptionAlgorithmSpec::*|null,
138157 * Recipient?: RecipientInfo|array|null,
139158 * DryRun?: bool|null,
159+ * DryRunModifiers?: array<DryRunModifierType::*>|null,
140160 * '@region'?: string|null,
141161 * } $input
142162 */
@@ -149,18 +169,20 @@ public function __construct(array $input = [])
149169 $ this ->encryptionAlgorithm = $ input ['EncryptionAlgorithm ' ] ?? null ;
150170 $ this ->recipient = isset ($ input ['Recipient ' ]) ? RecipientInfo::create ($ input ['Recipient ' ]) : null ;
151171 $ this ->dryRun = $ input ['DryRun ' ] ?? null ;
172+ $ this ->dryRunModifiers = $ input ['DryRunModifiers ' ] ?? null ;
152173 parent ::__construct ($ input );
153174 }
154175
155176 /**
156177 * @param array{
157- * CiphertextBlob?: string,
178+ * CiphertextBlob?: string|null ,
158179 * EncryptionContext?: array<string, string>|null,
159180 * GrantTokens?: string[]|null,
160181 * KeyId?: string|null,
161182 * EncryptionAlgorithm?: EncryptionAlgorithmSpec::*|null,
162183 * Recipient?: RecipientInfo|array|null,
163184 * DryRun?: bool|null,
185+ * DryRunModifiers?: array<DryRunModifierType::*>|null,
164186 * '@region'?: string|null,
165187 * }|DecryptRequest $input
166188 */
@@ -179,6 +201,14 @@ public function getDryRun(): ?bool
179201 return $ this ->dryRun ;
180202 }
181203
204+ /**
205+ * @return list<DryRunModifierType::*>
206+ */
207+ public function getDryRunModifiers (): array
208+ {
209+ return $ this ->dryRunModifiers ?? [];
210+ }
211+
182212 /**
183213 * @return EncryptionAlgorithmSpec::*|null
184214 */
@@ -253,6 +283,16 @@ public function setDryRun(?bool $value): self
253283 return $ this ;
254284 }
255285
286+ /**
287+ * @param list<DryRunModifierType::*> $value
288+ */
289+ public function setDryRunModifiers (array $ value ): self
290+ {
291+ $ this ->dryRunModifiers = $ value ;
292+
293+ return $ this ;
294+ }
295+
256296 /**
257297 * @param EncryptionAlgorithmSpec::*|null $value
258298 */
@@ -300,10 +340,9 @@ public function setRecipient(?RecipientInfo $value): self
300340 private function requestBody (): array
301341 {
302342 $ payload = [];
303- if (null = == $ v = $ this ->ciphertextBlob ) {
304- throw new InvalidArgument ( \sprintf ( ' Missing parameter " CiphertextBlob" for "%s". The value cannot be null. ' , __CLASS__ ) );
343+ if (null ! == $ v = $ this ->ciphertextBlob ) {
344+ $ payload [ ' CiphertextBlob ' ] = base64_encode ( $ v );
305345 }
306- $ payload ['CiphertextBlob ' ] = base64_encode ($ v );
307346 if (null !== $ v = $ this ->encryptionContext ) {
308347 if (empty ($ v )) {
309348 $ payload ['EncryptionContext ' ] = new \stdClass ();
@@ -338,6 +377,18 @@ private function requestBody(): array
338377 if (null !== $ v = $ this ->dryRun ) {
339378 $ payload ['DryRun ' ] = (bool ) $ v ;
340379 }
380+ if (null !== $ v = $ this ->dryRunModifiers ) {
381+ $ index = -1 ;
382+ $ payload ['DryRunModifiers ' ] = [];
383+ foreach ($ v as $ listValue ) {
384+ ++$ index ;
385+ if (!DryRunModifierType::exists ($ listValue )) {
386+ /** @psalm-suppress NoValue */
387+ throw new InvalidArgument (\sprintf ('Invalid parameter "DryRunModifiers" for "%s". The value "%s" is not a valid "DryRunModifierType". ' , __CLASS__ , $ listValue ));
388+ }
389+ $ payload ['DryRunModifiers ' ][$ index ] = $ listValue ;
390+ }
391+ }
341392
342393 return $ payload ;
343394 }
0 commit comments