From d4ba279972719c87f5e84f014f99bd565d8328a3 Mon Sep 17 00:00:00 2001 From: texastony <5892063+texastony@users.noreply.github.com> Date: Mon, 4 Nov 2024 15:05:51 -0800 Subject: [PATCH] fix: Smithy Generated Python was poorly rebased --- .../WriteInitializeMutationIndex.cs | 40 ------ .../dafny_to_smithy.py | 73 ++-------- .../aws_cryptography_keystore/references.py | 130 ++---------------- .../smithy_to_dafny.py | 54 ++------ 4 files changed, 33 insertions(+), 264 deletions(-) delete mode 100644 AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStore/WriteInitializeMutationIndex.cs diff --git a/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStore/WriteInitializeMutationIndex.cs b/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStore/WriteInitializeMutationIndex.cs deleted file mode 100644 index 87ffee6b9..000000000 --- a/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStore/WriteInitializeMutationIndex.cs +++ /dev/null @@ -1,40 +0,0 @@ -// 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.KeyStore; -namespace AWS.Cryptography.KeyStore -{ - public class WriteInitializeMutationIndex - { - private AWS.Cryptography.KeyStore.MutationIndex _create; - private AWS.Cryptography.KeyStore.OverWriteMutationIndex _update; - public AWS.Cryptography.KeyStore.MutationIndex Create - { - get { return this._create; } - set { this._create = value; } - } - public bool IsSetCreate() - { - return this._create != null; - } - public AWS.Cryptography.KeyStore.OverWriteMutationIndex Update - { - get { return this._update; } - set { this._update = value; } - } - public bool IsSetUpdate() - { - return this._update != null; - } - public void Validate() - { - var numberOfPropertiesSet = Convert.ToUInt16(IsSetCreate()) + - Convert.ToUInt16(IsSetUpdate()); - 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/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystore/dafny_to_smithy.py b/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystore/dafny_to_smithy.py index db7014f61..24df49bc0 100644 --- a/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystore/dafny_to_smithy.py +++ b/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystore/dafny_to_smithy.py @@ -312,30 +312,6 @@ def aws_cryptography_keystore_WriteInitializeMutationInput(dafny_input): mutation_index=aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_MutationIndex( dafny_input.MutationIndex ), - mutation_index=( - ( - aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_MutationIndex( - dafny_input.MutationIndex.value - ) - ) - if (dafny_input.MutationIndex.is_Some) - else None - ), - over_write_mutation_index=( - ( - aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_OverWriteMutationIndex( - dafny_input.OverWriteMutationIndex.value - ) - ) - if (dafny_input.OverWriteMutationIndex.is_Some) - else None - ), - versions=[ - aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_OverWriteEncryptedHierarchicalKey( - list_element - ) - for list_element in dafny_input.Versions - ], ) @@ -432,25 +408,8 @@ def aws_cryptography_keystore_WriteMutatedVersionsOutput(dafny_input): ) -def aws_cryptography_keystore_UpdateMutationIndexInput(dafny_input): - return aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.models.UpdateMutationIndexInput( - mutation_index=aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_MutationIndex( - dafny_input.MutationIndex - ), - old_mutation_index=aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_MutationIndex( - dafny_input.OldMutationIndex - ), - ) - - -def aws_cryptography_keystore_UpdateMutationIndexOutput(dafny_input): - return ( - aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.models.UpdateMutationIndexOutput() - ) - - -def aws_cryptography_keystore_GetMutationLockInput(dafny_input): - return aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystore.models.GetMutationLockInput( +def aws_cryptography_keystore_GetMutationInput(dafny_input): + return aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystore.models.GetMutationInput( identifier=b"".join( ord(c).to_bytes(2, "big") for c in dafny_input.Identifier ).decode("utf-16-be"), @@ -465,7 +424,16 @@ def aws_cryptography_keystore_GetMutationOutput(dafny_input): dafny_input.MutationCommitment.value ) ) - if (dafny_input.MutationLock.is_Some) + if (dafny_input.MutationCommitment.is_Some) + else None + ), + mutation_index=( + ( + aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_MutationIndex( + dafny_input.MutationIndex.value + ) + ) + if (dafny_input.MutationIndex.is_Some) else None ), ) @@ -502,23 +470,6 @@ def aws_cryptography_keystore_WriteMutationIndexOutput(dafny_input): ) -def aws_cryptography_keystore_WriteMutationIndexInput(dafny_input): - return aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.models.WriteMutationIndexInput( - mutation_commitment=aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_MutationCommitment( - dafny_input.MutationCommitment - ), - mutation_index=aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_MutationIndex( - dafny_input.MutationIndex - ), - ) - - -def aws_cryptography_keystore_WriteMutationIndexOutput(dafny_input): - return ( - aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.models.WriteMutationIndexOutput() - ) - - def smithy_api_Unit(): return ( aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystore.models.Unit() diff --git a/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystore/references.py b/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystore/references.py index 6d48c357c..2fc07efc1 100644 --- a/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystore/references.py +++ b/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystore/references.py @@ -235,17 +235,9 @@ def write_mutated_versions( @abc.abstractmethod def get_mutation( self, - param: "aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.models.UpdateMutationIndexInput", - ) -> "aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.models.UpdateMutationIndexOutput": - """Updates a Mutation Index.""" - raise NotImplementedError - - @abc.abstractmethod - def get_mutation_lock( - self, - param: "aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystore.models.GetMutationLockInput", - ) -> "aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystore.models.GetMutationLockOutput": - """Check for Mutation Lock on a Branch Key ID. + param: "aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystore.models.GetMutationInput", + ) -> "aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystore.models.GetMutationOutput": + """Check for Mutation Commitment on a Branch Key ID. If one exists, returns the Mutation Lock. Otherwise, returns nothing. @@ -273,19 +265,6 @@ def write_mutation_index( """ raise NotImplementedError - @abc.abstractmethod - def write_mutation_index( - self, - param: "aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.models.WriteMutationIndexInput", - ) -> "aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.models.WriteMutationIndexOutput": - """Creates a Mutation Index, conditioned on the Mutation Commitment. - - Used in the edge case where the Commitment exists and Index does - not. The Index may have been deleted to restart the mutation - from the very begining. - """ - raise NotImplementedError - def WriteNewEncryptedBranchKey( self, dafny_input: "DafnyWriteNewEncryptedBranchKeyInput" ) -> "DafnyWriteNewEncryptedBranchKeyOutput": @@ -525,12 +504,12 @@ def GetMutation( This method allows custom implementations of this interface to interact with generated code. """ - native_input = aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_GetMutationInput( + native_input = aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_GetMutationInput( dafny_input ) try: native_output = self.get_mutation(native_input) - dafny_output = aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.smithy_to_dafny.aws_cryptography_keystore_GetMutationOutput( + dafny_output = aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystore.smithy_to_dafny.aws_cryptography_keystore_GetMutationOutput( native_output ) return Wrappers.Result_Success(dafny_output) @@ -546,28 +525,7 @@ def DeleteMutation( This method allows custom implementations of this interface to interact with generated code. """ - native_input = aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_GetMutationLockInput( - dafny_input - ) - try: - native_output = self.get_mutation_lock(native_input) - dafny_output = aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystore.smithy_to_dafny.aws_cryptography_keystore_GetMutationLockOutput( - native_output - ) - return Wrappers.Result_Success(dafny_output) - except Exception as e: - error = _smithy_error_to_dafny_error(e) - return Wrappers.Result_Failure(error) - - def GetMutationLockAndIndex( - self, dafny_input: "DafnyGetMutationLockAndIndexInput" - ) -> "DafnyGetMutationLockAndIndexOutput": - """Do not use. - - This method allows custom implementations of this interface to - interact with generated code. - """ - native_input = aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_ClobberMutationLockInput( + native_input = aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_DeleteMutationInput( dafny_input ) try: @@ -601,27 +559,6 @@ def WriteMutationIndex( error = _smithy_error_to_dafny_error(e) return Wrappers.Result_Failure(error) - def WriteMutationIndex( - self, dafny_input: "DafnyWriteMutationIndexInput" - ) -> "DafnyWriteMutationIndexOutput": - """Do not use. - - This method allows custom implementations of this interface to - interact with generated code. - """ - native_input = aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_WriteMutationIndexInput( - dafny_input - ) - try: - native_output = self.write_mutation_index(native_input) - dafny_output = aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.smithy_to_dafny.aws_cryptography_keystore_WriteMutationIndexOutput( - native_output - ) - return Wrappers.Result_Success(dafny_output) - except Exception as e: - error = _smithy_error_to_dafny_error(e) - return Wrappers.Result_Failure(error) - class KeyStorageInterface(IKeyStorageInterface): @@ -943,31 +880,9 @@ def write_mutated_versions( def get_mutation( self, - param: "aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.models.UpdateMutationIndexInput", - ) -> "aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.models.UpdateMutationIndexOutput": - """Updates a Mutation Index.""" - dafny_output = self._impl.UpdateMutationIndex( - aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.smithy_to_dafny.aws_cryptography_keystore_UpdateMutationIndexInput( - param - ) - ) - if dafny_output.IsFailure(): - from aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.deserialize import ( - _deserialize_error as aws_cryptography_keystore_deserialize_error, - ) - - raise aws_cryptography_keystore_deserialize_error(dafny_output.error) - - else: - return aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_UpdateMutationIndexOutput( - dafny_output.value - ) - - def get_mutation_lock( - self, - param: "aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystore.models.GetMutationLockInput", - ) -> "aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystore.models.GetMutationLockOutput": - """Check for Mutation Lock on a Branch Key ID. + param: "aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystore.models.GetMutationInput", + ) -> "aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystore.models.GetMutationOutput": + """Check for Mutation Commitment on a Branch Key ID. If one exists, returns the Mutation Lock. Otherwise, returns nothing. @@ -1038,33 +953,6 @@ def write_mutation_index( dafny_output.value ) - def write_mutation_index( - self, - param: "aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.models.WriteMutationIndexInput", - ) -> "aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.models.WriteMutationIndexOutput": - """Creates a Mutation Index, conditioned on the Mutation Commitment. - - Used in the edge case where the Commitment exists and Index does - not. The Index may have been deleted to restart the mutation - from the very begining. - """ - dafny_output = self._impl.WriteMutationIndex( - aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.smithy_to_dafny.aws_cryptography_keystore_WriteMutationIndexInput( - param - ) - ) - if dafny_output.IsFailure(): - from aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.deserialize import ( - _deserialize_error as aws_cryptography_keystore_deserialize_error, - ) - - raise aws_cryptography_keystore_deserialize_error(dafny_output.error) - - else: - return aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_WriteMutationIndexOutput( - dafny_output.value - ) - @staticmethod def from_dict(d: Dict[str, Any]) -> "KeyStorageInterface": return KeyStorageInterface(d["_impl"]) diff --git a/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystore/smithy_to_dafny.py b/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystore/smithy_to_dafny.py index b3e33f269..9a66517eb 100644 --- a/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystore/smithy_to_dafny.py +++ b/AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystore/smithy_to_dafny.py @@ -490,47 +490,6 @@ def aws_cryptography_keystore_WriteInitializeMutationInput(native_input): MutationIndex=aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystore.smithy_to_dafny.aws_cryptography_keystore_MutationIndex( native_input.mutation_index ), - MutationIndex=( - ( - Option_Some( - aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.smithy_to_dafny.aws_cryptography_keystore_MutationIndex( - native_input.mutation_index - ) - ) - ) - if (native_input.mutation_index is not None) - else (Option_None()) - ), - OverWriteMutationIndex=( - ( - Option_Some( - aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.smithy_to_dafny.aws_cryptography_keystore_OverWriteMutationIndex( - native_input.over_write_mutation_index - ) - ) - ) - if (native_input.over_write_mutation_index is not None) - else (Option_None()) - ), - Versions=Seq( - [ - aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.smithy_to_dafny.aws_cryptography_keystore_OverWriteEncryptedHierarchicalKey( - list_element - ) - for list_element in native_input.versions - ] - ), - ) - - -def aws_cryptography_keystore_OverWriteMutationIndex(native_input): - return DafnyOverWriteMutationIndex( - Index=aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.smithy_to_dafny.aws_cryptography_keystore_MutationIndex( - native_input.index - ), - Old=aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.smithy_to_dafny.aws_cryptography_keystore_MutationIndex( - native_input.old - ), ) @@ -686,7 +645,18 @@ def aws_cryptography_keystore_GetMutationOutput(native_input): ) ) ) - if (native_input.mutation_lock is not None) + if (native_input.mutation_commitment is not None) + else (Option_None()) + ), + MutationIndex=( + ( + Option_Some( + aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystore.smithy_to_dafny.aws_cryptography_keystore_MutationIndex( + native_input.mutation_index + ) + ) + ) + if (native_input.mutation_index is not None) else (Option_None()) ), )