From 56c85d1326c61c0da31573e184249eca97a50dcf Mon Sep 17 00:00:00 2001 From: texastony <5892063+texastony@users.noreply.github.com> Date: Mon, 4 Nov 2024 17:17:37 -0800 Subject: [PATCH 1/4] chore(KSA-Model): more Mutation Operation changes Explicitly: - Change InitializeMutationFlag from a union to an enum for ToString reasons - Model `DoNotVersion` flag for Initialize Mutation - Refactor Describe Mutation output to detail Input so resume can be done - Refactor System Key to be optional, detailing that TrustStorage is the default - More errors Why change the flag to an enum? Dafny/Smithy-Dafny's support for Union's results in structures that do not print well. The intention of the `InitializeMutationFlag` is to inform customers about the result of their request. Such information may, possibly even should, be logged. --- .../Model/KeyStoreAdmin.smithy | 88 +++++++++++++++---- 1 file changed, 71 insertions(+), 17 deletions(-) diff --git a/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/Model/KeyStoreAdmin.smithy b/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/Model/KeyStoreAdmin.smithy index 751e35571..ba0519b04 100644 --- a/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/Model/KeyStoreAdmin.smithy +++ b/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/Model/KeyStoreAdmin.smithy @@ -46,15 +46,17 @@ service KeyStoreAdmin { DescribeMutation ], errors: [ - KeyStoreAdminException, - MutationConflictException, - MutationInvalidException, + KeyStoreAdminException + MutationConflictException + MutationInvalidException + aws.cryptography.keyStore#KeyStorageException aws.cryptography.keyStore#VersionRaceException MutationLockInvalidException UnexpectedStateException MutationFromException MutationToException MutationVerificationException + UnsupportedFeatureException ] } @@ -120,9 +122,11 @@ structure KmsAes { for non-cryptographic items.") structure TrustStorage {} +// TODO: verify version before release @documentation( "Key Store Admin protects any non-cryptographic -items stored with this Key.") +items stored with this Key. +As of v1.8.0, TrustStorage is the default behavior.") union SystemKey { kmsAes: KmsAes trustStorage: TrustStorage @@ -172,6 +176,10 @@ Additionally create a Beacon Key that is tied to this Branch Key.") operation CreateKey { input: CreateKeyInput, output: CreateKeyOutput + errors: [ + aws.cryptography.keyStore#KeyStorageException + KeyStoreAdminException + ] } structure CreateKeyInput { @@ -208,7 +216,11 @@ structure CreateKeyOutput { operation VersionKey { input: VersionKeyInput, output: VersionKeyOutput, - errors: [aws.cryptography.keyStore#VersionRaceException] + errors: [ + aws.cryptography.keyStore#VersionRaceException + aws.cryptography.keyStore#KeyStorageException + KeyStoreAdminException + ] } @@ -243,9 +255,11 @@ operation InitializeMutation { MutationConflictException MutationInvalidException aws.cryptography.keyStore#VersionRaceException + aws.cryptography.keyStore#KeyStorageException MutationVerificationException MutationToException MutationFromException + UnsupportedFeatureException ] } @@ -261,8 +275,11 @@ structure InitializeMutationInput { @documentation("Optional. Defaults to reEncrypt with a default KMS Client.") Strategy: KeyManagementStrategy - @required + @documentation("Optional. Defaults to TrustStorage. See System Key.") SystemKey: SystemKey + + @documentation("Optional. Defaults to False. As of v1.8.0, setting this true throws an exception.") + DoNotVersion: Boolean } structure MutationToken { @@ -278,14 +295,20 @@ structure MutationToken { CreateTime: String } -union InitializeMutationFlag { - @documentation("This is a new mutation.") - Created: String - @documentation("A matching mutation already existed.") - Resumed: String - @documentation("A matching mutation already existed, but no Page Index was found.") - ResumedWithoutIndex: String -} +@enum([ + { // "This is a new mutation." + name: "Created", + value: "Created" + }, + { // "A matching mutation already existed." + name: "Resumed", + value: "Resumed" + }, + { // "A matching mutation already existed, but no Page Index was found." + name: "ResumedWithoutIndex", + value: "ResumedWithoutIndex" + }]) +string InitializeMutationFlag structure MutatedBranchKeyItem { @required @@ -343,11 +366,13 @@ operation ApplyMutation { input: ApplyMutationInput output: ApplyMutationOutput errors: [ + aws.cryptography.keyStore#KeyStorageException MutationLockInvalidException UnexpectedStateException MutationVerificationException MutationToException MutationFromException + KeyStoreAdminException ] } @@ -366,7 +391,7 @@ structure ApplyMutationInput { @documentation("Optional. Defaults to reEncrypt with a default KMS Client.") Strategy: KeyManagementStrategy - @required + @documentation("Optional. Defaults to TrustStorage. See System Key.") SystemKey: SystemKey } @@ -407,6 +432,11 @@ If one exists, return a description of the mutation.") operation DescribeMutation { input: DescribeMutationInput output: DescribeMutationOutput + errors: [ + KeyStoreAdminException + aws.cryptography.keyStore#KeyStorageException + UnsupportedFeatureException + ] } structure DescribeMutationInput { @@ -415,12 +445,29 @@ structure DescribeMutationInput { Identifier: String } -structure DescribeMutationOutput { +structure MutationDescription { + @required @documentation("The original properities of the Branch Key.") Original: MutableBranchKeyProperities - + @required @documentation("The terminal properities of the Branch Key.") Terminal: MutableBranchKeyProperities + @required + @documentation("The input for this mutation.") + Input: Mutations + @documentation("String descprition of the System Key.") + SystemKey: String +} + +@documentation("If a Mutation is In Flight for this Branch Key.") +union MutationInFlight { + Yes: MutationDescription + No: String +} + +structure DescribeMutationOutput { + @required + MutationInFlight: MutationInFlight } // Errors @@ -511,3 +558,10 @@ structure MutationFromException { @required message: String, } + +@error("client") +@documentation("This feature is not yet implemented.") +structure UnsupportedFeatureException { + @required + message: String, +} From d9d611dd6e0f4a64adf6586229f5b0d7a28478b5 Mon Sep 17 00:00:00 2001 From: texastony <5892063+texastony@users.noreply.github.com> Date: Mon, 4 Nov 2024 17:29:46 -0800 Subject: [PATCH 2/4] chore(KSA): hopefully, the last polymorph of model changes for Mutations --- .../AwsCryptographyKeyStoreAdminTypes.dfy | 26 +- .../cryptography/keystoreadmin/ToDafny.java | 172 ++++-- .../cryptography/keystoreadmin/ToNative.java | 138 +++-- .../model/ApplyMutationInput.java | 17 +- .../model/DescribeMutationOutput.java | 74 +-- .../model/InitializeMutationFlag.java | 160 +----- .../model/InitializeMutationInput.java | 52 +- .../model/MutationDescription.java | 191 +++++++ .../keystoreadmin/model/MutationInFlight.java | 104 ++++ .../keystoreadmin/model/SystemKey.java | 1 + .../model/UnsupportedFeatureException.java | 113 ++++ .../ApplyMutationInput.cs | 1 - .../DescribeMutationOutput.cs | 23 +- .../InitializeMutationFlag.cs | 50 +- .../InitializeMutationInput.cs | 11 +- .../MutationDescription.cs | 58 ++ .../MutationInFlight.cs | 40 ++ .../TypeConversion.cs | 297 ++++++---- .../UnsupportedFeatureException.cs | 13 + .../dafny_to_smithy.py | 116 ++-- .../deserialize.py | 4 + .../aws_cryptography_keystoreadmin/errors.py | 77 ++- .../aws_cryptography_keystoreadmin/models.py | 506 ++++++++++-------- .../smithy_to_dafny.py | 167 +++--- 24 files changed, 1571 insertions(+), 840 deletions(-) create mode 100644 AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/MutationDescription.java create mode 100644 AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/MutationInFlight.java create mode 100644 AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/UnsupportedFeatureException.java create mode 100644 AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/MutationDescription.cs create mode 100644 AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/MutationInFlight.cs create mode 100644 AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/UnsupportedFeatureException.cs diff --git a/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/Model/AwsCryptographyKeyStoreAdminTypes.dfy b/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/Model/AwsCryptographyKeyStoreAdminTypes.dfy index 7a6bb67a6..a81536b77 100644 --- a/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/Model/AwsCryptographyKeyStoreAdminTypes.dfy +++ b/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/Model/AwsCryptographyKeyStoreAdminTypes.dfy @@ -22,7 +22,7 @@ module {:extern "software.amazon.cryptography.keystoreadmin.internaldafny.types" nameonly MutationToken: MutationToken , nameonly PageSize: Option := Option.None , nameonly Strategy: Option := Option.None , - nameonly SystemKey: SystemKey + nameonly SystemKey: Option := Option.None ) datatype ApplyMutationOutput = | ApplyMutationOutput ( nameonly MutationResult: ApplyMutationResult , @@ -44,18 +44,18 @@ module {:extern "software.amazon.cryptography.keystoreadmin.internaldafny.types" nameonly Identifier: string ) datatype DescribeMutationOutput = | DescribeMutationOutput ( - nameonly Original: Option := Option.None , - nameonly Terminal: Option := Option.None + nameonly MutationInFlight: MutationInFlight ) datatype InitializeMutationFlag = - | Created(Created: string) - | Resumed(Resumed: string) - | ResumedWithoutIndex(ResumedWithoutIndex: string) + | Created + | Resumed + | ResumedWithoutIndex datatype InitializeMutationInput = | InitializeMutationInput ( nameonly Identifier: string , nameonly Mutations: Mutations , nameonly Strategy: Option := Option.None , - nameonly SystemKey: SystemKey + nameonly SystemKey: Option := Option.None , + nameonly DoNotVersion: Option := Option.None ) datatype InitializeMutationOutput = | InitializeMutationOutput ( nameonly MutationToken: MutationToken , @@ -204,6 +204,15 @@ module {:extern "software.amazon.cryptography.keystoreadmin.internaldafny.types" datatype MutationComplete = | MutationComplete ( ) + datatype MutationDescription = | MutationDescription ( + nameonly Original: MutableBranchKeyProperities , + nameonly Terminal: MutableBranchKeyProperities , + nameonly Input: Mutations , + nameonly SystemKey: Option := Option.None + ) + datatype MutationInFlight = + | Yes(Yes: MutationDescription) + | No(No: string) datatype Mutations = | Mutations ( nameonly TerminalKmsArn: Option := Option.None , nameonly TerminalEncryptionContext: Option := Option.None @@ -253,6 +262,9 @@ module {:extern "software.amazon.cryptography.keystoreadmin.internaldafny.types" | UnexpectedStateException ( nameonly message: string ) + | UnsupportedFeatureException ( + nameonly message: string + ) // Any dependent models are listed here | AwsCryptographyKeyStore(AwsCryptographyKeyStore: AwsCryptographyKeyStoreTypes.Error) | ComAmazonawsDynamodb(ComAmazonawsDynamodb: ComAmazonawsDynamodbTypes.Error) diff --git a/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/ToDafny.java b/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/ToDafny.java index eff30d958..1287b6b65 100644 --- a/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/ToDafny.java +++ b/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/ToDafny.java @@ -7,6 +7,7 @@ import dafny.DafnyMap; import dafny.DafnySequence; import dafny.TypeDescriptor; +import java.lang.Boolean; import java.lang.Byte; import java.lang.Character; import java.lang.IllegalArgumentException; @@ -32,6 +33,7 @@ import software.amazon.cryptography.keystoreadmin.internaldafny.types.Error_MutationToException; import software.amazon.cryptography.keystoreadmin.internaldafny.types.Error_MutationVerificationException; import software.amazon.cryptography.keystoreadmin.internaldafny.types.Error_UnexpectedStateException; +import software.amazon.cryptography.keystoreadmin.internaldafny.types.Error_UnsupportedFeatureException; import software.amazon.cryptography.keystoreadmin.internaldafny.types.IKeyStoreAdminClient; import software.amazon.cryptography.keystoreadmin.internaldafny.types.InitializeMutationFlag; import software.amazon.cryptography.keystoreadmin.internaldafny.types.InitializeMutationInput; @@ -43,6 +45,8 @@ import software.amazon.cryptography.keystoreadmin.internaldafny.types.MutableBranchKeyProperities; import software.amazon.cryptography.keystoreadmin.internaldafny.types.MutatedBranchKeyItem; import software.amazon.cryptography.keystoreadmin.internaldafny.types.MutationComplete; +import software.amazon.cryptography.keystoreadmin.internaldafny.types.MutationDescription; +import software.amazon.cryptography.keystoreadmin.internaldafny.types.MutationInFlight; import software.amazon.cryptography.keystoreadmin.internaldafny.types.MutationToken; import software.amazon.cryptography.keystoreadmin.internaldafny.types.Mutations; import software.amazon.cryptography.keystoreadmin.internaldafny.types.SystemKey; @@ -59,6 +63,7 @@ import software.amazon.cryptography.keystoreadmin.model.MutationVerificationException; import software.amazon.cryptography.keystoreadmin.model.OpaqueError; import software.amazon.cryptography.keystoreadmin.model.UnexpectedStateException; +import software.amazon.cryptography.keystoreadmin.model.UnsupportedFeatureException; public class ToDafny { @@ -87,6 +92,9 @@ public static Error Error(RuntimeException nativeValue) { if (nativeValue instanceof UnexpectedStateException) { return ToDafny.Error((UnexpectedStateException) nativeValue); } + if (nativeValue instanceof UnsupportedFeatureException) { + return ToDafny.Error((UnsupportedFeatureException) nativeValue); + } if (nativeValue instanceof OpaqueError) { return ToDafny.Error((OpaqueError) nativeValue); } @@ -132,8 +140,14 @@ public static ApplyMutationInput ApplyMutationInput( ToDafny.KeyManagementStrategy(nativeValue.Strategy()) ) : Option.create_None(KeyManagementStrategy._typeDescriptor()); - SystemKey systemKey; - systemKey = ToDafny.SystemKey(nativeValue.SystemKey()); + Option systemKey; + systemKey = + Objects.nonNull(nativeValue.SystemKey()) + ? Option.create_Some( + SystemKey._typeDescriptor(), + ToDafny.SystemKey(nativeValue.SystemKey()) + ) + : Option.create_None(SystemKey._typeDescriptor()); return new ApplyMutationInput(mutationToken, pageSize, strategy, systemKey); } @@ -225,23 +239,9 @@ public static DescribeMutationInput DescribeMutationInput( public static DescribeMutationOutput DescribeMutationOutput( software.amazon.cryptography.keystoreadmin.model.DescribeMutationOutput nativeValue ) { - Option original; - original = - Objects.nonNull(nativeValue.Original()) - ? Option.create_Some( - MutableBranchKeyProperities._typeDescriptor(), - ToDafny.MutableBranchKeyProperities(nativeValue.Original()) - ) - : Option.create_None(MutableBranchKeyProperities._typeDescriptor()); - Option terminal; - terminal = - Objects.nonNull(nativeValue.Terminal()) - ? Option.create_Some( - MutableBranchKeyProperities._typeDescriptor(), - ToDafny.MutableBranchKeyProperities(nativeValue.Terminal()) - ) - : Option.create_None(MutableBranchKeyProperities._typeDescriptor()); - return new DescribeMutationOutput(original, terminal); + MutationInFlight mutationInFlight; + mutationInFlight = ToDafny.MutationInFlight(nativeValue.MutationInFlight()); + return new DescribeMutationOutput(mutationInFlight); } public static InitializeMutationInput InitializeMutationInput( @@ -262,13 +262,28 @@ public static InitializeMutationInput InitializeMutationInput( ToDafny.KeyManagementStrategy(nativeValue.Strategy()) ) : Option.create_None(KeyManagementStrategy._typeDescriptor()); - SystemKey systemKey; - systemKey = ToDafny.SystemKey(nativeValue.SystemKey()); + Option systemKey; + systemKey = + Objects.nonNull(nativeValue.SystemKey()) + ? Option.create_Some( + SystemKey._typeDescriptor(), + ToDafny.SystemKey(nativeValue.SystemKey()) + ) + : Option.create_None(SystemKey._typeDescriptor()); + Option doNotVersion; + doNotVersion = + Objects.nonNull(nativeValue.DoNotVersion()) + ? Option.create_Some( + TypeDescriptor.BOOLEAN, + (nativeValue.DoNotVersion()) + ) + : Option.create_None(TypeDescriptor.BOOLEAN); return new InitializeMutationInput( identifier, mutations, strategy, - systemKey + systemKey, + doNotVersion ); } @@ -360,6 +375,30 @@ public static MutationComplete MutationComplete( return new MutationComplete(); } + public static MutationDescription MutationDescription( + software.amazon.cryptography.keystoreadmin.model.MutationDescription nativeValue + ) { + MutableBranchKeyProperities original; + original = ToDafny.MutableBranchKeyProperities(nativeValue.Original()); + MutableBranchKeyProperities terminal; + terminal = ToDafny.MutableBranchKeyProperities(nativeValue.Terminal()); + Mutations input; + input = ToDafny.Mutations(nativeValue.Input()); + Option> systemKey; + systemKey = + Objects.nonNull(nativeValue.SystemKey()) + ? Option.create_Some( + DafnySequence._typeDescriptor(TypeDescriptor.CHAR), + software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence( + nativeValue.SystemKey() + ) + ) + : Option.create_None( + DafnySequence._typeDescriptor(TypeDescriptor.CHAR) + ); + return new MutationDescription(original, terminal, input, systemKey); + } + public static Mutations Mutations( software.amazon.cryptography.keystoreadmin.model.Mutations nativeValue ) { @@ -535,6 +574,42 @@ public static Error Error(UnexpectedStateException nativeValue) { return new Error_UnexpectedStateException(message); } + public static Error Error(UnsupportedFeatureException nativeValue) { + DafnySequence message; + message = + software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence( + nativeValue.message() + ); + return new Error_UnsupportedFeatureException(message); + } + + public static InitializeMutationFlag InitializeMutationFlag( + software.amazon.cryptography.keystoreadmin.model.InitializeMutationFlag nativeValue + ) { + switch (nativeValue) { + case Created: + { + return InitializeMutationFlag.create_Created(); + } + case Resumed: + { + return InitializeMutationFlag.create_Resumed(); + } + case ResumedWithoutIndex: + { + return InitializeMutationFlag.create_ResumedWithoutIndex(); + } + default: + { + throw new RuntimeException( + "Cannot convert " + + nativeValue + + " to software.amazon.cryptography.keystoreadmin.internaldafny.types.InitializeMutationFlag." + ); + } + } + } + public static ApplyMutationResult ApplyMutationResult( software.amazon.cryptography.keystoreadmin.model.ApplyMutationResult nativeValue ) { @@ -555,37 +630,6 @@ public static ApplyMutationResult ApplyMutationResult( ); } - public static InitializeMutationFlag InitializeMutationFlag( - software.amazon.cryptography.keystoreadmin.model.InitializeMutationFlag nativeValue - ) { - if (Objects.nonNull(nativeValue.Created())) { - return InitializeMutationFlag.create_Created( - software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence( - nativeValue.Created() - ) - ); - } - if (Objects.nonNull(nativeValue.Resumed())) { - return InitializeMutationFlag.create_Resumed( - software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence( - nativeValue.Resumed() - ) - ); - } - if (Objects.nonNull(nativeValue.ResumedWithoutIndex())) { - return InitializeMutationFlag.create_ResumedWithoutIndex( - software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence( - nativeValue.ResumedWithoutIndex() - ) - ); - } - throw new IllegalArgumentException( - "Cannot convert " + - nativeValue + - " to software.amazon.cryptography.keystoreadmin.internaldafny.types.InitializeMutationFlag." - ); - } - public static KeyManagementStrategy KeyManagementStrategy( software.amazon.cryptography.keystoreadmin.model.KeyManagementStrategy nativeValue ) { @@ -627,6 +671,28 @@ public static KmsAesIdentifier KmsAesIdentifier( ); } + public static MutationInFlight MutationInFlight( + software.amazon.cryptography.keystoreadmin.model.MutationInFlight nativeValue + ) { + if (Objects.nonNull(nativeValue.Yes())) { + return MutationInFlight.create_Yes( + ToDafny.MutationDescription(nativeValue.Yes()) + ); + } + if (Objects.nonNull(nativeValue.No())) { + return MutationInFlight.create_No( + software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence( + nativeValue.No() + ) + ); + } + throw new IllegalArgumentException( + "Cannot convert " + + nativeValue + + " to software.amazon.cryptography.keystoreadmin.internaldafny.types.MutationInFlight." + ); + } + public static SystemKey SystemKey( software.amazon.cryptography.keystoreadmin.model.SystemKey nativeValue ) { diff --git a/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/ToNative.java b/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/ToNative.java index 1e22d0f6a..4d52d11e2 100644 --- a/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/ToNative.java +++ b/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/ToNative.java @@ -4,6 +4,7 @@ package software.amazon.cryptography.keystoreadmin; import dafny.DafnySequence; +import java.lang.IllegalArgumentException; import java.lang.RuntimeException; import java.util.List; import software.amazon.cryptography.keystoreadmin.internaldafny.types.Error; @@ -17,6 +18,7 @@ import software.amazon.cryptography.keystoreadmin.internaldafny.types.Error_MutationVerificationException; import software.amazon.cryptography.keystoreadmin.internaldafny.types.Error_Opaque; import software.amazon.cryptography.keystoreadmin.internaldafny.types.Error_UnexpectedStateException; +import software.amazon.cryptography.keystoreadmin.internaldafny.types.Error_UnsupportedFeatureException; import software.amazon.cryptography.keystoreadmin.internaldafny.types.IKeyStoreAdminClient; import software.amazon.cryptography.keystoreadmin.model.ApplyMutationInput; import software.amazon.cryptography.keystoreadmin.model.ApplyMutationOutput; @@ -38,7 +40,9 @@ import software.amazon.cryptography.keystoreadmin.model.MutatedBranchKeyItem; import software.amazon.cryptography.keystoreadmin.model.MutationComplete; import software.amazon.cryptography.keystoreadmin.model.MutationConflictException; +import software.amazon.cryptography.keystoreadmin.model.MutationDescription; import software.amazon.cryptography.keystoreadmin.model.MutationFromException; +import software.amazon.cryptography.keystoreadmin.model.MutationInFlight; import software.amazon.cryptography.keystoreadmin.model.MutationInvalidException; import software.amazon.cryptography.keystoreadmin.model.MutationLockInvalidException; import software.amazon.cryptography.keystoreadmin.model.MutationToException; @@ -49,6 +53,7 @@ import software.amazon.cryptography.keystoreadmin.model.SystemKey; import software.amazon.cryptography.keystoreadmin.model.TrustStorage; import software.amazon.cryptography.keystoreadmin.model.UnexpectedStateException; +import software.amazon.cryptography.keystoreadmin.model.UnsupportedFeatureException; import software.amazon.cryptography.keystoreadmin.model.VersionKeyInput; import software.amazon.cryptography.keystoreadmin.model.VersionKeyOutput; @@ -179,6 +184,19 @@ public static UnexpectedStateException Error( return nativeBuilder.build(); } + public static UnsupportedFeatureException Error( + Error_UnsupportedFeatureException dafnyValue + ) { + UnsupportedFeatureException.Builder nativeBuilder = + UnsupportedFeatureException.builder(); + nativeBuilder.message( + software.amazon.smithy.dafny.conversion.ToNative.Simple.String( + dafnyValue.dtor_message() + ) + ); + return nativeBuilder.build(); + } + public static RuntimeException Error(Error dafnyValue) { if (dafnyValue.is_KeyStoreAdminException()) { return ToNative.Error((Error_KeyStoreAdminException) dafnyValue); @@ -204,6 +222,9 @@ public static RuntimeException Error(Error dafnyValue) { if (dafnyValue.is_UnexpectedStateException()) { return ToNative.Error((Error_UnexpectedStateException) dafnyValue); } + if (dafnyValue.is_UnsupportedFeatureException()) { + return ToNative.Error((Error_UnsupportedFeatureException) dafnyValue); + } if (dafnyValue.is_Opaque()) { return ToNative.Error((Error_Opaque) dafnyValue); } @@ -245,7 +266,11 @@ public static ApplyMutationInput ApplyMutationInput( ToNative.KeyManagementStrategy(dafnyValue.dtor_Strategy().dtor_value()) ); } - nativeBuilder.SystemKey(ToNative.SystemKey(dafnyValue.dtor_SystemKey())); + if (dafnyValue.dtor_SystemKey().is_Some()) { + nativeBuilder.SystemKey( + ToNative.SystemKey(dafnyValue.dtor_SystemKey().dtor_value()) + ); + } return nativeBuilder.build(); } @@ -319,20 +344,9 @@ public static DescribeMutationOutput DescribeMutationOutput( ) { DescribeMutationOutput.Builder nativeBuilder = DescribeMutationOutput.builder(); - if (dafnyValue.dtor_Original().is_Some()) { - nativeBuilder.Original( - ToNative.MutableBranchKeyProperities( - dafnyValue.dtor_Original().dtor_value() - ) - ); - } - if (dafnyValue.dtor_Terminal().is_Some()) { - nativeBuilder.Terminal( - ToNative.MutableBranchKeyProperities( - dafnyValue.dtor_Terminal().dtor_value() - ) - ); - } + nativeBuilder.MutationInFlight( + ToNative.MutationInFlight(dafnyValue.dtor_MutationInFlight()) + ); return nativeBuilder.build(); } @@ -352,7 +366,14 @@ public static InitializeMutationInput InitializeMutationInput( ToNative.KeyManagementStrategy(dafnyValue.dtor_Strategy().dtor_value()) ); } - nativeBuilder.SystemKey(ToNative.SystemKey(dafnyValue.dtor_SystemKey())); + if (dafnyValue.dtor_SystemKey().is_Some()) { + nativeBuilder.SystemKey( + ToNative.SystemKey(dafnyValue.dtor_SystemKey().dtor_value()) + ); + } + if (dafnyValue.dtor_DoNotVersion().is_Some()) { + nativeBuilder.DoNotVersion((dafnyValue.dtor_DoNotVersion().dtor_value())); + } return nativeBuilder.build(); } @@ -447,6 +468,27 @@ public static MutationComplete MutationComplete( return nativeBuilder.build(); } + public static MutationDescription MutationDescription( + software.amazon.cryptography.keystoreadmin.internaldafny.types.MutationDescription dafnyValue + ) { + MutationDescription.Builder nativeBuilder = MutationDescription.builder(); + nativeBuilder.Original( + ToNative.MutableBranchKeyProperities(dafnyValue.dtor_Original()) + ); + nativeBuilder.Terminal( + ToNative.MutableBranchKeyProperities(dafnyValue.dtor_Terminal()) + ); + nativeBuilder.Input(ToNative.Mutations(dafnyValue.dtor_Input())); + if (dafnyValue.dtor_SystemKey().is_Some()) { + nativeBuilder.SystemKey( + software.amazon.smithy.dafny.conversion.ToNative.Simple.String( + dafnyValue.dtor_SystemKey().dtor_value() + ) + ); + } + return nativeBuilder.build(); + } + public static Mutations Mutations( software.amazon.cryptography.keystoreadmin.internaldafny.types.Mutations dafnyValue ) { @@ -524,6 +566,24 @@ public static VersionKeyOutput VersionKeyOutput( return nativeBuilder.build(); } + public static InitializeMutationFlag InitializeMutationFlag( + software.amazon.cryptography.keystoreadmin.internaldafny.types.InitializeMutationFlag dafnyValue + ) { + if (dafnyValue.is_Created()) { + return InitializeMutationFlag.Created; + } + if (dafnyValue.is_Resumed()) { + return InitializeMutationFlag.Resumed; + } + if (dafnyValue.is_ResumedWithoutIndex()) { + return InitializeMutationFlag.ResumedWithoutIndex; + } + throw new IllegalArgumentException( + "No entry of software.amazon.cryptography.keystoreadmin.model.InitializeMutationFlag matches the input : " + + dafnyValue + ); + } + public static ApplyMutationResult ApplyMutationResult( software.amazon.cryptography.keystoreadmin.internaldafny.types.ApplyMutationResult dafnyValue ) { @@ -541,35 +601,6 @@ public static ApplyMutationResult ApplyMutationResult( return nativeBuilder.build(); } - public static InitializeMutationFlag InitializeMutationFlag( - software.amazon.cryptography.keystoreadmin.internaldafny.types.InitializeMutationFlag dafnyValue - ) { - InitializeMutationFlag.Builder nativeBuilder = - InitializeMutationFlag.builder(); - if (dafnyValue.is_Created()) { - nativeBuilder.Created( - software.amazon.smithy.dafny.conversion.ToNative.Simple.String( - dafnyValue.dtor_Created() - ) - ); - } - if (dafnyValue.is_Resumed()) { - nativeBuilder.Resumed( - software.amazon.smithy.dafny.conversion.ToNative.Simple.String( - dafnyValue.dtor_Resumed() - ) - ); - } - if (dafnyValue.is_ResumedWithoutIndex()) { - nativeBuilder.ResumedWithoutIndex( - software.amazon.smithy.dafny.conversion.ToNative.Simple.String( - dafnyValue.dtor_ResumedWithoutIndex() - ) - ); - } - return nativeBuilder.build(); - } - public static KeyManagementStrategy KeyManagementStrategy( software.amazon.cryptography.keystoreadmin.internaldafny.types.KeyManagementStrategy dafnyValue ) { @@ -606,6 +637,23 @@ public static KmsAesIdentifier KmsAesIdentifier( return nativeBuilder.build(); } + public static MutationInFlight MutationInFlight( + software.amazon.cryptography.keystoreadmin.internaldafny.types.MutationInFlight dafnyValue + ) { + MutationInFlight.Builder nativeBuilder = MutationInFlight.builder(); + if (dafnyValue.is_Yes()) { + nativeBuilder.Yes(ToNative.MutationDescription(dafnyValue.dtor_Yes())); + } + if (dafnyValue.is_No()) { + nativeBuilder.No( + software.amazon.smithy.dafny.conversion.ToNative.Simple.String( + dafnyValue.dtor_No() + ) + ); + } + return nativeBuilder.build(); + } + public static SystemKey SystemKey( software.amazon.cryptography.keystoreadmin.internaldafny.types.SystemKey dafnyValue ) { diff --git a/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/ApplyMutationInput.java b/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/ApplyMutationInput.java index 9dda892f3..b77d9f006 100644 --- a/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/ApplyMutationInput.java +++ b/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/ApplyMutationInput.java @@ -24,8 +24,7 @@ public class ApplyMutationInput { private final KeyManagementStrategy Strategy; /** - * Key Store Admin protects any non-cryptographic - * items stored with this Key. + * Optional. Defaults to TrustStorage. See System Key. */ private final SystemKey SystemKey; @@ -59,8 +58,7 @@ public KeyManagementStrategy Strategy() { } /** - * @return Key Store Admin protects any non-cryptographic - * items stored with this Key. + * @return Optional. Defaults to TrustStorage. See System Key. */ public SystemKey SystemKey() { return this.SystemKey; @@ -108,14 +106,12 @@ public interface Builder { KeyManagementStrategy Strategy(); /** - * @param SystemKey Key Store Admin protects any non-cryptographic - * items stored with this Key. + * @param SystemKey Optional. Defaults to TrustStorage. See System Key. */ Builder SystemKey(SystemKey SystemKey); /** - * @return Key Store Admin protects any non-cryptographic - * items stored with this Key. + * @return Optional. Defaults to TrustStorage. See System Key. */ SystemKey SystemKey(); @@ -183,11 +179,6 @@ public ApplyMutationInput build() { "Missing value for required field `MutationToken`" ); } - if (Objects.isNull(this.SystemKey())) { - throw new IllegalArgumentException( - "Missing value for required field `SystemKey`" - ); - } return new ApplyMutationInput(this); } } diff --git a/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/DescribeMutationOutput.java b/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/DescribeMutationOutput.java index e601ffac1..4717f7976 100644 --- a/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/DescribeMutationOutput.java +++ b/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/DescribeMutationOutput.java @@ -3,35 +3,24 @@ // Do not modify this file. This file is machine generated, and any changes to it will be overwritten. package software.amazon.cryptography.keystoreadmin.model; -public class DescribeMutationOutput { +import java.util.Objects; - /** - * The original properities of the Branch Key. - */ - private final MutableBranchKeyProperities Original; +public class DescribeMutationOutput { /** - * The terminal properities of the Branch Key. + * If a Mutation is In Flight for this Branch Key. */ - private final MutableBranchKeyProperities Terminal; + private final MutationInFlight MutationInFlight; protected DescribeMutationOutput(BuilderImpl builder) { - this.Original = builder.Original(); - this.Terminal = builder.Terminal(); - } - - /** - * @return The original properities of the Branch Key. - */ - public MutableBranchKeyProperities Original() { - return this.Original; + this.MutationInFlight = builder.MutationInFlight(); } /** - * @return The terminal properities of the Branch Key. + * @return If a Mutation is In Flight for this Branch Key. */ - public MutableBranchKeyProperities Terminal() { - return this.Terminal; + public MutationInFlight MutationInFlight() { + return this.MutationInFlight; } public Builder toBuilder() { @@ -44,60 +33,43 @@ public static Builder builder() { public interface Builder { /** - * @param Original The original properities of the Branch Key. - */ - Builder Original(MutableBranchKeyProperities Original); - - /** - * @return The original properities of the Branch Key. + * @param MutationInFlight If a Mutation is In Flight for this Branch Key. */ - MutableBranchKeyProperities Original(); + Builder MutationInFlight(MutationInFlight MutationInFlight); /** - * @param Terminal The terminal properities of the Branch Key. + * @return If a Mutation is In Flight for this Branch Key. */ - Builder Terminal(MutableBranchKeyProperities Terminal); - - /** - * @return The terminal properities of the Branch Key. - */ - MutableBranchKeyProperities Terminal(); + MutationInFlight MutationInFlight(); DescribeMutationOutput build(); } static class BuilderImpl implements Builder { - protected MutableBranchKeyProperities Original; - - protected MutableBranchKeyProperities Terminal; + protected MutationInFlight MutationInFlight; protected BuilderImpl() {} protected BuilderImpl(DescribeMutationOutput model) { - this.Original = model.Original(); - this.Terminal = model.Terminal(); - } - - public Builder Original(MutableBranchKeyProperities Original) { - this.Original = Original; - return this; - } - - public MutableBranchKeyProperities Original() { - return this.Original; + this.MutationInFlight = model.MutationInFlight(); } - public Builder Terminal(MutableBranchKeyProperities Terminal) { - this.Terminal = Terminal; + public Builder MutationInFlight(MutationInFlight MutationInFlight) { + this.MutationInFlight = MutationInFlight; return this; } - public MutableBranchKeyProperities Terminal() { - return this.Terminal; + public MutationInFlight MutationInFlight() { + return this.MutationInFlight; } public DescribeMutationOutput build() { + if (Objects.isNull(this.MutationInFlight())) { + throw new IllegalArgumentException( + "Missing value for required field `MutationInFlight`" + ); + } return new DescribeMutationOutput(this); } } diff --git a/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/InitializeMutationFlag.java b/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/InitializeMutationFlag.java index 3db5d8765..545cfd638 100644 --- a/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/InitializeMutationFlag.java +++ b/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/InitializeMutationFlag.java @@ -3,162 +3,20 @@ // Do not modify this file. This file is machine generated, and any changes to it will be overwritten. package software.amazon.cryptography.keystoreadmin.model; -import java.util.Objects; +public enum InitializeMutationFlag { + Created("Created"), -public class InitializeMutationFlag { + Resumed("Resumed"), - /** - * This is a new mutation. - */ - private final String Created; + ResumedWithoutIndex("ResumedWithoutIndex"); - /** - * A matching mutation already existed. - */ - private final String Resumed; + private final String value; - /** - * A matching mutation already existed, but no Page Index was found. - */ - private final String ResumedWithoutIndex; - - protected InitializeMutationFlag(BuilderImpl builder) { - this.Created = builder.Created(); - this.Resumed = builder.Resumed(); - this.ResumedWithoutIndex = builder.ResumedWithoutIndex(); - } - - /** - * @return This is a new mutation. - */ - public String Created() { - return this.Created; - } - - /** - * @return A matching mutation already existed. - */ - public String Resumed() { - return this.Resumed; - } - - /** - * @return A matching mutation already existed, but no Page Index was found. - */ - public String ResumedWithoutIndex() { - return this.ResumedWithoutIndex; - } - - public Builder toBuilder() { - return new BuilderImpl(this); - } - - public static Builder builder() { - return new BuilderImpl(); - } - - public interface Builder { - /** - * @param Created This is a new mutation. - */ - Builder Created(String Created); - - /** - * @return This is a new mutation. - */ - String Created(); - - /** - * @param Resumed A matching mutation already existed. - */ - Builder Resumed(String Resumed); - - /** - * @return A matching mutation already existed. - */ - String Resumed(); - - /** - * @param ResumedWithoutIndex A matching mutation already existed, but no Page Index was found. - */ - Builder ResumedWithoutIndex(String ResumedWithoutIndex); - - /** - * @return A matching mutation already existed, but no Page Index was found. - */ - String ResumedWithoutIndex(); - - InitializeMutationFlag build(); + private InitializeMutationFlag(String value) { + this.value = value; } - static class BuilderImpl implements Builder { - - protected String Created; - - protected String Resumed; - - protected String ResumedWithoutIndex; - - protected BuilderImpl() {} - - protected BuilderImpl(InitializeMutationFlag model) { - this.Created = model.Created(); - this.Resumed = model.Resumed(); - this.ResumedWithoutIndex = model.ResumedWithoutIndex(); - } - - public Builder Created(String Created) { - this.Created = Created; - return this; - } - - public String Created() { - return this.Created; - } - - public Builder Resumed(String Resumed) { - this.Resumed = Resumed; - return this; - } - - public String Resumed() { - return this.Resumed; - } - - public Builder ResumedWithoutIndex(String ResumedWithoutIndex) { - this.ResumedWithoutIndex = ResumedWithoutIndex; - return this; - } - - public String ResumedWithoutIndex() { - return this.ResumedWithoutIndex; - } - - public InitializeMutationFlag build() { - if (!onlyOneNonNull()) { - throw new IllegalArgumentException( - "`InitializeMutationFlag` is a Union. A Union MUST have one and only one value set." - ); - } - return new InitializeMutationFlag(this); - } - - private boolean onlyOneNonNull() { - Object[] allValues = { - this.Created, - this.Resumed, - this.ResumedWithoutIndex, - }; - boolean haveOneNonNull = false; - for (Object o : allValues) { - if (Objects.nonNull(o)) { - if (haveOneNonNull) { - return false; - } - haveOneNonNull = true; - } - } - return haveOneNonNull; - } + public String toString() { + return String.valueOf(value); } } diff --git a/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/InitializeMutationInput.java b/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/InitializeMutationInput.java index 227c7028b..78c5680b5 100644 --- a/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/InitializeMutationInput.java +++ b/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/InitializeMutationInput.java @@ -23,16 +23,21 @@ public class InitializeMutationInput { private final KeyManagementStrategy Strategy; /** - * Key Store Admin protects any non-cryptographic - * items stored with this Key. + * Optional. Defaults to TrustStorage. See System Key. */ private final SystemKey SystemKey; + /** + * Optional. Defaults to False. As of v1.8.0, setting this true throws an exception. + */ + private final Boolean DoNotVersion; + protected InitializeMutationInput(BuilderImpl builder) { this.Identifier = builder.Identifier(); this.Mutations = builder.Mutations(); this.Strategy = builder.Strategy(); this.SystemKey = builder.SystemKey(); + this.DoNotVersion = builder.DoNotVersion(); } /** @@ -57,13 +62,19 @@ public KeyManagementStrategy Strategy() { } /** - * @return Key Store Admin protects any non-cryptographic - * items stored with this Key. + * @return Optional. Defaults to TrustStorage. See System Key. */ public SystemKey SystemKey() { return this.SystemKey; } + /** + * @return Optional. Defaults to False. As of v1.8.0, setting this true throws an exception. + */ + public Boolean DoNotVersion() { + return this.DoNotVersion; + } + public Builder toBuilder() { return new BuilderImpl(this); } @@ -104,17 +115,25 @@ public interface Builder { KeyManagementStrategy Strategy(); /** - * @param SystemKey Key Store Admin protects any non-cryptographic - * items stored with this Key. + * @param SystemKey Optional. Defaults to TrustStorage. See System Key. */ Builder SystemKey(SystemKey SystemKey); /** - * @return Key Store Admin protects any non-cryptographic - * items stored with this Key. + * @return Optional. Defaults to TrustStorage. See System Key. */ SystemKey SystemKey(); + /** + * @param DoNotVersion Optional. Defaults to False. As of v1.8.0, setting this true throws an exception. + */ + Builder DoNotVersion(Boolean DoNotVersion); + + /** + * @return Optional. Defaults to False. As of v1.8.0, setting this true throws an exception. + */ + Boolean DoNotVersion(); + InitializeMutationInput build(); } @@ -128,6 +147,8 @@ static class BuilderImpl implements Builder { protected SystemKey SystemKey; + protected Boolean DoNotVersion; + protected BuilderImpl() {} protected BuilderImpl(InitializeMutationInput model) { @@ -135,6 +156,7 @@ protected BuilderImpl(InitializeMutationInput model) { this.Mutations = model.Mutations(); this.Strategy = model.Strategy(); this.SystemKey = model.SystemKey(); + this.DoNotVersion = model.DoNotVersion(); } public Builder Identifier(String Identifier) { @@ -173,6 +195,15 @@ public SystemKey SystemKey() { return this.SystemKey; } + public Builder DoNotVersion(Boolean DoNotVersion) { + this.DoNotVersion = DoNotVersion; + return this; + } + + public Boolean DoNotVersion() { + return this.DoNotVersion; + } + public InitializeMutationInput build() { if (Objects.isNull(this.Identifier())) { throw new IllegalArgumentException( @@ -184,11 +215,6 @@ public InitializeMutationInput build() { "Missing value for required field `Mutations`" ); } - if (Objects.isNull(this.SystemKey())) { - throw new IllegalArgumentException( - "Missing value for required field `SystemKey`" - ); - } return new InitializeMutationInput(this); } } diff --git a/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/MutationDescription.java b/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/MutationDescription.java new file mode 100644 index 000000000..7af4555c4 --- /dev/null +++ b/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/MutationDescription.java @@ -0,0 +1,191 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. +package software.amazon.cryptography.keystoreadmin.model; + +import java.util.Objects; + +public class MutationDescription { + + /** + * The original properities of the Branch Key. + */ + private final MutableBranchKeyProperities Original; + + /** + * The terminal properities of the Branch Key. + */ + private final MutableBranchKeyProperities Terminal; + + /** + * The input for this mutation. + */ + private final Mutations Input; + + /** + * String descprition of the System Key. + */ + private final String SystemKey; + + protected MutationDescription(BuilderImpl builder) { + this.Original = builder.Original(); + this.Terminal = builder.Terminal(); + this.Input = builder.Input(); + this.SystemKey = builder.SystemKey(); + } + + /** + * @return The original properities of the Branch Key. + */ + public MutableBranchKeyProperities Original() { + return this.Original; + } + + /** + * @return The terminal properities of the Branch Key. + */ + public MutableBranchKeyProperities Terminal() { + return this.Terminal; + } + + /** + * @return The input for this mutation. + */ + public Mutations Input() { + return this.Input; + } + + /** + * @return String descprition of the System Key. + */ + public String SystemKey() { + return this.SystemKey; + } + + public Builder toBuilder() { + return new BuilderImpl(this); + } + + public static Builder builder() { + return new BuilderImpl(); + } + + public interface Builder { + /** + * @param Original The original properities of the Branch Key. + */ + Builder Original(MutableBranchKeyProperities Original); + + /** + * @return The original properities of the Branch Key. + */ + MutableBranchKeyProperities Original(); + + /** + * @param Terminal The terminal properities of the Branch Key. + */ + Builder Terminal(MutableBranchKeyProperities Terminal); + + /** + * @return The terminal properities of the Branch Key. + */ + MutableBranchKeyProperities Terminal(); + + /** + * @param Input The input for this mutation. + */ + Builder Input(Mutations Input); + + /** + * @return The input for this mutation. + */ + Mutations Input(); + + /** + * @param SystemKey String descprition of the System Key. + */ + Builder SystemKey(String SystemKey); + + /** + * @return String descprition of the System Key. + */ + String SystemKey(); + + MutationDescription build(); + } + + static class BuilderImpl implements Builder { + + protected MutableBranchKeyProperities Original; + + protected MutableBranchKeyProperities Terminal; + + protected Mutations Input; + + protected String SystemKey; + + protected BuilderImpl() {} + + protected BuilderImpl(MutationDescription model) { + this.Original = model.Original(); + this.Terminal = model.Terminal(); + this.Input = model.Input(); + this.SystemKey = model.SystemKey(); + } + + public Builder Original(MutableBranchKeyProperities Original) { + this.Original = Original; + return this; + } + + public MutableBranchKeyProperities Original() { + return this.Original; + } + + public Builder Terminal(MutableBranchKeyProperities Terminal) { + this.Terminal = Terminal; + return this; + } + + public MutableBranchKeyProperities Terminal() { + return this.Terminal; + } + + public Builder Input(Mutations Input) { + this.Input = Input; + return this; + } + + public Mutations Input() { + return this.Input; + } + + public Builder SystemKey(String SystemKey) { + this.SystemKey = SystemKey; + return this; + } + + public String SystemKey() { + return this.SystemKey; + } + + public MutationDescription build() { + if (Objects.isNull(this.Original())) { + throw new IllegalArgumentException( + "Missing value for required field `Original`" + ); + } + if (Objects.isNull(this.Terminal())) { + throw new IllegalArgumentException( + "Missing value for required field `Terminal`" + ); + } + if (Objects.isNull(this.Input())) { + throw new IllegalArgumentException( + "Missing value for required field `Input`" + ); + } + return new MutationDescription(this); + } + } +} diff --git a/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/MutationInFlight.java b/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/MutationInFlight.java new file mode 100644 index 000000000..c88899e29 --- /dev/null +++ b/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/MutationInFlight.java @@ -0,0 +1,104 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. +package software.amazon.cryptography.keystoreadmin.model; + +import java.util.Objects; + +/** + * If a Mutation is In Flight for this Branch Key. + */ +public class MutationInFlight { + + private final MutationDescription Yes; + + private final String No; + + protected MutationInFlight(BuilderImpl builder) { + this.Yes = builder.Yes(); + this.No = builder.No(); + } + + public MutationDescription Yes() { + return this.Yes; + } + + public String No() { + return this.No; + } + + public Builder toBuilder() { + return new BuilderImpl(this); + } + + public static Builder builder() { + return new BuilderImpl(); + } + + public interface Builder { + Builder Yes(MutationDescription Yes); + + MutationDescription Yes(); + + Builder No(String No); + + String No(); + + MutationInFlight build(); + } + + static class BuilderImpl implements Builder { + + protected MutationDescription Yes; + + protected String No; + + protected BuilderImpl() {} + + protected BuilderImpl(MutationInFlight model) { + this.Yes = model.Yes(); + this.No = model.No(); + } + + public Builder Yes(MutationDescription Yes) { + this.Yes = Yes; + return this; + } + + public MutationDescription Yes() { + return this.Yes; + } + + public Builder No(String No) { + this.No = No; + return this; + } + + public String No() { + return this.No; + } + + public MutationInFlight build() { + if (!onlyOneNonNull()) { + throw new IllegalArgumentException( + "`MutationInFlight` is a Union. A Union MUST have one and only one value set." + ); + } + return new MutationInFlight(this); + } + + private boolean onlyOneNonNull() { + Object[] allValues = { this.Yes, this.No }; + boolean haveOneNonNull = false; + for (Object o : allValues) { + if (Objects.nonNull(o)) { + if (haveOneNonNull) { + return false; + } + haveOneNonNull = true; + } + } + return haveOneNonNull; + } + } +} diff --git a/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/SystemKey.java b/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/SystemKey.java index b2a3b9824..42d766faa 100644 --- a/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/SystemKey.java +++ b/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/SystemKey.java @@ -8,6 +8,7 @@ /** * Key Store Admin protects any non-cryptographic * items stored with this Key. + * As of v1.8.0, TrustStorage is the default behavior. */ public class SystemKey { diff --git a/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/UnsupportedFeatureException.java b/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/UnsupportedFeatureException.java new file mode 100644 index 000000000..c11857f1e --- /dev/null +++ b/AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystoreadmin/model/UnsupportedFeatureException.java @@ -0,0 +1,113 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. +package software.amazon.cryptography.keystoreadmin.model; + +import java.util.Objects; + +/** + * This feature is not yet implemented. + */ +public class UnsupportedFeatureException extends RuntimeException { + + protected UnsupportedFeatureException(BuilderImpl builder) { + super(messageFromBuilder(builder), builder.cause()); + } + + private static String messageFromBuilder(Builder builder) { + if (builder.message() != null) { + return builder.message(); + } + if (builder.cause() != null) { + return builder.cause().getMessage(); + } + return null; + } + + /** + * See {@link Throwable#getMessage()}. + */ + public String message() { + return this.getMessage(); + } + + /** + * See {@link Throwable#getCause()}. + */ + public Throwable cause() { + return this.getCause(); + } + + public Builder toBuilder() { + return new BuilderImpl(this); + } + + public static Builder builder() { + return new BuilderImpl(); + } + + public interface Builder { + /** + * @param message The detailed message. The detail message is saved for later retrieval by the {@link #getMessage()} method. + */ + Builder message(String message); + + /** + * @return The detailed message. The detail message is saved for later retrieval by the {@link #getMessage()} method. + */ + String message(); + + /** + * @param cause The cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is permitted, and indicates that the cause is nonexistent or unknown.) + */ + Builder cause(Throwable cause); + + /** + * @return The cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is permitted, and indicates that the cause is nonexistent or unknown.) + */ + Throwable cause(); + + UnsupportedFeatureException build(); + } + + static class BuilderImpl implements Builder { + + protected String message; + + protected Throwable cause; + + protected BuilderImpl() {} + + protected BuilderImpl(UnsupportedFeatureException model) { + this.message = model.message(); + this.cause = model.cause(); + } + + public Builder message(String message) { + this.message = message; + return this; + } + + public String message() { + return this.message; + } + + public Builder cause(Throwable cause) { + this.cause = cause; + return this; + } + + public Throwable cause() { + return this.cause; + } + + public UnsupportedFeatureException build() { + if (Objects.isNull(this.message())) { + throw new IllegalArgumentException( + "Missing value for required field `message`" + ); + } + return new UnsupportedFeatureException(this); + } + } +} diff --git a/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/ApplyMutationInput.cs b/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/ApplyMutationInput.cs index 00d53d23a..d8e50b349 100644 --- a/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/ApplyMutationInput.cs +++ b/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/ApplyMutationInput.cs @@ -50,7 +50,6 @@ public bool IsSetSystemKey() public void Validate() { if (!IsSetMutationToken()) throw new System.ArgumentException("Missing value for required property 'MutationToken'"); - if (!IsSetSystemKey()) throw new System.ArgumentException("Missing value for required property 'SystemKey'"); } } diff --git a/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/DescribeMutationOutput.cs b/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/DescribeMutationOutput.cs index 63a9b856f..49bd08486 100644 --- a/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/DescribeMutationOutput.cs +++ b/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/DescribeMutationOutput.cs @@ -7,28 +7,19 @@ namespace AWS.Cryptography.KeyStoreAdmin { public class DescribeMutationOutput { - private AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities _original; - private AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities _terminal; - public AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities Original + private AWS.Cryptography.KeyStoreAdmin.MutationInFlight _mutationInFlight; + public AWS.Cryptography.KeyStoreAdmin.MutationInFlight MutationInFlight { - get { return this._original; } - set { this._original = value; } + get { return this._mutationInFlight; } + set { this._mutationInFlight = value; } } - public bool IsSetOriginal() + public bool IsSetMutationInFlight() { - return this._original != null; - } - public AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities Terminal - { - get { return this._terminal; } - set { this._terminal = value; } - } - public bool IsSetTerminal() - { - return this._terminal != null; + return this._mutationInFlight != null; } public void Validate() { + if (!IsSetMutationInFlight()) throw new System.ArgumentException("Missing value for required property 'MutationInFlight'"); } } diff --git a/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/InitializeMutationFlag.cs b/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/InitializeMutationFlag.cs index 96b844765..9d979b8cc 100644 --- a/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/InitializeMutationFlag.cs +++ b/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/InitializeMutationFlag.cs @@ -5,47 +5,19 @@ using AWS.Cryptography.KeyStoreAdmin; namespace AWS.Cryptography.KeyStoreAdmin { - public class InitializeMutationFlag + using Amazon.Runtime; + public class InitializeMutationFlag : ConstantClass { - private string _created; - private string _resumed; - private string _resumedWithoutIndex; - public string Created - { - get { return this._created; } - set { this._created = value; } - } - public bool IsSetCreated() - { - return this._created != null; - } - public string Resumed - { - get { return this._resumed; } - set { this._resumed = value; } - } - public bool IsSetResumed() - { - return this._resumed != null; - } - public string ResumedWithoutIndex - { - get { return this._resumedWithoutIndex; } - set { this._resumedWithoutIndex = value; } - } - public bool IsSetResumedWithoutIndex() - { - return this._resumedWithoutIndex != null; - } - public void Validate() - { - var numberOfPropertiesSet = Convert.ToUInt16(IsSetCreated()) + - Convert.ToUInt16(IsSetResumed()) + - Convert.ToUInt16(IsSetResumedWithoutIndex()); - if (numberOfPropertiesSet == 0) throw new System.ArgumentException("No union value set"); - if (numberOfPropertiesSet > 1) throw new System.ArgumentException("Multiple union values set"); - } + public static readonly InitializeMutationFlag Created = new InitializeMutationFlag("Created"); + + public static readonly InitializeMutationFlag Resumed = new InitializeMutationFlag("Resumed"); + + public static readonly InitializeMutationFlag ResumedWithoutIndex = new InitializeMutationFlag("ResumedWithoutIndex"); + public static readonly InitializeMutationFlag[] Values = { + Created , Resumed , ResumedWithoutIndex +}; + public InitializeMutationFlag(string value) : base(value) { } } } diff --git a/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/InitializeMutationInput.cs b/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/InitializeMutationInput.cs index 7b0d8ab96..26d2be684 100644 --- a/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/InitializeMutationInput.cs +++ b/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/InitializeMutationInput.cs @@ -11,6 +11,7 @@ public class InitializeMutationInput private AWS.Cryptography.KeyStoreAdmin.Mutations _mutations; private AWS.Cryptography.KeyStoreAdmin.KeyManagementStrategy _strategy; private AWS.Cryptography.KeyStoreAdmin.SystemKey _systemKey; + private bool? _doNotVersion; public string Identifier { get { return this._identifier; } @@ -47,11 +48,19 @@ public bool IsSetSystemKey() { return this._systemKey != null; } + public bool DoNotVersion + { + get { return this._doNotVersion.GetValueOrDefault(); } + set { this._doNotVersion = value; } + } + public bool IsSetDoNotVersion() + { + return this._doNotVersion.HasValue; + } public void Validate() { if (!IsSetIdentifier()) throw new System.ArgumentException("Missing value for required property 'Identifier'"); if (!IsSetMutations()) throw new System.ArgumentException("Missing value for required property 'Mutations'"); - if (!IsSetSystemKey()) throw new System.ArgumentException("Missing value for required property 'SystemKey'"); } } diff --git a/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/MutationDescription.cs b/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/MutationDescription.cs new file mode 100644 index 000000000..7b738c540 --- /dev/null +++ b/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/MutationDescription.cs @@ -0,0 +1,58 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. +using System; +using AWS.Cryptography.KeyStoreAdmin; +namespace AWS.Cryptography.KeyStoreAdmin +{ + public class MutationDescription + { + private AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities _original; + private AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities _terminal; + private AWS.Cryptography.KeyStoreAdmin.Mutations _input; + private string _systemKey; + public AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities Original + { + get { return this._original; } + set { this._original = value; } + } + public bool IsSetOriginal() + { + return this._original != null; + } + public AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities Terminal + { + get { return this._terminal; } + set { this._terminal = value; } + } + public bool IsSetTerminal() + { + return this._terminal != null; + } + public AWS.Cryptography.KeyStoreAdmin.Mutations Input + { + get { return this._input; } + set { this._input = value; } + } + public bool IsSetInput() + { + return this._input != null; + } + public string SystemKey + { + get { return this._systemKey; } + set { this._systemKey = value; } + } + public bool IsSetSystemKey() + { + return this._systemKey != null; + } + public void Validate() + { + if (!IsSetOriginal()) throw new System.ArgumentException("Missing value for required property 'Original'"); + if (!IsSetTerminal()) throw new System.ArgumentException("Missing value for required property 'Terminal'"); + if (!IsSetInput()) throw new System.ArgumentException("Missing value for required property 'Input'"); + + } + } +} diff --git a/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/MutationInFlight.cs b/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/MutationInFlight.cs new file mode 100644 index 000000000..bd2887805 --- /dev/null +++ b/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/MutationInFlight.cs @@ -0,0 +1,40 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. +using System; +using AWS.Cryptography.KeyStoreAdmin; +namespace AWS.Cryptography.KeyStoreAdmin +{ + public class MutationInFlight + { + private AWS.Cryptography.KeyStoreAdmin.MutationDescription _yes; + private string _no; + public AWS.Cryptography.KeyStoreAdmin.MutationDescription Yes + { + get { return this._yes; } + set { this._yes = value; } + } + public bool IsSetYes() + { + return this._yes != null; + } + public string No + { + get { return this._no; } + set { this._no = value; } + } + public bool IsSetNo() + { + return this._no != null; + } + public void Validate() + { + var numberOfPropertiesSet = Convert.ToUInt16(IsSetYes()) + + Convert.ToUInt16(IsSetNo()); + if (numberOfPropertiesSet == 0) throw new System.ArgumentException("No union value set"); + + if (numberOfPropertiesSet > 1) throw new System.ArgumentException("Multiple union values set"); + + } + } +} diff --git a/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/TypeConversion.cs b/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/TypeConversion.cs index 10cac9f4b..52e7248eb 100644 --- a/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/TypeConversion.cs +++ b/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/TypeConversion.cs @@ -16,14 +16,15 @@ public static AWS.Cryptography.KeyStoreAdmin.ApplyMutationInput FromDafny_N3_aws software.amazon.cryptography.keystoreadmin.internaldafny.types.ApplyMutationInput concrete = (software.amazon.cryptography.keystoreadmin.internaldafny.types.ApplyMutationInput)value; AWS.Cryptography.KeyStoreAdmin.ApplyMutationInput converted = new AWS.Cryptography.KeyStoreAdmin.ApplyMutationInput(); converted.MutationToken = (AWS.Cryptography.KeyStoreAdmin.MutationToken)FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S18_ApplyMutationInput__M13_MutationToken(concrete._MutationToken); if (concrete._PageSize.is_Some) converted.PageSize = (int)FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S18_ApplyMutationInput__M8_PageSize(concrete._PageSize); if (concrete._Strategy.is_Some) converted.Strategy = (AWS.Cryptography.KeyStoreAdmin.KeyManagementStrategy)FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S18_ApplyMutationInput__M8_Strategy(concrete._Strategy); - converted.SystemKey = (AWS.Cryptography.KeyStoreAdmin.SystemKey)FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S18_ApplyMutationInput__M9_SystemKey(concrete._SystemKey); return converted; + if (concrete._SystemKey.is_Some) converted.SystemKey = (AWS.Cryptography.KeyStoreAdmin.SystemKey)FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S18_ApplyMutationInput__M9_SystemKey(concrete._SystemKey); return converted; } public static software.amazon.cryptography.keystoreadmin.internaldafny.types._IApplyMutationInput ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S18_ApplyMutationInput(AWS.Cryptography.KeyStoreAdmin.ApplyMutationInput value) { value.Validate(); int? var_pageSize = value.IsSetPageSize() ? value.PageSize : (int?)null; AWS.Cryptography.KeyStoreAdmin.KeyManagementStrategy var_strategy = value.IsSetStrategy() ? value.Strategy : (AWS.Cryptography.KeyStoreAdmin.KeyManagementStrategy)null; - return new software.amazon.cryptography.keystoreadmin.internaldafny.types.ApplyMutationInput(ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S18_ApplyMutationInput__M13_MutationToken(value.MutationToken), ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S18_ApplyMutationInput__M8_PageSize(var_pageSize), ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S18_ApplyMutationInput__M8_Strategy(var_strategy), ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S18_ApplyMutationInput__M9_SystemKey(value.SystemKey)); + AWS.Cryptography.KeyStoreAdmin.SystemKey var_systemKey = value.IsSetSystemKey() ? value.SystemKey : (AWS.Cryptography.KeyStoreAdmin.SystemKey)null; + return new software.amazon.cryptography.keystoreadmin.internaldafny.types.ApplyMutationInput(ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S18_ApplyMutationInput__M13_MutationToken(value.MutationToken), ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S18_ApplyMutationInput__M8_PageSize(var_pageSize), ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S18_ApplyMutationInput__M8_Strategy(var_strategy), ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S18_ApplyMutationInput__M9_SystemKey(var_systemKey)); } public static AWS.Cryptography.KeyStoreAdmin.ApplyMutationOutput FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S19_ApplyMutationOutput(software.amazon.cryptography.keystoreadmin.internaldafny.types._IApplyMutationOutput value) { @@ -100,64 +101,43 @@ public static software.amazon.cryptography.keystoreadmin.internaldafny.types._ID } public static AWS.Cryptography.KeyStoreAdmin.DescribeMutationOutput FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_DescribeMutationOutput(software.amazon.cryptography.keystoreadmin.internaldafny.types._IDescribeMutationOutput value) { - software.amazon.cryptography.keystoreadmin.internaldafny.types.DescribeMutationOutput concrete = (software.amazon.cryptography.keystoreadmin.internaldafny.types.DescribeMutationOutput)value; AWS.Cryptography.KeyStoreAdmin.DescribeMutationOutput converted = new AWS.Cryptography.KeyStoreAdmin.DescribeMutationOutput(); if (concrete._Original.is_Some) converted.Original = (AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities)FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_DescribeMutationOutput__M8_Original(concrete._Original); - if (concrete._Terminal.is_Some) converted.Terminal = (AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities)FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_DescribeMutationOutput__M8_Terminal(concrete._Terminal); return converted; + software.amazon.cryptography.keystoreadmin.internaldafny.types.DescribeMutationOutput concrete = (software.amazon.cryptography.keystoreadmin.internaldafny.types.DescribeMutationOutput)value; AWS.Cryptography.KeyStoreAdmin.DescribeMutationOutput converted = new AWS.Cryptography.KeyStoreAdmin.DescribeMutationOutput(); converted.MutationInFlight = (AWS.Cryptography.KeyStoreAdmin.MutationInFlight)FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_DescribeMutationOutput__M16_MutationInFlight(concrete._MutationInFlight); return converted; } public static software.amazon.cryptography.keystoreadmin.internaldafny.types._IDescribeMutationOutput ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_DescribeMutationOutput(AWS.Cryptography.KeyStoreAdmin.DescribeMutationOutput value) { value.Validate(); - AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities var_original = value.IsSetOriginal() ? value.Original : (AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities)null; - AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities var_terminal = value.IsSetTerminal() ? value.Terminal : (AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities)null; - return new software.amazon.cryptography.keystoreadmin.internaldafny.types.DescribeMutationOutput(ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_DescribeMutationOutput__M8_Original(var_original), ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_DescribeMutationOutput__M8_Terminal(var_terminal)); + + return new software.amazon.cryptography.keystoreadmin.internaldafny.types.DescribeMutationOutput(ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_DescribeMutationOutput__M16_MutationInFlight(value.MutationInFlight)); } public static AWS.Cryptography.KeyStoreAdmin.InitializeMutationFlag FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_InitializeMutationFlag(software.amazon.cryptography.keystoreadmin.internaldafny.types._IInitializeMutationFlag value) { - software.amazon.cryptography.keystoreadmin.internaldafny.types.InitializeMutationFlag concrete = (software.amazon.cryptography.keystoreadmin.internaldafny.types.InitializeMutationFlag)value; - var converted = new AWS.Cryptography.KeyStoreAdmin.InitializeMutationFlag(); if (value.is_Created) - { - converted.Created = FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_InitializeMutationFlag__M7_Created(concrete.dtor_Created); - return converted; - } - if (value.is_Resumed) - { - converted.Resumed = FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_InitializeMutationFlag__M7_Resumed(concrete.dtor_Resumed); - return converted; - } - if (value.is_ResumedWithoutIndex) - { - converted.ResumedWithoutIndex = FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_InitializeMutationFlag__M19_ResumedWithoutIndex(concrete.dtor_ResumedWithoutIndex); - return converted; - } - throw new System.ArgumentException("Invalid AWS.Cryptography.KeyStoreAdmin.InitializeMutationFlag state"); + if (value.is_Created) return AWS.Cryptography.KeyStoreAdmin.InitializeMutationFlag.Created; + if (value.is_Resumed) return AWS.Cryptography.KeyStoreAdmin.InitializeMutationFlag.Resumed; + if (value.is_ResumedWithoutIndex) return AWS.Cryptography.KeyStoreAdmin.InitializeMutationFlag.ResumedWithoutIndex; + throw new System.ArgumentException("Invalid AWS.Cryptography.KeyStoreAdmin.InitializeMutationFlag value"); } public static software.amazon.cryptography.keystoreadmin.internaldafny.types._IInitializeMutationFlag ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_InitializeMutationFlag(AWS.Cryptography.KeyStoreAdmin.InitializeMutationFlag value) { - value.Validate(); if (value.IsSetCreated()) - { - return software.amazon.cryptography.keystoreadmin.internaldafny.types.InitializeMutationFlag.create_Created(ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_InitializeMutationFlag__M7_Created(value.Created)); - } - if (value.IsSetResumed()) - { - return software.amazon.cryptography.keystoreadmin.internaldafny.types.InitializeMutationFlag.create_Resumed(ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_InitializeMutationFlag__M7_Resumed(value.Resumed)); - } - if (value.IsSetResumedWithoutIndex()) - { - return software.amazon.cryptography.keystoreadmin.internaldafny.types.InitializeMutationFlag.create_ResumedWithoutIndex(ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_InitializeMutationFlag__M19_ResumedWithoutIndex(value.ResumedWithoutIndex)); - } - throw new System.ArgumentException("Invalid AWS.Cryptography.KeyStoreAdmin.InitializeMutationFlag state"); + if (AWS.Cryptography.KeyStoreAdmin.InitializeMutationFlag.Created.Equals(value)) return software.amazon.cryptography.keystoreadmin.internaldafny.types.InitializeMutationFlag.create_Created(); + if (AWS.Cryptography.KeyStoreAdmin.InitializeMutationFlag.Resumed.Equals(value)) return software.amazon.cryptography.keystoreadmin.internaldafny.types.InitializeMutationFlag.create_Resumed(); + if (AWS.Cryptography.KeyStoreAdmin.InitializeMutationFlag.ResumedWithoutIndex.Equals(value)) return software.amazon.cryptography.keystoreadmin.internaldafny.types.InitializeMutationFlag.create_ResumedWithoutIndex(); + throw new System.ArgumentException("Invalid AWS.Cryptography.KeyStoreAdmin.InitializeMutationFlag value"); } public static AWS.Cryptography.KeyStoreAdmin.InitializeMutationInput FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S23_InitializeMutationInput(software.amazon.cryptography.keystoreadmin.internaldafny.types._IInitializeMutationInput value) { software.amazon.cryptography.keystoreadmin.internaldafny.types.InitializeMutationInput concrete = (software.amazon.cryptography.keystoreadmin.internaldafny.types.InitializeMutationInput)value; AWS.Cryptography.KeyStoreAdmin.InitializeMutationInput converted = new AWS.Cryptography.KeyStoreAdmin.InitializeMutationInput(); converted.Identifier = (string)FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S23_InitializeMutationInput__M10_Identifier(concrete._Identifier); converted.Mutations = (AWS.Cryptography.KeyStoreAdmin.Mutations)FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S23_InitializeMutationInput__M9_Mutations(concrete._Mutations); if (concrete._Strategy.is_Some) converted.Strategy = (AWS.Cryptography.KeyStoreAdmin.KeyManagementStrategy)FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S23_InitializeMutationInput__M8_Strategy(concrete._Strategy); - converted.SystemKey = (AWS.Cryptography.KeyStoreAdmin.SystemKey)FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S23_InitializeMutationInput__M9_SystemKey(concrete._SystemKey); return converted; + if (concrete._SystemKey.is_Some) converted.SystemKey = (AWS.Cryptography.KeyStoreAdmin.SystemKey)FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S23_InitializeMutationInput__M9_SystemKey(concrete._SystemKey); + if (concrete._DoNotVersion.is_Some) converted.DoNotVersion = (bool)FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S23_InitializeMutationInput__M12_DoNotVersion(concrete._DoNotVersion); return converted; } public static software.amazon.cryptography.keystoreadmin.internaldafny.types._IInitializeMutationInput ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S23_InitializeMutationInput(AWS.Cryptography.KeyStoreAdmin.InitializeMutationInput value) { value.Validate(); AWS.Cryptography.KeyStoreAdmin.KeyManagementStrategy var_strategy = value.IsSetStrategy() ? value.Strategy : (AWS.Cryptography.KeyStoreAdmin.KeyManagementStrategy)null; - return new software.amazon.cryptography.keystoreadmin.internaldafny.types.InitializeMutationInput(ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S23_InitializeMutationInput__M10_Identifier(value.Identifier), ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S23_InitializeMutationInput__M9_Mutations(value.Mutations), ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S23_InitializeMutationInput__M8_Strategy(var_strategy), ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S23_InitializeMutationInput__M9_SystemKey(value.SystemKey)); + AWS.Cryptography.KeyStoreAdmin.SystemKey var_systemKey = value.IsSetSystemKey() ? value.SystemKey : (AWS.Cryptography.KeyStoreAdmin.SystemKey)null; + bool? var_doNotVersion = value.IsSetDoNotVersion() ? value.DoNotVersion : (bool?)null; + return new software.amazon.cryptography.keystoreadmin.internaldafny.types.InitializeMutationInput(ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S23_InitializeMutationInput__M10_Identifier(value.Identifier), ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S23_InitializeMutationInput__M9_Mutations(value.Mutations), ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S23_InitializeMutationInput__M8_Strategy(var_strategy), ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S23_InitializeMutationInput__M9_SystemKey(var_systemKey), ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S23_InitializeMutationInput__M12_DoNotVersion(var_doNotVersion)); } public static AWS.Cryptography.KeyStoreAdmin.InitializeMutationOutput FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S24_InitializeMutationOutput(software.amazon.cryptography.keystoreadmin.internaldafny.types._IInitializeMutationOutput value) { @@ -266,6 +246,33 @@ public static software.amazon.cryptography.keystoreadmin.internaldafny.types.Err ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S21_MutationFromException__M7_message(value.Message) ); } + public static AWS.Cryptography.KeyStoreAdmin.MutationInFlight FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S16_MutationInFlight(software.amazon.cryptography.keystoreadmin.internaldafny.types._IMutationInFlight value) + { + software.amazon.cryptography.keystoreadmin.internaldafny.types.MutationInFlight concrete = (software.amazon.cryptography.keystoreadmin.internaldafny.types.MutationInFlight)value; + var converted = new AWS.Cryptography.KeyStoreAdmin.MutationInFlight(); if (value.is_Yes) + { + converted.Yes = FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S16_MutationInFlight__M3_Yes(concrete.dtor_Yes); + return converted; + } + if (value.is_No) + { + converted.No = FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S16_MutationInFlight__M2_No(concrete.dtor_No); + return converted; + } + throw new System.ArgumentException("Invalid AWS.Cryptography.KeyStoreAdmin.MutationInFlight state"); + } + public static software.amazon.cryptography.keystoreadmin.internaldafny.types._IMutationInFlight ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S16_MutationInFlight(AWS.Cryptography.KeyStoreAdmin.MutationInFlight value) + { + value.Validate(); if (value.IsSetYes()) + { + return software.amazon.cryptography.keystoreadmin.internaldafny.types.MutationInFlight.create_Yes(ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S16_MutationInFlight__M3_Yes(value.Yes)); + } + if (value.IsSetNo()) + { + return software.amazon.cryptography.keystoreadmin.internaldafny.types.MutationInFlight.create_No(ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S16_MutationInFlight__M2_No(value.No)); + } + throw new System.ArgumentException("Invalid AWS.Cryptography.KeyStoreAdmin.MutationInFlight state"); + } public static AWS.Cryptography.KeyStoreAdmin.MutationInvalidException FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S24_MutationInvalidException(software.amazon.cryptography.keystoreadmin.internaldafny.types.Error_MutationInvalidException value) { return new AWS.Cryptography.KeyStoreAdmin.MutationInvalidException( @@ -358,6 +365,19 @@ public static software.amazon.cryptography.keystoreadmin.internaldafny.types.Err ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S24_UnexpectedStateException__M7_message(value.Message) ); } + public static AWS.Cryptography.KeyStoreAdmin.UnsupportedFeatureException FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_UnsupportedFeatureException(software.amazon.cryptography.keystoreadmin.internaldafny.types.Error_UnsupportedFeatureException value) + { + return new AWS.Cryptography.KeyStoreAdmin.UnsupportedFeatureException( + FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_UnsupportedFeatureException__M7_message(value._message) + ); + } + public static software.amazon.cryptography.keystoreadmin.internaldafny.types.Error_UnsupportedFeatureException ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_UnsupportedFeatureException(AWS.Cryptography.KeyStoreAdmin.UnsupportedFeatureException value) + { + + return new software.amazon.cryptography.keystoreadmin.internaldafny.types.Error_UnsupportedFeatureException( + ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_UnsupportedFeatureException__M7_message(value.Message) + ); + } public static AWS.Cryptography.KeyStoreAdmin.VersionKeyInput FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S15_VersionKeyInput(software.amazon.cryptography.keystoreadmin.internaldafny.types._IVersionKeyInput value) { software.amazon.cryptography.keystoreadmin.internaldafny.types.VersionKeyInput concrete = (software.amazon.cryptography.keystoreadmin.internaldafny.types.VersionKeyInput)value; AWS.Cryptography.KeyStoreAdmin.VersionKeyInput converted = new AWS.Cryptography.KeyStoreAdmin.VersionKeyInput(); converted.Identifier = (string)FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S15_VersionKeyInput__M10_Identifier(concrete._Identifier); @@ -404,13 +424,13 @@ public static AWS.Cryptography.KeyStoreAdmin.KeyManagementStrategy FromDafny_N3_ { return value == null ? Wrappers_Compile.Option.create_None() : Wrappers_Compile.Option.create_Some(ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S21_KeyManagementStrategy((AWS.Cryptography.KeyStoreAdmin.KeyManagementStrategy)value)); } - public static AWS.Cryptography.KeyStoreAdmin.SystemKey FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S18_ApplyMutationInput__M9_SystemKey(software.amazon.cryptography.keystoreadmin.internaldafny.types._ISystemKey value) + public static AWS.Cryptography.KeyStoreAdmin.SystemKey FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S18_ApplyMutationInput__M9_SystemKey(Wrappers_Compile._IOption value) { - return FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S9_SystemKey(value); + return value.is_None ? (AWS.Cryptography.KeyStoreAdmin.SystemKey)null : FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S9_SystemKey(value.Extract()); } - public static software.amazon.cryptography.keystoreadmin.internaldafny.types._ISystemKey ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S18_ApplyMutationInput__M9_SystemKey(AWS.Cryptography.KeyStoreAdmin.SystemKey value) + public static Wrappers_Compile._IOption ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S18_ApplyMutationInput__M9_SystemKey(AWS.Cryptography.KeyStoreAdmin.SystemKey value) { - return ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S9_SystemKey(value); + return value == null ? Wrappers_Compile.Option.create_None() : Wrappers_Compile.Option.create_Some(ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S9_SystemKey((AWS.Cryptography.KeyStoreAdmin.SystemKey)value)); } public static AWS.Cryptography.KeyStoreAdmin.ApplyMutationResult FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S19_ApplyMutationOutput__M14_MutationResult(software.amazon.cryptography.keystoreadmin.internaldafny.types._IApplyMutationResult value) { @@ -492,45 +512,13 @@ public static Dafny.ISequence ToDafny_N3_aws__N12_cryptography__N13_keySto { return ToDafny_N6_smithy__N3_api__S6_String(value); } - public static AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_DescribeMutationOutput__M8_Original(Wrappers_Compile._IOption value) - { - return value.is_None ? (AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities)null : FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities(value.Extract()); - } - public static Wrappers_Compile._IOption ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_DescribeMutationOutput__M8_Original(AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities value) - { - return value == null ? Wrappers_Compile.Option.create_None() : Wrappers_Compile.Option.create_Some(ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities((AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities)value)); - } - public static AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_DescribeMutationOutput__M8_Terminal(Wrappers_Compile._IOption value) - { - return value.is_None ? (AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities)null : FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities(value.Extract()); - } - public static Wrappers_Compile._IOption ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_DescribeMutationOutput__M8_Terminal(AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities value) - { - return value == null ? Wrappers_Compile.Option.create_None() : Wrappers_Compile.Option.create_Some(ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities((AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities)value)); - } - public static string FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_InitializeMutationFlag__M7_Created(Dafny.ISequence value) - { - return FromDafny_N6_smithy__N3_api__S6_String(value); - } - public static Dafny.ISequence ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_InitializeMutationFlag__M7_Created(string value) - { - return ToDafny_N6_smithy__N3_api__S6_String(value); - } - public static string FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_InitializeMutationFlag__M7_Resumed(Dafny.ISequence value) + public static AWS.Cryptography.KeyStoreAdmin.MutationInFlight FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_DescribeMutationOutput__M16_MutationInFlight(software.amazon.cryptography.keystoreadmin.internaldafny.types._IMutationInFlight value) { - return FromDafny_N6_smithy__N3_api__S6_String(value); + return FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S16_MutationInFlight(value); } - public static Dafny.ISequence ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_InitializeMutationFlag__M7_Resumed(string value) + public static software.amazon.cryptography.keystoreadmin.internaldafny.types._IMutationInFlight ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_DescribeMutationOutput__M16_MutationInFlight(AWS.Cryptography.KeyStoreAdmin.MutationInFlight value) { - return ToDafny_N6_smithy__N3_api__S6_String(value); - } - public static string FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_InitializeMutationFlag__M19_ResumedWithoutIndex(Dafny.ISequence value) - { - return FromDafny_N6_smithy__N3_api__S6_String(value); - } - public static Dafny.ISequence ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S22_InitializeMutationFlag__M19_ResumedWithoutIndex(string value) - { - return ToDafny_N6_smithy__N3_api__S6_String(value); + return ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S16_MutationInFlight(value); } public static string FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S23_InitializeMutationInput__M10_Identifier(Dafny.ISequence value) { @@ -556,13 +544,21 @@ public static AWS.Cryptography.KeyStoreAdmin.KeyManagementStrategy FromDafny_N3_ { return value == null ? Wrappers_Compile.Option.create_None() : Wrappers_Compile.Option.create_Some(ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S21_KeyManagementStrategy((AWS.Cryptography.KeyStoreAdmin.KeyManagementStrategy)value)); } - public static AWS.Cryptography.KeyStoreAdmin.SystemKey FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S23_InitializeMutationInput__M9_SystemKey(software.amazon.cryptography.keystoreadmin.internaldafny.types._ISystemKey value) + public static AWS.Cryptography.KeyStoreAdmin.SystemKey FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S23_InitializeMutationInput__M9_SystemKey(Wrappers_Compile._IOption value) { - return FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S9_SystemKey(value); + return value.is_None ? (AWS.Cryptography.KeyStoreAdmin.SystemKey)null : FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S9_SystemKey(value.Extract()); } - public static software.amazon.cryptography.keystoreadmin.internaldafny.types._ISystemKey ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S23_InitializeMutationInput__M9_SystemKey(AWS.Cryptography.KeyStoreAdmin.SystemKey value) + public static Wrappers_Compile._IOption ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S23_InitializeMutationInput__M9_SystemKey(AWS.Cryptography.KeyStoreAdmin.SystemKey value) { - return ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S9_SystemKey(value); + return value == null ? Wrappers_Compile.Option.create_None() : Wrappers_Compile.Option.create_Some(ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S9_SystemKey((AWS.Cryptography.KeyStoreAdmin.SystemKey)value)); + } + public static bool? FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S23_InitializeMutationInput__M12_DoNotVersion(Wrappers_Compile._IOption value) + { + return value.is_None ? (bool?)null : FromDafny_N6_smithy__N3_api__S7_Boolean(value.Extract()); + } + public static Wrappers_Compile._IOption ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S23_InitializeMutationInput__M12_DoNotVersion(bool? value) + { + return value == null ? Wrappers_Compile.Option.create_None() : Wrappers_Compile.Option.create_Some(ToDafny_N6_smithy__N3_api__S7_Boolean((bool)value)); } public static AWS.Cryptography.KeyStoreAdmin.MutationToken FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S24_InitializeMutationOutput__M13_MutationToken(software.amazon.cryptography.keystoreadmin.internaldafny.types._IMutationToken value) { @@ -652,6 +648,22 @@ public static Dafny.ISequence ToDafny_N3_aws__N12_cryptography__N13_keySto { return ToDafny_N6_smithy__N3_api__S6_String(value); } + public static AWS.Cryptography.KeyStoreAdmin.MutationDescription FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S16_MutationInFlight__M3_Yes(software.amazon.cryptography.keystoreadmin.internaldafny.types._IMutationDescription value) + { + return FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S19_MutationDescription(value); + } + public static software.amazon.cryptography.keystoreadmin.internaldafny.types._IMutationDescription ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S16_MutationInFlight__M3_Yes(AWS.Cryptography.KeyStoreAdmin.MutationDescription value) + { + return ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S19_MutationDescription(value); + } + public static string FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S16_MutationInFlight__M2_No(Dafny.ISequence value) + { + return FromDafny_N6_smithy__N3_api__S6_String(value); + } + public static Dafny.ISequence ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S16_MutationInFlight__M2_No(string value) + { + return ToDafny_N6_smithy__N3_api__S6_String(value); + } public static string FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S24_MutationInvalidException__M7_message(Dafny.ISequence value) { return FromDafny_N6_smithy__N3_api__S6_String(value); @@ -708,6 +720,14 @@ public static Dafny.ISequence ToDafny_N3_aws__N12_cryptography__N13_keySto { return ToDafny_N6_smithy__N3_api__S6_String(value); } + public static string FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_UnsupportedFeatureException__M7_message(Dafny.ISequence value) + { + return FromDafny_N6_smithy__N3_api__S6_String(value); + } + public static Dafny.ISequence ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_UnsupportedFeatureException__M7_message(string value) + { + return ToDafny_N6_smithy__N3_api__S6_String(value); + } public static string FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S15_VersionKeyInput__M10_Identifier(Dafny.ISequence value) { return FromDafny_N6_smithy__N3_api__S6_String(value); @@ -788,17 +808,6 @@ public static System.Collections.Generic.Dictionary FromDafny_N3 new Dafny.Pair, Dafny.ISequence>(ToDafny_N3_aws__N12_cryptography__N8_keyStore__S17_EncryptionContext__M3_key(pair.Key), ToDafny_N3_aws__N12_cryptography__N8_keyStore__S17_EncryptionContext__M5_value(pair.Value)) )); } - public static AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities(software.amazon.cryptography.keystoreadmin.internaldafny.types._IMutableBranchKeyProperities value) - { - software.amazon.cryptography.keystoreadmin.internaldafny.types.MutableBranchKeyProperities concrete = (software.amazon.cryptography.keystoreadmin.internaldafny.types.MutableBranchKeyProperities)value; AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities converted = new AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities(); converted.KmsArn = (string)FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities__M6_KmsArn(concrete._KmsArn); - converted.CustomEncryptionContext = (System.Collections.Generic.Dictionary)FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities__M23_CustomEncryptionContext(concrete._CustomEncryptionContext); return converted; - } - public static software.amazon.cryptography.keystoreadmin.internaldafny.types._IMutableBranchKeyProperities ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities(AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities value) - { - value.Validate(); - - return new software.amazon.cryptography.keystoreadmin.internaldafny.types.MutableBranchKeyProperities(ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities__M6_KmsArn(value.KmsArn), ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities__M23_CustomEncryptionContext(value.CustomEncryptionContext)); - } public static AWS.Cryptography.KeyStoreAdmin.Mutations FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S9_Mutations(software.amazon.cryptography.keystoreadmin.internaldafny.types._IMutations value) { software.amazon.cryptography.keystoreadmin.internaldafny.types.Mutations concrete = (software.amazon.cryptography.keystoreadmin.internaldafny.types.Mutations)value; AWS.Cryptography.KeyStoreAdmin.Mutations converted = new AWS.Cryptography.KeyStoreAdmin.Mutations(); if (concrete._TerminalKmsArn.is_Some) converted.TerminalKmsArn = (string)FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S9_Mutations__M14_TerminalKmsArn(concrete._TerminalKmsArn); @@ -811,6 +820,14 @@ public static software.amazon.cryptography.keystoreadmin.internaldafny.types._IM System.Collections.Generic.Dictionary var_terminalEncryptionContext = value.IsSetTerminalEncryptionContext() ? value.TerminalEncryptionContext : (System.Collections.Generic.Dictionary)null; return new software.amazon.cryptography.keystoreadmin.internaldafny.types.Mutations(ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S9_Mutations__M14_TerminalKmsArn(var_terminalKmsArn), ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S9_Mutations__M25_TerminalEncryptionContext(var_terminalEncryptionContext)); } + public static bool FromDafny_N6_smithy__N3_api__S7_Boolean(bool value) + { + return value; + } + public static bool ToDafny_N6_smithy__N3_api__S7_Boolean(bool value) + { + return value; + } public static AWS.Cryptography.KeyStore.AwsKms FromDafny_N3_aws__N12_cryptography__N8_keyStore__S6_AwsKms(software.amazon.cryptography.keystore.internaldafny.types._IAwsKms value) { software.amazon.cryptography.keystore.internaldafny.types.AwsKms concrete = (software.amazon.cryptography.keystore.internaldafny.types.AwsKms)value; AWS.Cryptography.KeyStore.AwsKms converted = new AWS.Cryptography.KeyStore.AwsKms(); if (concrete._grantTokens.is_Some) converted.GrantTokens = (System.Collections.Generic.List)FromDafny_N3_aws__N12_cryptography__N8_keyStore__S6_AwsKms__M11_grantTokens(concrete._grantTokens); @@ -850,6 +867,19 @@ public static software.amazon.cryptography.keystore.internaldafny.types._IStorag } throw new System.ArgumentException("Invalid AWS.Cryptography.KeyStore.Storage state"); } + public static AWS.Cryptography.KeyStoreAdmin.MutationDescription FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S19_MutationDescription(software.amazon.cryptography.keystoreadmin.internaldafny.types._IMutationDescription value) + { + software.amazon.cryptography.keystoreadmin.internaldafny.types.MutationDescription concrete = (software.amazon.cryptography.keystoreadmin.internaldafny.types.MutationDescription)value; AWS.Cryptography.KeyStoreAdmin.MutationDescription converted = new AWS.Cryptography.KeyStoreAdmin.MutationDescription(); converted.Original = (AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities)FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S19_MutationDescription__M8_Original(concrete._Original); + converted.Terminal = (AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities)FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S19_MutationDescription__M8_Terminal(concrete._Terminal); + converted.Input = (AWS.Cryptography.KeyStoreAdmin.Mutations)FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S19_MutationDescription__M5_Input(concrete._Input); + if (concrete._SystemKey.is_Some) converted.SystemKey = (string)FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S19_MutationDescription__M9_SystemKey(concrete._SystemKey); return converted; + } + public static software.amazon.cryptography.keystoreadmin.internaldafny.types._IMutationDescription ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S19_MutationDescription(AWS.Cryptography.KeyStoreAdmin.MutationDescription value) + { + value.Validate(); + string var_systemKey = value.IsSetSystemKey() ? value.SystemKey : (string)null; + return new software.amazon.cryptography.keystoreadmin.internaldafny.types.MutationDescription(ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S19_MutationDescription__M8_Original(value.Original), ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S19_MutationDescription__M8_Terminal(value.Terminal), ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S19_MutationDescription__M5_Input(value.Input), ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S19_MutationDescription__M9_SystemKey(var_systemKey)); + } public static AWS.Cryptography.KeyStoreAdmin.KmsAes FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S6_KmsAes(software.amazon.cryptography.keystoreadmin.internaldafny.types._IKmsAes value) { software.amazon.cryptography.keystoreadmin.internaldafny.types.KmsAes concrete = (software.amazon.cryptography.keystoreadmin.internaldafny.types.KmsAes)value; AWS.Cryptography.KeyStoreAdmin.KmsAes converted = new AWS.Cryptography.KeyStoreAdmin.KmsAes(); converted.KmsAesIdentifier = (AWS.Cryptography.KeyStoreAdmin.KmsAesIdentifier)FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S6_KmsAes__M16_KmsAesIdentifier(concrete._KmsAesIdentifier); @@ -919,22 +949,6 @@ public static Dafny.ISequence ToDafny_N3_aws__N12_cryptography__N8_keyStor { return ToDafny_N3_aws__N12_cryptography__N8_keyStore__S9_Utf8Bytes(value); } - public static string FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities__M6_KmsArn(Dafny.ISequence value) - { - return FromDafny_N6_smithy__N3_api__S6_String(value); - } - public static Dafny.ISequence ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities__M6_KmsArn(string value) - { - return ToDafny_N6_smithy__N3_api__S6_String(value); - } - public static System.Collections.Generic.Dictionary FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities__M23_CustomEncryptionContext(Dafny.IMap, Dafny.ISequence> value) - { - return FromDafny_N3_aws__N12_cryptography__N8_keyStore__S23_EncryptionContextString(value); - } - public static Dafny.IMap, Dafny.ISequence> ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities__M23_CustomEncryptionContext(System.Collections.Generic.Dictionary value) - { - return ToDafny_N3_aws__N12_cryptography__N8_keyStore__S23_EncryptionContextString(value); - } public static string FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S9_Mutations__M14_TerminalKmsArn(Wrappers_Compile._IOption> value) { return value.is_None ? (string)null : FromDafny_N6_smithy__N3_api__S6_String(value.Extract()); @@ -983,6 +997,38 @@ public static software.amazon.cryptography.keystore.internaldafny.types.IKeyStor { return ToDafny_N3_aws__N12_cryptography__N8_keyStore__S28_KeyStorageInterfaceReference(value); } + public static AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S19_MutationDescription__M8_Original(software.amazon.cryptography.keystoreadmin.internaldafny.types._IMutableBranchKeyProperities value) + { + return FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities(value); + } + public static software.amazon.cryptography.keystoreadmin.internaldafny.types._IMutableBranchKeyProperities ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S19_MutationDescription__M8_Original(AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities value) + { + return ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities(value); + } + public static AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S19_MutationDescription__M8_Terminal(software.amazon.cryptography.keystoreadmin.internaldafny.types._IMutableBranchKeyProperities value) + { + return FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities(value); + } + public static software.amazon.cryptography.keystoreadmin.internaldafny.types._IMutableBranchKeyProperities ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S19_MutationDescription__M8_Terminal(AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities value) + { + return ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities(value); + } + public static AWS.Cryptography.KeyStoreAdmin.Mutations FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S19_MutationDescription__M5_Input(software.amazon.cryptography.keystoreadmin.internaldafny.types._IMutations value) + { + return FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S9_Mutations(value); + } + public static software.amazon.cryptography.keystoreadmin.internaldafny.types._IMutations ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S19_MutationDescription__M5_Input(AWS.Cryptography.KeyStoreAdmin.Mutations value) + { + return ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S9_Mutations(value); + } + public static string FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S19_MutationDescription__M9_SystemKey(Wrappers_Compile._IOption> value) + { + return value.is_None ? (string)null : FromDafny_N6_smithy__N3_api__S6_String(value.Extract()); + } + public static Wrappers_Compile._IOption> ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S19_MutationDescription__M9_SystemKey(string value) + { + return value == null ? Wrappers_Compile.Option>.create_None() : Wrappers_Compile.Option>.create_Some(ToDafny_N6_smithy__N3_api__S6_String((string)value)); + } public static AWS.Cryptography.KeyStoreAdmin.KmsAesIdentifier FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S6_KmsAes__M16_KmsAesIdentifier(software.amazon.cryptography.keystoreadmin.internaldafny.types._IKmsAesIdentifier value) { return FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S16_KmsAesIdentifier(value); @@ -1073,6 +1119,17 @@ public static software.amazon.cryptography.keystore.internaldafny.types.IKeyStor // Therefore it defers to the dependant module for conversion return AWS.Cryptography.KeyStore.TypeConversion.ToDafny_N3_aws__N12_cryptography__N8_keyStore__S28_KeyStorageInterfaceReference(value); } + public static AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities(software.amazon.cryptography.keystoreadmin.internaldafny.types._IMutableBranchKeyProperities value) + { + software.amazon.cryptography.keystoreadmin.internaldafny.types.MutableBranchKeyProperities concrete = (software.amazon.cryptography.keystoreadmin.internaldafny.types.MutableBranchKeyProperities)value; AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities converted = new AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities(); converted.KmsArn = (string)FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities__M6_KmsArn(concrete._KmsArn); + converted.CustomEncryptionContext = (System.Collections.Generic.Dictionary)FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities__M23_CustomEncryptionContext(concrete._CustomEncryptionContext); return converted; + } + public static software.amazon.cryptography.keystoreadmin.internaldafny.types._IMutableBranchKeyProperities ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities(AWS.Cryptography.KeyStoreAdmin.MutableBranchKeyProperities value) + { + value.Validate(); + + return new software.amazon.cryptography.keystoreadmin.internaldafny.types.MutableBranchKeyProperities(ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities__M6_KmsArn(value.KmsArn), ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities__M23_CustomEncryptionContext(value.CustomEncryptionContext)); + } public static string FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S20_MutatedBranchKeyItem__M8_ItemType(Dafny.ISequence value) { return FromDafny_N6_smithy__N3_api__S6_String(value); @@ -1129,6 +1186,22 @@ public static Amazon.DynamoDBv2.IAmazonDynamoDB FromDafny_N3_aws__N12_cryptograp { return value == null ? Wrappers_Compile.Option.create_None() : Wrappers_Compile.Option.create_Some(ToDafny_N3_aws__N12_cryptography__N8_keyStore__S18_DdbClientReference((Amazon.DynamoDBv2.IAmazonDynamoDB)value)); } + public static string FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities__M6_KmsArn(Dafny.ISequence value) + { + return FromDafny_N6_smithy__N3_api__S6_String(value); + } + public static Dafny.ISequence ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities__M6_KmsArn(string value) + { + return ToDafny_N6_smithy__N3_api__S6_String(value); + } + public static System.Collections.Generic.Dictionary FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities__M23_CustomEncryptionContext(Dafny.IMap, Dafny.ISequence> value) + { + return FromDafny_N3_aws__N12_cryptography__N8_keyStore__S23_EncryptionContextString(value); + } + public static Dafny.IMap, Dafny.ISequence> ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_MutableBranchKeyProperities__M23_CustomEncryptionContext(System.Collections.Generic.Dictionary value) + { + return ToDafny_N3_aws__N12_cryptography__N8_keyStore__S23_EncryptionContextString(value); + } public static string FromDafny_N3_com__N9_amazonaws__N8_dynamodb__S9_TableName(Dafny.ISequence value) { return new string(value.Elements); @@ -1182,6 +1255,8 @@ public static System.Exception FromDafny_CommonError(software.amazon.cryptograph return FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S29_MutationVerificationException(dafnyVal); case software.amazon.cryptography.keystoreadmin.internaldafny.types.Error_UnexpectedStateException dafnyVal: return FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S24_UnexpectedStateException(dafnyVal); + case software.amazon.cryptography.keystoreadmin.internaldafny.types.Error_UnsupportedFeatureException dafnyVal: + return FromDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_UnsupportedFeatureException(dafnyVal); case software.amazon.cryptography.keystoreadmin.internaldafny.types.Error_CollectionOfErrors dafnyVal: return new CollectionOfErrors( new System.Collections.Generic.List(dafnyVal.dtor_list.CloneAsArray() @@ -1225,6 +1300,8 @@ public static software.amazon.cryptography.keystoreadmin.internaldafny.types._IE return ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S29_MutationVerificationException(exception); case AWS.Cryptography.KeyStoreAdmin.UnexpectedStateException exception: return ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S24_UnexpectedStateException(exception); + case AWS.Cryptography.KeyStoreAdmin.UnsupportedFeatureException exception: + return ToDafny_N3_aws__N12_cryptography__N13_keyStoreAdmin__S27_UnsupportedFeatureException(exception); case CollectionOfErrors collectionOfErrors: return new software.amazon.cryptography.keystoreadmin.internaldafny.types.Error_CollectionOfErrors( Dafny.Sequence diff --git a/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/UnsupportedFeatureException.cs b/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/UnsupportedFeatureException.cs new file mode 100644 index 000000000..dd67178c0 --- /dev/null +++ b/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStoreAdmin/UnsupportedFeatureException.cs @@ -0,0 +1,13 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. +using System; +using AWS.Cryptography.KeyStoreAdmin; +namespace AWS.Cryptography.KeyStoreAdmin +{ + public class UnsupportedFeatureException : Exception + { + public UnsupportedFeatureException(string message) : base(message) { } + public string getMessage() { return this.Message; } + } +} diff --git a/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystoreadmin/dafny_to_smithy.py b/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystoreadmin/dafny_to_smithy.py index 535ab48b9..efd495e0a 100644 --- a/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystoreadmin/dafny_to_smithy.py +++ b/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystoreadmin/dafny_to_smithy.py @@ -11,9 +11,12 @@ KeyManagementStrategy_AwsKmsReEncrypt, KmsAesIdentifier_KmsKeyArn, KmsAesIdentifier_KmsMRKeyArn, + MutationInFlight_No, + MutationInFlight_Yes, SystemKey_kmsAes, SystemKey_trustStorage, ) +import aws_cryptographic_material_providers.internaldafny.generated.module_ import aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystore.dafny_to_smithy import aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.dafny_to_smithy import aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.models @@ -196,8 +199,19 @@ def aws_cryptography_keystoreadmin_InitializeMutationInput(dafny_input): if (dafny_input.Strategy.is_Some) else None ), - system_key=aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.dafny_to_smithy.aws_cryptography_keystoreadmin_SystemKey( - dafny_input.SystemKey + system_key=( + ( + aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.dafny_to_smithy.aws_cryptography_keystoreadmin_SystemKey( + dafny_input.SystemKey.value + ) + ) + if (dafny_input.SystemKey.is_Some) + else None + ), + do_not_version=( + (dafny_input.DoNotVersion.value) + if (dafny_input.DoNotVersion.is_Some) + else None ), ) @@ -239,8 +253,14 @@ def aws_cryptography_keystoreadmin_ApplyMutationInput(dafny_input): if (dafny_input.Strategy.is_Some) else None ), - system_key=aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.dafny_to_smithy.aws_cryptography_keystoreadmin_SystemKey( - dafny_input.SystemKey + system_key=( + ( + aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.dafny_to_smithy.aws_cryptography_keystoreadmin_SystemKey( + dafny_input.SystemKey.value + ) + ) + if (dafny_input.SystemKey.is_Some) + else None ), ) @@ -279,29 +299,17 @@ def aws_cryptography_keystoreadmin_MutatedBranchKeyItem(dafny_input): def aws_cryptography_keystoreadmin_InitializeMutationFlag(dafny_input): - # Convert InitializeMutationFlag if isinstance(dafny_input, InitializeMutationFlag_Created): - InitializeMutationFlag_union_value = aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.models.InitializeMutationFlagCreated( - b"".join(ord(c).to_bytes(2, "big") for c in dafny_input.Created).decode( - "utf-16-be" - ) - ) + return "Created" + elif isinstance(dafny_input, InitializeMutationFlag_Resumed): - InitializeMutationFlag_union_value = aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.models.InitializeMutationFlagResumed( - b"".join(ord(c).to_bytes(2, "big") for c in dafny_input.Resumed).decode( - "utf-16-be" - ) - ) + return "Resumed" + elif isinstance(dafny_input, InitializeMutationFlag_ResumedWithoutIndex): - InitializeMutationFlag_union_value = aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.models.InitializeMutationFlagResumedWithoutIndex( - b"".join( - ord(c).to_bytes(2, "big") for c in dafny_input.ResumedWithoutIndex - ).decode("utf-16-be") - ) - else: - raise ValueError("No recognized union value in union type: " + str(dafny_input)) + return "ResumedWithoutIndex" - return InitializeMutationFlag_union_value + else: + raise ValueError(f"No recognized enum value in enum type: {dafny_input=}") def aws_cryptography_keystoreadmin_InitializeMutationOutput(dafny_input): @@ -361,6 +369,49 @@ def aws_cryptography_keystoreadmin_ApplyMutationOutput(dafny_input): ) +def aws_cryptography_keystoreadmin_MutationInFlight(dafny_input): + # Convert MutationInFlight + if isinstance(dafny_input, MutationInFlight_Yes): + MutationInFlight_union_value = aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.models.MutationInFlightYes( + aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.dafny_to_smithy.aws_cryptography_keystoreadmin_MutationDescription( + dafny_input.Yes + ) + ) + elif isinstance(dafny_input, MutationInFlight_No): + MutationInFlight_union_value = aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.models.MutationInFlightNo( + b"".join(ord(c).to_bytes(2, "big") for c in dafny_input.No).decode( + "utf-16-be" + ) + ) + else: + raise ValueError("No recognized union value in union type: " + str(dafny_input)) + + return MutationInFlight_union_value + + +def aws_cryptography_keystoreadmin_MutationDescription(dafny_input): + return aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.models.MutationDescription( + original=aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.dafny_to_smithy.aws_cryptography_keystoreadmin_MutableBranchKeyProperities( + dafny_input.Original + ), + terminal=aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.dafny_to_smithy.aws_cryptography_keystoreadmin_MutableBranchKeyProperities( + dafny_input.Terminal + ), + input=aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.dafny_to_smithy.aws_cryptography_keystoreadmin_Mutations( + dafny_input.Input + ), + system_key=( + ( + b"".join( + ord(c).to_bytes(2, "big") for c in dafny_input.SystemKey.value + ).decode("utf-16-be") + ) + if (dafny_input.SystemKey.is_Some) + else None + ), + ) + + def aws_cryptography_keystoreadmin_MutableBranchKeyProperities(dafny_input): return aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.models.MutableBranchKeyProperities( kms_arn=b"".join(ord(c).to_bytes(2, "big") for c in dafny_input.KmsArn).decode( @@ -377,23 +428,8 @@ def aws_cryptography_keystoreadmin_MutableBranchKeyProperities(dafny_input): def aws_cryptography_keystoreadmin_DescribeMutationOutput(dafny_input): return aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.models.DescribeMutationOutput( - original=( - ( - aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.dafny_to_smithy.aws_cryptography_keystoreadmin_MutableBranchKeyProperities( - dafny_input.Original.value - ) - ) - if (dafny_input.Original.is_Some) - else None - ), - terminal=( - ( - aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.dafny_to_smithy.aws_cryptography_keystoreadmin_MutableBranchKeyProperities( - dafny_input.Terminal.value - ) - ) - if (dafny_input.Terminal.is_Some) - else None + mutation_in_flight=aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.dafny_to_smithy.aws_cryptography_keystoreadmin_MutationInFlight( + dafny_input.MutationInFlight ), ) diff --git a/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystoreadmin/deserialize.py b/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystoreadmin/deserialize.py index caccd1776..942b93515 100644 --- a/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystoreadmin/deserialize.py +++ b/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystoreadmin/deserialize.py @@ -16,6 +16,7 @@ Error_MutationToException, Error_MutationVerificationException, Error_UnexpectedStateException, + Error_UnsupportedFeatureException, InitializeMutationOutput_InitializeMutationOutput as DafnyInitializeMutationOutput, VersionKeyOutput_VersionKeyOutput as DafnyVersionKeyOutput, ) @@ -39,6 +40,7 @@ OpaqueError, ServiceError, UnexpectedStateException, + UnsupportedFeatureException, ) from aws_cryptography_internal_dynamodb.smithygenerated.com_amazonaws_dynamodb.shim import ( _sdk_error_to_dafny_error as com_amazonaws_dynamodb_sdk_error_to_dafny_error, @@ -122,6 +124,8 @@ def _deserialize_error(error: Error) -> ServiceError: return MutationVerificationException(message=_dafny.string_of(error.message)) elif error.is_UnexpectedStateException: return UnexpectedStateException(message=_dafny.string_of(error.message)) + elif error.is_UnsupportedFeatureException: + return UnsupportedFeatureException(message=_dafny.string_of(error.message)) elif error.is_AwsCryptographyKeyStore: return KeyStore( aws_cryptography_keystore_deserialize_error(error.AwsCryptographyKeyStore) diff --git a/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystoreadmin/errors.py b/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystoreadmin/errors.py index 48720132d..eb6b18d70 100644 --- a/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystoreadmin/errors.py +++ b/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystoreadmin/errors.py @@ -43,6 +43,50 @@ class UnknownApiError(ApiError[Literal["Unknown"]]): code: Literal["Unknown"] = "Unknown" +class KeyStoreAdminException(ApiError[Literal["KeyStoreAdminException"]]): + code: Literal["KeyStoreAdminException"] = "KeyStoreAdminException" + message: str + + def __init__( + self, + *, + message: str, + ): + super().__init__(message) + + def as_dict(self) -> Dict[str, Any]: + """Converts the KeyStoreAdminException to a dictionary.""" + return { + "message": self.message, + "code": self.code, + } + + @staticmethod + def from_dict(d: Dict[str, Any]) -> "KeyStoreAdminException": + """Creates a KeyStoreAdminException from a dictionary.""" + kwargs: Dict[str, Any] = { + "message": d["message"], + } + + return KeyStoreAdminException(**kwargs) + + def __repr__(self) -> str: + result = "KeyStoreAdminException(" + if self.message is not None: + result += f"message={repr(self.message)}" + + return result + ")" + + def __eq__(self, other: Any) -> bool: + if not isinstance(other, KeyStoreAdminException): + return False + attributes: list[str] = [ + "message", + "message", + ] + return all(getattr(self, a) == getattr(other, a) for a in attributes) + + class MutationFromException(ApiError[Literal["MutationFromException"]]): code: Literal["MutationFromException"] = "MutationFromException" message: str @@ -297,8 +341,8 @@ def __eq__(self, other: Any) -> bool: return all(getattr(self, a) == getattr(other, a) for a in attributes) -class KeyStoreAdminException(ApiError[Literal["KeyStoreAdminException"]]): - code: Literal["KeyStoreAdminException"] = "KeyStoreAdminException" +class UnsupportedFeatureException(ApiError[Literal["UnsupportedFeatureException"]]): + code: Literal["UnsupportedFeatureException"] = "UnsupportedFeatureException" message: str def __init__( @@ -306,33 +350,37 @@ def __init__( *, message: str, ): + """This feature is not yet implemented. + + :param message: A message associated with the specific error. + """ super().__init__(message) def as_dict(self) -> Dict[str, Any]: - """Converts the KeyStoreAdminException to a dictionary.""" + """Converts the UnsupportedFeatureException to a dictionary.""" return { "message": self.message, "code": self.code, } @staticmethod - def from_dict(d: Dict[str, Any]) -> "KeyStoreAdminException": - """Creates a KeyStoreAdminException from a dictionary.""" + def from_dict(d: Dict[str, Any]) -> "UnsupportedFeatureException": + """Creates a UnsupportedFeatureException from a dictionary.""" kwargs: Dict[str, Any] = { "message": d["message"], } - return KeyStoreAdminException(**kwargs) + return UnsupportedFeatureException(**kwargs) def __repr__(self) -> str: - result = "KeyStoreAdminException(" + result = "UnsupportedFeatureException(" if self.message is not None: result += f"message={repr(self.message)}" return result + ")" def __eq__(self, other: Any) -> bool: - if not isinstance(other, KeyStoreAdminException): + if not isinstance(other, UnsupportedFeatureException): return False attributes: list[str] = [ "message", @@ -479,6 +527,11 @@ class UnexpectedStateException(ApiError[Literal["UnexpectedStateException"]]): message: str +class UnsupportedFeatureException(ApiError[Literal["UnsupportedFeatureException"]]): + code: Literal["UnsupportedFeatureException"] = "UnsupportedFeatureException" + message: str + + class ComAmazonawsDynamodb(ApiError[Literal["ComAmazonawsDynamodb"]]): ComAmazonawsDynamodb: Any @@ -659,6 +712,14 @@ def _smithy_error_to_dafny_error(e: ServiceError): message=_dafny.Seq(e.message) ) + if isinstance( + e, + aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.errors.UnsupportedFeatureException, + ): + return aws_cryptographic_material_providers.internaldafny.generated.AwsCryptographyKeyStoreAdminTypes.Error_UnsupportedFeatureException( + message=_dafny.Seq(e.message) + ) + if isinstance(e, ComAmazonawsDynamodb): return aws_cryptographic_material_providers.internaldafny.generated.AwsCryptographyKeyStoreAdminTypes.Error_ComAmazonawsDynamodb( com_amazonaws_dynamodb_sdk_error_to_dafny_error(e.message) diff --git a/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystoreadmin/models.py b/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystoreadmin/models.py index 253037491..1418fc28d 100644 --- a/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystoreadmin/models.py +++ b/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystoreadmin/models.py @@ -403,7 +403,8 @@ def __repr__(self) -> str: return f"SystemKeyUnknown(tag={self.tag})" -# Key Store Admin protects any non-cryptographic items stored with this Key. +# Key Store Admin protects any non-cryptographic items stored with this Key. As of +# v1.8.0, TrustStorage is the default behavior. SystemKey = Union[SystemKeyKmsAes, SystemKeyTrustStorage, SystemKeyUnknown] @@ -421,20 +422,17 @@ class ApplyMutationInput: mutation_token: MutationToken page_size: Optional[int] strategy: Optional[KeyManagementStrategy] - system_key: SystemKey + system_key: Optional[SystemKey] def __init__( self, *, mutation_token: MutationToken, - system_key: SystemKey, page_size: Optional[int] = None, strategy: Optional[KeyManagementStrategy] = None, + system_key: Optional[SystemKey] = None, ): """ - :param system_key: Key Store Admin protects any non-cryptographic - items stored - with this Key. :param page_size: For Default DynamoDB Table Storage, the maximum page size is 99. At most, Apply Mutation will mutate pageSize Items. @@ -445,17 +443,17 @@ def __init__( Thus, if the pageSize is 24, 25 requests will be sent in the Transact Write Request. :param strategy: Optional. Defaults to reEncrypt with a default KMS Client. + :param system_key: Optional. Defaults to TrustStorage. See System Key. """ self.mutation_token = mutation_token - self.system_key = system_key self.page_size = page_size self.strategy = strategy + self.system_key = system_key def as_dict(self) -> Dict[str, Any]: """Converts the ApplyMutationInput to a dictionary.""" d: Dict[str, Any] = { "mutation_token": self.mutation_token.as_dict(), - "system_key": self.system_key.as_dict(), } if self.page_size is not None: @@ -464,6 +462,9 @@ def as_dict(self) -> Dict[str, Any]: if self.strategy is not None: d["strategy"] = self.strategy.as_dict() + if self.system_key is not None: + d["system_key"] = self.system_key.as_dict() + return d @staticmethod @@ -471,7 +472,6 @@ def from_dict(d: Dict[str, Any]) -> "ApplyMutationInput": """Creates a ApplyMutationInput from a dictionary.""" kwargs: Dict[str, Any] = { "mutation_token": MutationToken.from_dict(d["mutation_token"]), - "system_key": _system_key_from_dict(d["system_key"]), } if "page_size" in d: @@ -480,6 +480,9 @@ def from_dict(d: Dict[str, Any]) -> "ApplyMutationInput": if "strategy" in d: kwargs["strategy"] = (_key_management_strategy_from_dict(d["strategy"]),) + if "system_key" in d: + kwargs["system_key"] = (_system_key_from_dict(d["system_key"]),) + return ApplyMutationInput(**kwargs) def __repr__(self) -> str: @@ -928,6 +931,90 @@ def __eq__(self, other: Any) -> bool: return all(getattr(self, a) == getattr(other, a) for a in attributes) +class Mutations: + terminal_kms_arn: Optional[str] + terminal_encryption_context: Optional[dict[str, str]] + + def __init__( + self, + *, + terminal_kms_arn: Optional[str] = None, + terminal_encryption_context: Optional[dict[str, str]] = None, + ): + """Define the Mutation in terms of the terminal, or end state, value + for a particular Branch Key property. The original value will be + REPLACED with this value. + + As of v1.8.0, a Mutation can either: + - replace the KmsArn protecting the + Branch Key + - replace the custom encryption context + - replace both the KmsArn and + the custom encryption context + + :param terminal_kms_arn: ReEncrypt all Items of the Branch Key + to be + authorized by this + AWS Key Management Service Key. + A Multi-Region or Single + Region AWS KMS Key are permitted, + but not aliases! + :param terminal_encryption_context: ReEncrypt all Items of the Branch Key + to + be authorized with this custom encryption context. + An empty Encyrption Context + is not allowed. + """ + self.terminal_kms_arn = terminal_kms_arn + self.terminal_encryption_context = terminal_encryption_context + + def as_dict(self) -> Dict[str, Any]: + """Converts the Mutations to a dictionary.""" + d: Dict[str, Any] = {} + + if self.terminal_kms_arn is not None: + d["terminal_kms_arn"] = self.terminal_kms_arn + + if self.terminal_encryption_context is not None: + d["terminal_encryption_context"] = self.terminal_encryption_context + + return d + + @staticmethod + def from_dict(d: Dict[str, Any]) -> "Mutations": + """Creates a Mutations from a dictionary.""" + kwargs: Dict[str, Any] = {} + + if "terminal_kms_arn" in d: + kwargs["terminal_kms_arn"] = d["terminal_kms_arn"] + + if "terminal_encryption_context" in d: + kwargs["terminal_encryption_context"] = d["terminal_encryption_context"] + + return Mutations(**kwargs) + + def __repr__(self) -> str: + result = "Mutations(" + if self.terminal_kms_arn is not None: + result += f"terminal_kms_arn={repr(self.terminal_kms_arn)}, " + + if self.terminal_encryption_context is not None: + result += ( + f"terminal_encryption_context={repr(self.terminal_encryption_context)}" + ) + + return result + ")" + + def __eq__(self, other: Any) -> bool: + if not isinstance(other, Mutations): + return False + attributes: list[str] = [ + "terminal_kms_arn", + "terminal_encryption_context", + ] + return all(getattr(self, a) == getattr(other, a) for a in attributes) + + class MutableBranchKeyProperities: kms_arn: str custom_encryption_context: dict[str, str] @@ -992,148 +1079,215 @@ def __eq__(self, other: Any) -> bool: return all(getattr(self, a) == getattr(other, a) for a in attributes) -class DescribeMutationOutput: - original: Optional[MutableBranchKeyProperities] - terminal: Optional[MutableBranchKeyProperities] +class MutationDescription: + original: MutableBranchKeyProperities + terminal: MutableBranchKeyProperities + input: Mutations + system_key: Optional[str] def __init__( self, *, - original: Optional[MutableBranchKeyProperities] = None, - terminal: Optional[MutableBranchKeyProperities] = None, + original: MutableBranchKeyProperities, + terminal: MutableBranchKeyProperities, + input: Mutations, + system_key: Optional[str] = None, ): """ :param original: The original properities of the Branch Key. :param terminal: The terminal properities of the Branch Key. + :param input: The input for this mutation. + :param system_key: String descprition of the System Key. """ self.original = original self.terminal = terminal + self.input = input + self.system_key = system_key def as_dict(self) -> Dict[str, Any]: - """Converts the DescribeMutationOutput to a dictionary.""" - d: Dict[str, Any] = {} - - if self.original is not None: - d["original"] = self.original.as_dict() + """Converts the MutationDescription to a dictionary.""" + d: Dict[str, Any] = { + "original": self.original.as_dict(), + "terminal": self.terminal.as_dict(), + "input": self.input.as_dict(), + } - if self.terminal is not None: - d["terminal"] = self.terminal.as_dict() + if self.system_key is not None: + d["system_key"] = self.system_key return d @staticmethod - def from_dict(d: Dict[str, Any]) -> "DescribeMutationOutput": - """Creates a DescribeMutationOutput from a dictionary.""" - kwargs: Dict[str, Any] = {} - - if "original" in d: - kwargs["original"] = MutableBranchKeyProperities.from_dict(d["original"]) + def from_dict(d: Dict[str, Any]) -> "MutationDescription": + """Creates a MutationDescription from a dictionary.""" + kwargs: Dict[str, Any] = { + "original": MutableBranchKeyProperities.from_dict(d["original"]), + "terminal": MutableBranchKeyProperities.from_dict(d["terminal"]), + "input": Mutations.from_dict(d["input"]), + } - if "terminal" in d: - kwargs["terminal"] = MutableBranchKeyProperities.from_dict(d["terminal"]) + if "system_key" in d: + kwargs["system_key"] = d["system_key"] - return DescribeMutationOutput(**kwargs) + return MutationDescription(**kwargs) def __repr__(self) -> str: - result = "DescribeMutationOutput(" + result = "MutationDescription(" if self.original is not None: result += f"original={repr(self.original)}, " if self.terminal is not None: - result += f"terminal={repr(self.terminal)}" + result += f"terminal={repr(self.terminal)}, " + + if self.input is not None: + result += f"input={repr(self.input)}, " + + if self.system_key is not None: + result += f"system_key={repr(self.system_key)}" return result + ")" def __eq__(self, other: Any) -> bool: - if not isinstance(other, DescribeMutationOutput): + if not isinstance(other, MutationDescription): return False attributes: list[str] = [ "original", "terminal", + "input", + "system_key", ] return all(getattr(self, a) == getattr(other, a) for a in attributes) -class Mutations: - terminal_kms_arn: Optional[str] - terminal_encryption_context: Optional[dict[str, str]] +class MutationInFlightYes: + def __init__(self, value: MutationDescription): + self.value = value - def __init__( - self, - *, - terminal_kms_arn: Optional[str] = None, - terminal_encryption_context: Optional[dict[str, str]] = None, - ): - """Define the Mutation in terms of the terminal, or end state, value - for a particular Branch Key property. The original value will be - REPLACED with this value. + def as_dict(self) -> Dict[str, Any]: + return {"Yes": self.value.as_dict()} - As of v1.8.0, a Mutation can either: - - replace the KmsArn protecting the - Branch Key - - replace the custom encryption context - - replace both the KmsArn and - the custom encryption context + @staticmethod + def from_dict(d: Dict[str, Any]) -> "MutationInFlightYes": + if len(d) != 1: + raise TypeError(f"Unions may have exactly 1 value, but found {len(d)}") - :param terminal_kms_arn: ReEncrypt all Items of the Branch Key - to be - authorized by this - AWS Key Management Service Key. - A Multi-Region or Single - Region AWS KMS Key are permitted, - but not aliases! - :param terminal_encryption_context: ReEncrypt all Items of the Branch Key - to - be authorized with this custom encryption context. - An empty Encyrption Context - is not allowed. - """ - self.terminal_kms_arn = terminal_kms_arn - self.terminal_encryption_context = terminal_encryption_context + return MutationInFlightYes(MutationDescription.from_dict(d["Yes"])) - def as_dict(self) -> Dict[str, Any]: - """Converts the Mutations to a dictionary.""" - d: Dict[str, Any] = {} + def __repr__(self) -> str: + return f"MutationInFlightYes(value=repr(self.value))" - if self.terminal_kms_arn is not None: - d["terminal_kms_arn"] = self.terminal_kms_arn + def __eq__(self, other: Any) -> bool: + if not isinstance(other, MutationInFlightYes): + return False + return self.value == other.value - if self.terminal_encryption_context is not None: - d["terminal_encryption_context"] = self.terminal_encryption_context - return d +class MutationInFlightNo: + def __init__(self, value: str): + self.value = value + + def as_dict(self) -> Dict[str, Any]: + return {"No": self.value} @staticmethod - def from_dict(d: Dict[str, Any]) -> "Mutations": - """Creates a Mutations from a dictionary.""" - kwargs: Dict[str, Any] = {} + def from_dict(d: Dict[str, Any]) -> "MutationInFlightNo": + if len(d) != 1: + raise TypeError(f"Unions may have exactly 1 value, but found {len(d)}") - if "terminal_kms_arn" in d: - kwargs["terminal_kms_arn"] = d["terminal_kms_arn"] + return MutationInFlightNo(d["No"]) - if "terminal_encryption_context" in d: - kwargs["terminal_encryption_context"] = d["terminal_encryption_context"] + def __repr__(self) -> str: + return f"MutationInFlightNo(value=repr(self.value))" - return Mutations(**kwargs) + def __eq__(self, other: Any) -> bool: + if not isinstance(other, MutationInFlightNo): + return False + return self.value == other.value + + +class MutationInFlightUnknown: + """Represents an unknown variant. + + If you receive this value, you will need to update your library to + receive the parsed value. + + This value may not be deliberately sent. + """ + + def __init__(self, tag: str): + self.tag = tag + + def as_dict(self) -> Dict[str, Any]: + return {"SDK_UNKNOWN_MEMBER": {"name": self.tag}} + + @staticmethod + def from_dict(d: Dict[str, Any]) -> "MutationInFlightUnknown": + if len(d) != 1: + raise TypeError(f"Unions may have exactly 1 value, but found {len(d)}") + return MutationInFlightUnknown(d["SDK_UNKNOWN_MEMBER"]["name"]) def __repr__(self) -> str: - result = "Mutations(" - if self.terminal_kms_arn is not None: - result += f"terminal_kms_arn={repr(self.terminal_kms_arn)}, " + return f"MutationInFlightUnknown(tag={self.tag})" - if self.terminal_encryption_context is not None: - result += ( - f"terminal_encryption_context={repr(self.terminal_encryption_context)}" - ) + +# If a Mutation is In Flight for this Branch Key. +MutationInFlight = Union[ + MutationInFlightYes, MutationInFlightNo, MutationInFlightUnknown +] + + +def _mutation_in_flight_from_dict(d: Dict[str, Any]) -> MutationInFlight: + if "Yes" in d: + return MutationInFlightYes.from_dict(d) + + if "No" in d: + return MutationInFlightNo.from_dict(d) + + raise TypeError(f"Unions may have exactly 1 value, but found {len(d)}") + + +class DescribeMutationOutput: + mutation_in_flight: MutationInFlight + + def __init__( + self, + *, + mutation_in_flight: MutationInFlight, + ): + """ + :param mutation_in_flight: If a Mutation is In Flight for this Branch Key. + """ + self.mutation_in_flight = mutation_in_flight + + def as_dict(self) -> Dict[str, Any]: + """Converts the DescribeMutationOutput to a dictionary.""" + return { + "mutation_in_flight": self.mutation_in_flight.as_dict(), + } + + @staticmethod + def from_dict(d: Dict[str, Any]) -> "DescribeMutationOutput": + """Creates a DescribeMutationOutput from a dictionary.""" + kwargs: Dict[str, Any] = { + "mutation_in_flight": _mutation_in_flight_from_dict( + d["mutation_in_flight"] + ), + } + + return DescribeMutationOutput(**kwargs) + + def __repr__(self) -> str: + result = "DescribeMutationOutput(" + if self.mutation_in_flight is not None: + result += f"mutation_in_flight={repr(self.mutation_in_flight)}" return result + ")" def __eq__(self, other: Any) -> bool: - if not isinstance(other, Mutations): + if not isinstance(other, DescribeMutationOutput): return False attributes: list[str] = [ - "terminal_kms_arn", - "terminal_encryption_context", + "mutation_in_flight", ] return all(getattr(self, a) == getattr(other, a) for a in attributes) @@ -1142,41 +1296,49 @@ class InitializeMutationInput: identifier: str mutations: Mutations strategy: Optional[KeyManagementStrategy] - system_key: SystemKey + system_key: Optional[SystemKey] + do_not_version: Optional[bool] def __init__( self, *, identifier: str, mutations: Mutations, - system_key: SystemKey, strategy: Optional[KeyManagementStrategy] = None, + system_key: Optional[SystemKey] = None, + do_not_version: Optional[bool] = None, ): """ :param identifier: The identifier for the Branch Key to be mutated. :param mutations: Describes the Mutation that will be applied to all Items of the Branch Key. - :param system_key: Key Store Admin protects any non-cryptographic - items stored - with this Key. :param strategy: Optional. Defaults to reEncrypt with a default KMS Client. + :param system_key: Optional. Defaults to TrustStorage. See System Key. + :param do_not_version: Optional. Defaults to False. As of v1.8.0, setting this + true throws an exception. """ self.identifier = identifier self.mutations = mutations - self.system_key = system_key self.strategy = strategy + self.system_key = system_key + self.do_not_version = do_not_version def as_dict(self) -> Dict[str, Any]: """Converts the InitializeMutationInput to a dictionary.""" d: Dict[str, Any] = { "identifier": self.identifier, "mutations": self.mutations.as_dict(), - "system_key": self.system_key.as_dict(), } if self.strategy is not None: d["strategy"] = self.strategy.as_dict() + if self.system_key is not None: + d["system_key"] = self.system_key.as_dict() + + if self.do_not_version is not None: + d["do_not_version"] = self.do_not_version + return d @staticmethod @@ -1185,12 +1347,17 @@ def from_dict(d: Dict[str, Any]) -> "InitializeMutationInput": kwargs: Dict[str, Any] = { "identifier": d["identifier"], "mutations": Mutations.from_dict(d["mutations"]), - "system_key": _system_key_from_dict(d["system_key"]), } if "strategy" in d: kwargs["strategy"] = (_key_management_strategy_from_dict(d["strategy"]),) + if "system_key" in d: + kwargs["system_key"] = (_system_key_from_dict(d["system_key"]),) + + if "do_not_version" in d: + kwargs["do_not_version"] = d["do_not_version"] + return InitializeMutationInput(**kwargs) def __repr__(self) -> str: @@ -1205,7 +1372,10 @@ def __repr__(self) -> str: result += f"strategy={repr(self.strategy)}, " if self.system_key is not None: - result += f"system_key={repr(self.system_key)}" + result += f"system_key={repr(self.system_key)}, " + + if self.do_not_version is not None: + result += f"do_not_version={repr(self.do_not_version)}" return result + ")" @@ -1217,142 +1387,34 @@ def __eq__(self, other: Any) -> bool: "mutations", "strategy", "system_key", + "do_not_version", ] return all(getattr(self, a) == getattr(other, a) for a in attributes) -class InitializeMutationFlagCreated: - """This is a new mutation.""" - - def __init__(self, value: str): - self.value = value - - def as_dict(self) -> Dict[str, Any]: - return {"Created": self.value} - - @staticmethod - def from_dict(d: Dict[str, Any]) -> "InitializeMutationFlagCreated": - if len(d) != 1: - raise TypeError(f"Unions may have exactly 1 value, but found {len(d)}") - - return InitializeMutationFlagCreated(d["Created"]) - - def __repr__(self) -> str: - return f"InitializeMutationFlagCreated(value=repr(self.value))" - - def __eq__(self, other: Any) -> bool: - if not isinstance(other, InitializeMutationFlagCreated): - return False - return self.value == other.value - - -class InitializeMutationFlagResumed: - """A matching mutation already existed.""" +class InitializeMutationFlag: + CREATED = "Created" - def __init__(self, value: str): - self.value = value + RESUMED = "Resumed" - def as_dict(self) -> Dict[str, Any]: - return {"Resumed": self.value} + RESUMED_WITHOUT_INDEX = "ResumedWithoutIndex" - @staticmethod - def from_dict(d: Dict[str, Any]) -> "InitializeMutationFlagResumed": - if len(d) != 1: - raise TypeError(f"Unions may have exactly 1 value, but found {len(d)}") - - return InitializeMutationFlagResumed(d["Resumed"]) - - def __repr__(self) -> str: - return f"InitializeMutationFlagResumed(value=repr(self.value))" - - def __eq__(self, other: Any) -> bool: - if not isinstance(other, InitializeMutationFlagResumed): - return False - return self.value == other.value - - -class InitializeMutationFlagResumedWithoutIndex: - """A matching mutation already existed, but no Page Index was found.""" - - def __init__(self, value: str): - self.value = value - - def as_dict(self) -> Dict[str, Any]: - return {"ResumedWithoutIndex": self.value} - - @staticmethod - def from_dict(d: Dict[str, Any]) -> "InitializeMutationFlagResumedWithoutIndex": - if len(d) != 1: - raise TypeError(f"Unions may have exactly 1 value, but found {len(d)}") - - return InitializeMutationFlagResumedWithoutIndex(d["ResumedWithoutIndex"]) - - def __repr__(self) -> str: - return f"InitializeMutationFlagResumedWithoutIndex(value=repr(self.value))" - - def __eq__(self, other: Any) -> bool: - if not isinstance(other, InitializeMutationFlagResumedWithoutIndex): - return False - return self.value == other.value - - -class InitializeMutationFlagUnknown: - """Represents an unknown variant. - - If you receive this value, you will need to update your library to - receive the parsed value. - - This value may not be deliberately sent. - """ - - def __init__(self, tag: str): - self.tag = tag - - def as_dict(self) -> Dict[str, Any]: - return {"SDK_UNKNOWN_MEMBER": {"name": self.tag}} - - @staticmethod - def from_dict(d: Dict[str, Any]) -> "InitializeMutationFlagUnknown": - if len(d) != 1: - raise TypeError(f"Unions may have exactly 1 value, but found {len(d)}") - return InitializeMutationFlagUnknown(d["SDK_UNKNOWN_MEMBER"]["name"]) - - def __repr__(self) -> str: - return f"InitializeMutationFlagUnknown(tag={self.tag})" - - -InitializeMutationFlag = Union[ - InitializeMutationFlagCreated, - InitializeMutationFlagResumed, - InitializeMutationFlagResumedWithoutIndex, - InitializeMutationFlagUnknown, -] - - -def _initialize_mutation_flag_from_dict(d: Dict[str, Any]) -> InitializeMutationFlag: - if "Created" in d: - return InitializeMutationFlagCreated.from_dict(d) - - if "Resumed" in d: - return InitializeMutationFlagResumed.from_dict(d) - - if "ResumedWithoutIndex" in d: - return InitializeMutationFlagResumedWithoutIndex.from_dict(d) - - raise TypeError(f"Unions may have exactly 1 value, but found {len(d)}") + # This set contains every possible value known at the time this was generated. New + # values may be added in the future. + values = frozenset({"Created", "Resumed", "ResumedWithoutIndex"}) class InitializeMutationOutput: mutation_token: MutationToken mutated_branch_key_items: list[MutatedBranchKeyItem] - initialize_mutation_flag: InitializeMutationFlag + initialize_mutation_flag: str def __init__( self, *, mutation_token: MutationToken, mutated_branch_key_items: list[MutatedBranchKeyItem], - initialize_mutation_flag: InitializeMutationFlag, + initialize_mutation_flag: str, ): """ :param mutation_token: Pass the Mutation Token to the Apply Mutation operation @@ -1371,7 +1433,7 @@ def as_dict(self) -> Dict[str, Any]: "mutated_branch_key_items": _mutated_branch_key_items_as_dict( self.mutated_branch_key_items ), - "initialize_mutation_flag": self.initialize_mutation_flag.as_dict(), + "initialize_mutation_flag": self.initialize_mutation_flag, } @staticmethod @@ -1382,9 +1444,7 @@ def from_dict(d: Dict[str, Any]) -> "InitializeMutationOutput": "mutated_branch_key_items": _mutated_branch_key_items_from_dict( d["mutated_branch_key_items"] ), - "initialize_mutation_flag": _initialize_mutation_flag_from_dict( - d["initialize_mutation_flag"] - ), + "initialize_mutation_flag": d["initialize_mutation_flag"], } return InitializeMutationOutput(**kwargs) diff --git a/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystoreadmin/smithy_to_dafny.py b/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystoreadmin/smithy_to_dafny.py index 6757d6a7d..59ee16b85 100644 --- a/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystoreadmin/smithy_to_dafny.py +++ b/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystoreadmin/smithy_to_dafny.py @@ -25,6 +25,9 @@ MutableBranchKeyProperities_MutableBranchKeyProperities as DafnyMutableBranchKeyProperities, MutatedBranchKeyItem_MutatedBranchKeyItem as DafnyMutatedBranchKeyItem, MutationComplete_MutationComplete as DafnyMutationComplete, + MutationDescription_MutationDescription as DafnyMutationDescription, + MutationInFlight_No, + MutationInFlight_Yes, MutationToken_MutationToken as DafnyMutationToken, Mutations_Mutations as DafnyMutations, SystemKey_kmsAes, @@ -209,8 +212,21 @@ def aws_cryptography_keystoreadmin_InitializeMutationInput(native_input): if (native_input.strategy is not None) else (Option_None()) ), - SystemKey=aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.smithy_to_dafny.aws_cryptography_keystoreadmin_SystemKey( - native_input.system_key + SystemKey=( + ( + Option_Some( + aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.smithy_to_dafny.aws_cryptography_keystoreadmin_SystemKey( + native_input.system_key + ) + ) + ) + if (native_input.system_key is not None) + else (Option_None()) + ), + DoNotVersion=( + (Option_Some(native_input.do_not_version)) + if (native_input.do_not_version is not None) + else (Option_None()) ), ) @@ -343,8 +359,16 @@ def aws_cryptography_keystoreadmin_ApplyMutationInput(native_input): if (native_input.strategy is not None) else (Option_None()) ), - SystemKey=aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.smithy_to_dafny.aws_cryptography_keystoreadmin_SystemKey( - native_input.system_key + SystemKey=( + ( + Option_Some( + aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.smithy_to_dafny.aws_cryptography_keystoreadmin_SystemKey( + native_input.system_key + ) + ) + ) + if (native_input.system_key is not None) + else (Option_None()) ), ) @@ -471,60 +495,17 @@ def aws_cryptography_keystoreadmin_MutatedBranchKeyItem(native_input): def aws_cryptography_keystoreadmin_InitializeMutationFlag(native_input): - if isinstance( - native_input, - aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.models.InitializeMutationFlagCreated, - ): - InitializeMutationFlag_union_value = InitializeMutationFlag_Created( - Seq( - "".join( - [ - chr(int.from_bytes(pair, "big")) - for pair in zip( - *[iter(native_input.value.encode("utf-16-be"))] * 2 - ) - ] - ) - ) - ) - elif isinstance( - native_input, - aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.models.InitializeMutationFlagResumed, - ): - InitializeMutationFlag_union_value = InitializeMutationFlag_Resumed( - Seq( - "".join( - [ - chr(int.from_bytes(pair, "big")) - for pair in zip( - *[iter(native_input.value.encode("utf-16-be"))] * 2 - ) - ] - ) - ) - ) - elif isinstance( - native_input, - aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.models.InitializeMutationFlagResumedWithoutIndex, - ): - InitializeMutationFlag_union_value = InitializeMutationFlag_ResumedWithoutIndex( - Seq( - "".join( - [ - chr(int.from_bytes(pair, "big")) - for pair in zip( - *[iter(native_input.value.encode("utf-16-be"))] * 2 - ) - ] - ) - ) - ) - else: - raise ValueError( - "No recognized union value in union type: " + str(native_input) - ) + if native_input == "Created": + return InitializeMutationFlag_Created() + + elif native_input == "Resumed": + return InitializeMutationFlag_Resumed() - return InitializeMutationFlag_union_value + elif native_input == "ResumedWithoutIndex": + return InitializeMutationFlag_ResumedWithoutIndex() + + else: + raise ValueError(f"No recognized enum value in enum type: {native_input=}") def aws_cryptography_keystoreadmin_ApplyMutationOutput(native_input): @@ -576,26 +557,74 @@ def aws_cryptography_keystoreadmin_MutationComplete(native_input): def aws_cryptography_keystoreadmin_DescribeMutationOutput(native_input): return DafnyDescribeMutationOutput( - Original=( - ( - Option_Some( - aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.smithy_to_dafny.aws_cryptography_keystoreadmin_MutableBranchKeyProperities( - native_input.original - ) + MutationInFlight=aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.smithy_to_dafny.aws_cryptography_keystoreadmin_MutationInFlight( + native_input.mutation_in_flight + ), + ) + + +def aws_cryptography_keystoreadmin_MutationInFlight(native_input): + if isinstance( + native_input, + aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.models.MutationInFlightYes, + ): + MutationInFlight_union_value = MutationInFlight_Yes( + aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.smithy_to_dafny.aws_cryptography_keystoreadmin_MutationDescription( + native_input.value + ) + ) + elif isinstance( + native_input, + aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.models.MutationInFlightNo, + ): + MutationInFlight_union_value = MutationInFlight_No( + Seq( + "".join( + [ + chr(int.from_bytes(pair, "big")) + for pair in zip( + *[iter(native_input.value.encode("utf-16-be"))] * 2 + ) + ] ) ) - if (native_input.original is not None) - else (Option_None()) + ) + else: + raise ValueError( + "No recognized union value in union type: " + str(native_input) + ) + + return MutationInFlight_union_value + + +def aws_cryptography_keystoreadmin_MutationDescription(native_input): + return DafnyMutationDescription( + Original=aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.smithy_to_dafny.aws_cryptography_keystoreadmin_MutableBranchKeyProperities( + native_input.original + ), + Terminal=aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.smithy_to_dafny.aws_cryptography_keystoreadmin_MutableBranchKeyProperities( + native_input.terminal + ), + Input=aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.smithy_to_dafny.aws_cryptography_keystoreadmin_Mutations( + native_input.input ), - Terminal=( + SystemKey=( ( Option_Some( - aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystoreadmin.smithy_to_dafny.aws_cryptography_keystoreadmin_MutableBranchKeyProperities( - native_input.terminal + Seq( + "".join( + [ + chr(int.from_bytes(pair, "big")) + for pair in zip( + *[iter(native_input.system_key.encode("utf-16-be"))] + * 2 + ) + ] + ) ) ) ) - if (native_input.terminal is not None) + if (native_input.system_key is not None) else (Option_None()) ), ) From de27852d198a7c18feb41a75e32d4c18bec2bda0 Mon Sep 17 00:00:00 2001 From: texastony <5892063+texastony@users.noreply.github.com> Date: Mon, 4 Nov 2024 17:57:39 -0800 Subject: [PATCH 3/4] chore(KSA-Dafny): refactor code for model changes --- .../dafny/AwsCryptographyKeyStoreAdmin/src/Mutations.dfy | 6 +++--- .../test/Mutations/TestEncryptionContextChanged.dfy | 5 +++-- .../TestInitMutActiveAndBeaconAreInSameState.dfy | 3 ++- .../test/Mutations/TestKmsArnChanged.dfy | 5 +++-- .../test/Mutations/TestMutationsUnModeledAttribute.dfy | 5 +++-- .../test/Mutations/TestThreat27.dfy | 3 ++- .../test/Mutations/TestThreat28.dfy | 9 +++++---- 7 files changed, 21 insertions(+), 15 deletions(-) diff --git a/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/src/Mutations.dfy b/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/src/Mutations.dfy index c78c42fd6..b266aba12 100644 --- a/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/src/Mutations.dfy +++ b/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/src/Mutations.dfy @@ -404,7 +404,7 @@ module {:options "/functionSyntax:4" } Mutations { UUID := Some(mutationCommitmentUUID), CreateTime := timestamp); - var Flag: Types.InitializeMutationFlag := Types.Created(""); + var Flag: Types.InitializeMutationFlag := Types.Created(); return Success(Types.InitializeMutationOutput( MutationToken := Token, @@ -788,10 +788,10 @@ module {:options "/functionSyntax:4" } Mutations { var mutatedBranchKeyItems := [ Types.MutatedBranchKeyItem(ItemType := "Mutation Commitment: " + commitment.UUID, Description := "Matched Input") ]; - var Flag: Types.InitializeMutationFlag := Types.Resumed(""); + var Flag: Types.InitializeMutationFlag := Types.Resumed(); if (index.None?) { - Flag := Types.ResumedWithoutIndex(""); + Flag := Types.ResumedWithoutIndex(); var timestamp? := Time.GetCurrentTimeStamp(); var timestamp :- timestamp? .MapFailure(e => Types.KeyStoreAdminException( diff --git a/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/test/Mutations/TestEncryptionContextChanged.dfy b/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/test/Mutations/TestEncryptionContextChanged.dfy index 44634cac6..32226c7c1 100644 --- a/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/test/Mutations/TestEncryptionContextChanged.dfy +++ b/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/test/Mutations/TestEncryptionContextChanged.dfy @@ -71,7 +71,8 @@ module {:options "/functionSyntax:4" } TestEncryptionContextChanged { Identifier := testId, Mutations := mutationsRequest, Strategy := Some(strategy), - SystemKey := Types.SystemKey.trustStorage(trustStorage := Types.TrustStorage())); + SystemKey := Some(Types.SystemKey.trustStorage(trustStorage := Types.TrustStorage())), + DoNotVersion := Some(false)); var initializeOutput :- expect underTest.InitializeMutation(initInput); var initializeToken := initializeOutput.MutationToken; @@ -83,7 +84,7 @@ module {:options "/functionSyntax:4" } TestEncryptionContextChanged { MutationToken := initializeToken, PageSize := Some(24), Strategy := Some(strategy), - SystemKey := Types.SystemKey.trustStorage(trustStorage := Types.TrustStorage())); + SystemKey := Some(Types.SystemKey.trustStorage(trustStorage := Types.TrustStorage()))); var applyOutput :- expect underTest.ApplyMutation(testInput); print testLogPrefix + " Applied Mutation w/ pageSize 1. testId: " + testId + "\n"; diff --git a/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/test/Mutations/TestInitMutActiveAndBeaconAreInSameState.dfy b/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/test/Mutations/TestInitMutActiveAndBeaconAreInSameState.dfy index 630852a88..c0c6bcb76 100644 --- a/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/test/Mutations/TestInitMutActiveAndBeaconAreInSameState.dfy +++ b/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/test/Mutations/TestInitMutActiveAndBeaconAreInSameState.dfy @@ -66,7 +66,8 @@ module {:options "/functionSyntax:4" } TestInitMutActiveAndBeaconAreInSameState Identifier := testId, Mutations := mutationsRequest, Strategy := Some(strategy), - SystemKey := Types.SystemKey.trustStorage(trustStorage := Types.TrustStorage())); + SystemKey := Some(Types.SystemKey.trustStorage(trustStorage := Types.TrustStorage())), + DoNotVersion := Some(false)); var initializeOutput? := underTest.InitializeMutation(initInput); expect initializeOutput?.Failure?, "Initialize Mutation did not detect drifted Active & Beacon!"; diff --git a/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/test/Mutations/TestKmsArnChanged.dfy b/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/test/Mutations/TestKmsArnChanged.dfy index 3d3ca73e8..5cfa267d1 100644 --- a/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/test/Mutations/TestKmsArnChanged.dfy +++ b/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/test/Mutations/TestKmsArnChanged.dfy @@ -67,7 +67,8 @@ module {:options "/functionSyntax:4" } TestKmsArnChanged { Identifier := testId, Mutations := mutationsRequest, Strategy := Some(strategy), - SystemKey := Types.SystemKey.trustStorage(trustStorage := Types.TrustStorage())); + SystemKey := Some(Types.SystemKey.trustStorage(trustStorage := Types.TrustStorage())), + DoNotVersion := Some(false)); var initializeOutput :- expect underTest.InitializeMutation(initInput); var initializeToken := initializeOutput.MutationToken; @@ -78,7 +79,7 @@ module {:options "/functionSyntax:4" } TestKmsArnChanged { MutationToken := initializeToken, PageSize := Some(24), Strategy := Some(strategy), - SystemKey := Types.SystemKey.trustStorage(trustStorage := Types.TrustStorage())); + SystemKey := Some(Types.SystemKey.trustStorage(trustStorage := Types.TrustStorage()))); var applyOutput :- expect underTest.ApplyMutation(testInput); print testLogPrefix + " Applied Mutation w/ pageSize 24. testId: " + testId + "\n"; diff --git a/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/test/Mutations/TestMutationsUnModeledAttribute.dfy b/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/test/Mutations/TestMutationsUnModeledAttribute.dfy index a5790c3fd..6197d8531 100644 --- a/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/test/Mutations/TestMutationsUnModeledAttribute.dfy +++ b/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/test/Mutations/TestMutationsUnModeledAttribute.dfy @@ -77,7 +77,8 @@ module {:options "/functionSyntax:4" } TestMutationsUnModeledAttribute { Identifier := testId, Mutations := mutationsRequest, Strategy := Some(strategy), - SystemKey := Types.SystemKey.trustStorage(trustStorage := Types.TrustStorage())); + SystemKey := Some(Types.SystemKey.trustStorage(trustStorage := Types.TrustStorage())), + DoNotVersion := Some(false)); var initializeOutput :- expect underTest.InitializeMutation(initInput); var initializeToken := initializeOutput.MutationToken; @@ -87,7 +88,7 @@ module {:options "/functionSyntax:4" } TestMutationsUnModeledAttribute { MutationToken := initializeToken, PageSize := Some(24), Strategy := Some(strategy), - SystemKey := Types.SystemKey.trustStorage(trustStorage := Types.TrustStorage())); + SystemKey := Some(Types.SystemKey.trustStorage(trustStorage := Types.TrustStorage()))); var applyOutput :- expect underTest.ApplyMutation(testInput); print testLogPrefix + " Applied Mutation w/ pageSize 24. testId: " + testId + "\n"; diff --git a/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/test/Mutations/TestThreat27.dfy b/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/test/Mutations/TestThreat27.dfy index 1c9cc5e9c..1a20d3d47 100644 --- a/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/test/Mutations/TestThreat27.dfy +++ b/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/test/Mutations/TestThreat27.dfy @@ -84,7 +84,8 @@ module {:options "/functionSyntax:4" } TestThreat27 { Identifier := testId, Mutations := mutationsRequest, Strategy := Some(strategy), - SystemKey := Types.SystemKey.trustStorage(trustStorage := Types.TrustStorage())); + SystemKey := Some(Types.SystemKey.trustStorage(trustStorage := Types.TrustStorage())), + DoNotVersion := Some(false)); var initializeOutput :- expect underTest.InitializeMutation(testInput); print "\nTestThreat27 :: TestHappyCase :: Initialized Mutation: " + activeOne + "\n"; diff --git a/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/test/Mutations/TestThreat28.dfy b/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/test/Mutations/TestThreat28.dfy index 466781e6f..24d17c373 100644 --- a/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/test/Mutations/TestThreat28.dfy +++ b/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/test/Mutations/TestThreat28.dfy @@ -83,7 +83,8 @@ module {:options "/functionSyntax:4" } TestThreat28 { Identifier := testId, Mutations := mutationsRequest, Strategy := Some(strategy), - SystemKey := Types.SystemKey.trustStorage(trustStorage := Types.TrustStorage())); + SystemKey := Some(Types.SystemKey.trustStorage(trustStorage := Types.TrustStorage())), + DoNotVersion := Some(false)); var initializeOutput :- expect underTest.InitializeMutation(initInput); var initializeToken := initializeOutput.MutationToken; @@ -95,7 +96,7 @@ module {:options "/functionSyntax:4" } TestThreat28 { MutationToken := initializeToken, PageSize := Some(1), //Some(24), Strategy := Some(strategy), - SystemKey := Types.SystemKey.trustStorage(trustStorage := Types.TrustStorage())); + SystemKey := Some(Types.SystemKey.trustStorage(trustStorage := Types.TrustStorage()))); // var applyOutput :- expect underTest.ApplyMutation(testInput); var applyOutput? := underTest.ApplyMutation(testInput); if (applyOutput?.Failure?) { @@ -114,7 +115,7 @@ module {:options "/functionSyntax:4" } TestThreat28 { MutationToken := applyToken, PageSize := Some(1), Strategy := Some(strategy), - SystemKey := Types.SystemKey.trustStorage(trustStorage := Types.TrustStorage())); + SystemKey := Some(Types.SystemKey.trustStorage(trustStorage := Types.TrustStorage()))); applyOutput? := underTest.ApplyMutation(testInput); if (applyOutput?.Failure?) { print applyOutput?; @@ -131,7 +132,7 @@ module {:options "/functionSyntax:4" } TestThreat28 { MutationToken := applyToken, PageSize := Some(1), Strategy := Some(strategy), - SystemKey := Types.SystemKey.trustStorage(trustStorage := Types.TrustStorage())); + SystemKey := Some(Types.SystemKey.trustStorage(trustStorage := Types.TrustStorage()))); applyOutput? := underTest.ApplyMutation(testInput); if (applyOutput?.Failure?) { print applyOutput?; From 67c52ab055bc7c5d03d73cfcbb5a0db6adaabd61 Mon Sep 17 00:00:00 2001 From: texastony <5892063+texastony@users.noreply.github.com> Date: Mon, 4 Nov 2024 21:35:44 -0800 Subject: [PATCH 4/4] chore(KSA-Dafny): allow for non-required System Key and Do Not Version --- ...AwsCryptographyKeyStoreAdminOperations.dfy | 28 +++++++- .../src/Mutations.dfy | 71 ++++++++++++------- 2 files changed, 73 insertions(+), 26 deletions(-) diff --git a/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/src/AwsCryptographyKeyStoreAdminOperations.dfy b/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/src/AwsCryptographyKeyStoreAdminOperations.dfy index 01709d944..bf66e30f2 100644 --- a/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/src/AwsCryptographyKeyStoreAdminOperations.dfy +++ b/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/src/AwsCryptographyKeyStoreAdminOperations.dfy @@ -36,6 +36,20 @@ module AwsCryptographyKeyStoreAdminOperations refines AbstractAwsCryptographyKey function {:opaque} MutationLie(): set {{}} + function method DefaultSystemKey( + input: Option := None + ): (output: Types.SystemKey) + { + if input.None? then Types.SystemKey.trustStorage(TrustStorage()) else input.value + } + + function method DefaultInitializeMutationDoNotVersion( + input: Option := None + ): (output: bool) + { + if input.None? then false else input.value + } + function ModifiesInternalConfig(config: InternalConfig) : set { config.storage.Modifies + MutationLie() @@ -280,8 +294,18 @@ module AwsCryptographyKeyStoreAdminOperations refines AbstractAwsCryptographyKey // See Smithy-Dafny : https://github.com/smithy-lang/smithy-dafny/pull/543 assume {:axiom} keyManagerStrat.reEncrypt.kmsClient.Modifies < MutationLie(); - var _ :- Mutations.ValidateInitializeMutationInput(input, config.logicalKeyStoreName); - output := Mutations.InitializeMutation(input, config.logicalKeyStoreName, keyManagerStrat, config.storage); + var internalInput := Mutations.InternalInitializeMutationInput( + Identifier := input.Identifier, + Mutations := input.Mutations, + SystemKey := DefaultSystemKey(input.SystemKey), + DoNotVersion := DefaultInitializeMutationDoNotVersion(input.DoNotVersion), + logicalKeyStoreName := config.logicalKeyStoreName, + keyManagerStrategy := keyManagerStrat, + storage := config.storage + ); + + var _ :- Mutations.ValidateInitializeMutationInput(internalInput); + output := Mutations.InitializeMutation(internalInput); return output; } diff --git a/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/src/Mutations.dfy b/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/src/Mutations.dfy index b266aba12..8d5037044 100644 --- a/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/src/Mutations.dfy +++ b/AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/src/Mutations.dfy @@ -47,14 +47,23 @@ module {:options "/functionSyntax:4" } Mutations { | forall i <- s :: !i.itemNeither? witness * + datatype InternalInitializeMutationInput = | InternalInitializeMutationInput ( + nameonly Identifier: string , + nameonly Mutations: Types.Mutations , + nameonly SystemKey: Types.SystemKey , + nameonly DoNotVersion: bool, + nameonly logicalKeyStoreName: string, + nameonly keyManagerStrategy: KmsUtils.keyManagerStrat, + nameonly storage: Types.AwsCryptographyKeyStoreTypes.IKeyStorageInterface + ) + // Ensures: // Branch Key ID is set // Mutations List is valid // logicalKeyStoreName is valid function {:vcs_split_on_every_assert} ValidateInitializeMutationInput( - input: Types.InitializeMutationInput, - logicalKeyStoreName: string - ): (output: Result) + input: InternalInitializeMutationInput + ): (output: Result) ensures output.Success? ==> @@ -64,8 +73,24 @@ module {:options "/functionSyntax:4" } Mutations { && input.Mutations.TerminalKmsArn.Some? ==> && KmsArn.ValidKmsArn?(input.Mutations.TerminalKmsArn.value) - + ensures + && output.Success? + ==> + input.DoNotVersion == false + ensures + && output.Success? + ==> + input.SystemKey.trustStorage? { + :- Need( + input.DoNotVersion == false, + Types.UnsupportedFeatureException(message := "At this time, DoNotVersion MUST be false.") + ); + :- Need( + input.SystemKey.trustStorage?, + Types.UnsupportedFeatureException(message := "At this time, SystemKey MUST be TrustStorage.") + ); + :- Need(|input.Identifier| > 0, Types.KeyStoreAdminException(message := "Branch Key Identifier cannot be empty!")); var terminalEC := input.Mutations.TerminalEncryptionContext.UnwrapOr(map[]); @@ -104,35 +129,33 @@ module {:options "/functionSyntax:4" } Mutations { } method {:vcs_split_on_every_assert} InitializeMutation( - input: Types.InitializeMutationInput, - logicalKeyStoreName: string, - keyManagerStrategy: KmsUtils.keyManagerStrat, - storage: Types.AwsCryptographyKeyStoreTypes.IKeyStorageInterface + input: InternalInitializeMutationInput ) returns (output: Result) - requires ValidateInitializeMutationInput(input, logicalKeyStoreName).Success? + requires ValidateInitializeMutationInput(input).Success? requires StateStrucs.ValidMutations?(input.Mutations) // may not need this - requires storage.ValidState() && - match keyManagerStrategy + requires input.storage.ValidState() && + match input.keyManagerStrategy case reEncrypt(km) => km.kmsClient.ValidState() && AwsKmsUtils.GetValidGrantTokens(Some(km.grantTokens)).Success? case decryptEncrypt(kmD, kmE) => && kmD.kmsClient.ValidState() && kmE.kmsClient.ValidState() && AwsKmsUtils.GetValidGrantTokens(Some(kmD.grantTokens)).Success? && AwsKmsUtils.GetValidGrantTokens(Some(kmE.grantTokens)).Success? - ensures storage.ValidState() && - match keyManagerStrategy + ensures input.storage.ValidState() && + match input.keyManagerStrategy case reEncrypt(km) => km.kmsClient.ValidState() case decryptEncrypt(kmD, kmE) => kmD.kmsClient.ValidState() && kmE.kmsClient.ValidState() modifies - storage.Modifies, - match keyManagerStrategy + input.storage.Modifies, + match input.keyManagerStrategy case reEncrypt(km) => km.kmsClient.Modifies case decryptEncrypt(kmD, kmE) => kmD.kmsClient.Modifies + kmE.kmsClient.Modifies - requires keyManagerStrategy.reEncrypt? + requires input.keyManagerStrategy.reEncrypt? { - var keyManager := keyManagerStrategy.reEncrypt; + var keyManager := input.keyManagerStrategy.reEncrypt; var resumeMutation? := false; - + var storage := input.storage; + var logicalKeyStoreName := input.logicalKeyStoreName; // Fetch Active Branch Key & Beacon Key & Mutation Lock var readItems? := storage.GetItemsForInitializeMutation( Types.AwsCryptographyKeyStoreTypes.GetItemsForInitializeMutationInput(Identifier := input.Identifier)); @@ -183,7 +206,7 @@ module {:options "/functionSyntax:4" } Mutations { var activeItem := readItems.ActiveItem; :- Need( - || storage is DefaultKeyStorageInterface.DynamoDBKeyStorageInterface + || input.storage is DefaultKeyStorageInterface.DynamoDBKeyStorageInterface || ( && readItems.ActiveItem.Identifier == input.Identifier && Structure.ActiveHierarchicalSymmetricKey?(readItems.ActiveItem) @@ -195,7 +218,7 @@ module {:options "/functionSyntax:4" } Mutations { ); :- Need( - || storage is DefaultKeyStorageInterface.DynamoDBKeyStorageInterface + || input.storage is DefaultKeyStorageInterface.DynamoDBKeyStorageInterface || ( && readItems.BeaconItem.Identifier == input.Identifier && Structure.ActiveHierarchicalSymmetricBeaconKey?(readItems.BeaconItem) @@ -282,7 +305,7 @@ module {:options "/functionSyntax:4" } Mutations { // --= Validate Active Branch Key var verifyActive? := VerifyEncryptedHierarchicalKey( item := activeItem, - keyManagerStrategy := keyManagerStrategy + keyManagerStrategy :=input.keyManagerStrategy ); if (verifyActive?.Fail?) { return Failure( @@ -350,7 +373,7 @@ module {:options "/functionSyntax:4" } Mutations { originalKmsArn := MutationToApply.Terminal.kmsArn, terminalKmsArn := MutationToApply.Terminal.kmsArn, terminalEncryptionContext := ActiveEncryptionContext, - keyManagerStrategy := keyManagerStrategy + keyManagerStrategy := input.keyManagerStrategy ); // -= Mutate Beacon Key @@ -370,7 +393,7 @@ module {:options "/functionSyntax:4" } Mutations { originalKmsArn := MutationToApply.Original.kmsArn, terminalKmsArn := MutationToApply.Terminal.kmsArn, terminalEncryptionContext := BeaconEncryptionContext, - keyManagerStrategy := keyManagerStrategy + keyManagerStrategy := input.keyManagerStrategy ); // -= Create Mutation Commitment @@ -764,7 +787,7 @@ module {:options "/functionSyntax:4" } Mutations { // Note: Assumes the System Key has already verified function CommitmentAndInputMatch( - nameonly input: Types.InitializeMutationInput, + nameonly input: InternalInitializeMutationInput, nameonly commitment: KeyStoreTypes.MutationCommitment ): (output: Result) {