Skip to content

Commit

Permalink
Python: Re-polymorph (#568)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmcdonald3 authored Aug 12, 2024
1 parent fc062e1 commit 0552aa8
Show file tree
Hide file tree
Showing 50 changed files with 6,330 additions and 516 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# Code generated by smithy-python-codegen DO NOT EDIT.
# 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.
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Code generated by smithy-python-codegen DO NOT EDIT.
# 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.

import asyncio
from asyncio import sleep
from software_amazon_cryptography_keystore_internaldafny_types import IKeyStoreClient
from aws_cryptographic_materialproviders.internaldafny.generated.AwsCryptographyKeyStoreTypes import (
IKeyStoreClient,
)
from typing import Awaitable, Callable, TypeVar, cast

from .config import Config, KeyStoreConfig
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Code generated by smithy-python-codegen DO NOT EDIT.
# 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.

from aws_cryptographic_materialproviders.internaldafny.generated.AwsCryptographyKeyStoreTypes import (
KeyStoreConfig_KeyStoreConfig as DafnyKeyStoreConfig,
)
import aws_cryptographic_materialproviders.internaldafny.generated.module_
import aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.dafny_to_smithy
import aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.smithy_to_dafny
from dataclasses import dataclass
import module_
from software_amazon_cryptography_keystore_internaldafny_types import (
KeyStoreConfig_KeyStoreConfig as DafnyKeyStoreConfig,
)
from typing import Any, Callable, Optional, TypeAlias

from .dafnyImplInterface import DafnyImplInterface
Expand Down Expand Up @@ -80,15 +82,19 @@ def __init__(
"""Constructor for KeyStoreConfig.
:param ddb_table_name: The DynamoDB table name that backs this Key Store.
:param kms_configuration: The AWS KMS Key that protects this Key Store.
:param kms_configuration: Configures Key Store's KMS Key ARN restrictions.
:param logical_key_store_name: The logical name for this Key Store, which is
cryptographically bound to the keys it holds.
cryptographically bound to the keys it holds. This appears in the Encryption
Context of KMS requests as `tablename`.
:param id: An identifier for this Key Store.
:param grant_tokens: The AWS KMS grant tokens that are used when this Key Store
calls to AWS KMS.
:param ddb_client: The DynamoDB client this Key Store uses to call Amazon
DynamoDB.
:param kms_client: The KMS client this Key Store uses to call AWS KMS.
DynamoDB. If None is provided and the KMS ARN is, the KMS ARN is used to
determine the Region of the default client.
:param kms_client: The KMS client this Key Store uses to call AWS KMS. If None
is provided and the KMS ARN is, the KMS ARN is used to determine the Region of
the default client.
"""
super().__init__()
self.ddb_table_name = ddb_table_name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Code generated by smithy-python-codegen DO NOT EDIT.
# 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.

from software_amazon_cryptography_keystore_internaldafny import KeyStoreClient
from aws_cryptographic_materialproviders.internaldafny.generated.KeyStore import (
KeyStoreClient,
)
from .dafny_protocol import DafnyRequest


Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# Code generated by smithy-python-codegen DO NOT EDIT.
# 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.

import module_
from software_amazon_cryptography_keystore_internaldafny_types import (
from aws_cryptographic_materialproviders.internaldafny.generated.AwsCryptographyKeyStoreTypes import (
CreateKeyInput_CreateKeyInput as DafnyCreateKeyInput,
CreateKeyStoreInput_CreateKeyStoreInput as DafnyCreateKeyStoreInput,
GetActiveBranchKeyInput_GetActiveBranchKeyInput as DafnyGetActiveBranchKeyInput,
GetBeaconKeyInput_GetBeaconKeyInput as DafnyGetBeaconKeyInput,
GetBranchKeyVersionInput_GetBranchKeyVersionInput as DafnyGetBranchKeyVersionInput,
VersionKeyInput_VersionKeyInput as DafnyVersionKeyInput,
)
import aws_cryptographic_materialproviders.internaldafny.generated.module_


import Wrappers
import standard_library.internaldafny.generated.Wrappers as Wrappers
from typing import Union


Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# Code generated by smithy-python-codegen DO NOT EDIT.
# 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.

import UTF8
import aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.dafny_to_smithy
import aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.models
from software_amazon_cryptography_keystore_internaldafny_types import (
from aws_cryptographic_materialproviders.internaldafny.generated.AwsCryptographyKeyStoreTypes import (
KMSConfiguration_discovery,
KMSConfiguration_kmsKeyArn,
KMSConfiguration_kmsMRKeyArn,
KMSConfiguration_mrDiscovery,
)
import aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.dafny_to_smithy
import aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.models
from standard_library.internaldafny.generated import UTF8


def smithy_api_Unit():
Expand All @@ -30,12 +35,8 @@ def aws_cryptography_keystore_CreateKeyInput(dafny_input):
encryption_context=(
(
{
bytes(
"".join(UTF8.default__.Decode(key).value.Elements),
encoding="utf-8",
): bytes(
"".join(UTF8.default__.Decode(value).value.Elements),
encoding="utf-8",
"".join(UTF8.default__.Decode(key).value.Elements): "".join(
UTF8.default__.Decode(value).value.Elements
)
for (key, value) in dafny_input.encryptionContext.value.items
}
Expand Down Expand Up @@ -77,12 +78,40 @@ def aws_cryptography_keystore_KMSConfiguration(dafny_input):
KMSConfiguration_union_value = aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.models.KMSConfigurationKmsKeyArn(
dafny_input.kmsKeyArn.VerbatimString(False)
)
elif isinstance(dafny_input, KMSConfiguration_kmsMRKeyArn):
KMSConfiguration_union_value = aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.models.KMSConfigurationKmsMRKeyArn(
dafny_input.kmsMRKeyArn.VerbatimString(False)
)
elif isinstance(dafny_input, KMSConfiguration_discovery):
KMSConfiguration_union_value = aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.models.KMSConfigurationDiscovery(
aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_Discovery(
dafny_input.discovery
)
)
elif isinstance(dafny_input, KMSConfiguration_mrDiscovery):
KMSConfiguration_union_value = aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.models.KMSConfigurationMrDiscovery(
aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_MRDiscovery(
dafny_input.mrDiscovery
)
)
else:
raise ValueError("No recognized union value in union type: " + str(dafny_input))

return KMSConfiguration_union_value


def aws_cryptography_keystore_Discovery(dafny_input):
return (
aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.models.Discovery()
)


def aws_cryptography_keystore_MRDiscovery(dafny_input):
return aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.models.MRDiscovery(
region=dafny_input.region.VerbatimString(False),
)


def aws_cryptography_keystore_GetKeyStoreInfoOutput(dafny_input):
return aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.models.GetKeyStoreInfoOutput(
key_store_id=dafny_input.keyStoreId.VerbatimString(False),
Expand Down Expand Up @@ -119,15 +148,12 @@ def aws_cryptography_keystore_VersionKeyOutput(dafny_input):
def aws_cryptography_keystore_BranchKeyMaterials(dafny_input):
return aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.models.BranchKeyMaterials(
branch_key_identifier=dafny_input.branchKeyIdentifier.VerbatimString(False),
branch_key_version=bytes(
"".join(UTF8.default__.Decode(dafny_input.branchKeyVersion).value.Elements),
encoding="utf-8",
branch_key_version="".join(
UTF8.default__.Decode(dafny_input.branchKeyVersion).value.Elements
),
encryption_context={
bytes(
"".join(UTF8.default__.Decode(key).value.Elements), encoding="utf-8"
): bytes(
"".join(UTF8.default__.Decode(value).value.Elements), encoding="utf-8"
"".join(UTF8.default__.Decode(key).value.Elements): "".join(
UTF8.default__.Decode(value).value.Elements
)
for (key, value) in dafny_input.encryptionContext.items
},
Expand Down Expand Up @@ -155,10 +181,8 @@ def aws_cryptography_keystore_BeaconKeyMaterials(dafny_input):
return aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.models.BeaconKeyMaterials(
beacon_key_identifier=dafny_input.beaconKeyIdentifier.VerbatimString(False),
encryption_context={
bytes(
"".join(UTF8.default__.Decode(key).value.Elements), encoding="utf-8"
): bytes(
"".join(UTF8.default__.Decode(value).value.Elements), encoding="utf-8"
"".join(UTF8.default__.Decode(key).value.Elements): "".join(
UTF8.default__.Decode(value).value.Elements
)
for (key, value) in dafny_input.encryptionContext.items
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Code generated by smithy-python-codegen DO NOT EDIT.
# 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.

import _dafny
import aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.dafny_to_smithy
import module_
from software_amazon_cryptography_keystore_internaldafny_types import (
from aws_cryptographic_materialproviders.internaldafny.generated.AwsCryptographyKeyStoreTypes import (
CreateKeyOutput_CreateKeyOutput as DafnyCreateKeyOutput,
CreateKeyStoreOutput_CreateKeyStoreOutput as DafnyCreateKeyStoreOutput,
Error,
Expand All @@ -14,6 +14,8 @@
GetKeyStoreInfoOutput_GetKeyStoreInfoOutput as DafnyGetKeyStoreInfoOutput,
VersionKeyOutput_VersionKeyOutput as DafnyVersionKeyOutput,
)
import aws_cryptographic_materialproviders.internaldafny.generated.module_
import aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.dafny_to_smithy
from typing import Any

from .dafny_protocol import DafnyResponse
Expand All @@ -38,7 +40,7 @@
async def _deserialize_get_key_store_info(input: DafnyResponse, config: Config):

if input.IsFailure():
return await _deserialize_error(input.error)
return _deserialize_error(input.error)
return aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_GetKeyStoreInfoOutput(
input.value
)
Expand All @@ -47,7 +49,7 @@ async def _deserialize_get_key_store_info(input: DafnyResponse, config: Config):
async def _deserialize_create_key_store(input: DafnyResponse, config: Config):

if input.IsFailure():
return await _deserialize_error(input.error)
return _deserialize_error(input.error)
return aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_CreateKeyStoreOutput(
input.value
)
Expand All @@ -56,7 +58,7 @@ async def _deserialize_create_key_store(input: DafnyResponse, config: Config):
async def _deserialize_create_key(input: DafnyResponse, config: Config):

if input.IsFailure():
return await _deserialize_error(input.error)
return _deserialize_error(input.error)
return aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_CreateKeyOutput(
input.value
)
Expand All @@ -65,7 +67,7 @@ async def _deserialize_create_key(input: DafnyResponse, config: Config):
async def _deserialize_version_key(input: DafnyResponse, config: Config):

if input.IsFailure():
return await _deserialize_error(input.error)
return _deserialize_error(input.error)
return aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_VersionKeyOutput(
input.value
)
Expand All @@ -74,7 +76,7 @@ async def _deserialize_version_key(input: DafnyResponse, config: Config):
async def _deserialize_get_active_branch_key(input: DafnyResponse, config: Config):

if input.IsFailure():
return await _deserialize_error(input.error)
return _deserialize_error(input.error)
return aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_GetActiveBranchKeyOutput(
input.value
)
Expand All @@ -83,7 +85,7 @@ async def _deserialize_get_active_branch_key(input: DafnyResponse, config: Confi
async def _deserialize_get_branch_key_version(input: DafnyResponse, config: Config):

if input.IsFailure():
return await _deserialize_error(input.error)
return _deserialize_error(input.error)
return aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_GetBranchKeyVersionOutput(
input.value
)
Expand All @@ -92,19 +94,19 @@ async def _deserialize_get_branch_key_version(input: DafnyResponse, config: Conf
async def _deserialize_get_beacon_key(input: DafnyResponse, config: Config):

if input.IsFailure():
return await _deserialize_error(input.error)
return _deserialize_error(input.error)
return aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.dafny_to_smithy.aws_cryptography_keystore_GetBeaconKeyOutput(
input.value
)


async def _deserialize_error(error: Error) -> ServiceError:
def _deserialize_error(error: Error) -> ServiceError:
if error.is_Opaque:
return OpaqueError(obj=error.obj)
elif error.is_CollectionOfErrors:
return CollectionOfErrors(
message=_dafny.string_of(error.message),
list=[await _deserialize_error(dafny_e) for dafny_e in error.list],
list=[_deserialize_error(dafny_e) for dafny_e in error.list],
)
elif error.is_KeyStoreException:
return KeyStoreException(message=_dafny.string_of(error.message))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# Code generated by smithy-python-codegen DO NOT EDIT.
# 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.

import _dafny
import aws_cryptographic_materialproviders.internaldafny.generated
import aws_cryptographic_materialproviders.internaldafny.generated.AwsCryptographyKeyStoreTypes
import aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.errors
from com_amazonaws_dynamodb.smithygenerated.com_amazonaws_dynamodb.shim import (
_sdk_error_to_dafny_error as com_amazonaws_dynamodb_sdk_error_to_dafny_error,
)
from com_amazonaws_kms.smithygenerated.com_amazonaws_kms.shim import (
_sdk_error_to_dafny_error as com_amazonaws_kms_sdk_error_to_dafny_error,
)
import software_amazon_cryptography_keystore_internaldafny_types
from typing import Any, Dict, Generic, List, Literal, TypeVar


Expand Down Expand Up @@ -209,26 +213,34 @@ def _smithy_error_to_dafny_error(e: ServiceError):
e,
aws_cryptographic_materialproviders.smithygenerated.aws_cryptography_keystore.errors.KeyStoreException,
):
return software_amazon_cryptography_keystore_internaldafny_types.Error_KeyStoreException(
message=e.message
return aws_cryptographic_materialproviders.internaldafny.generated.AwsCryptographyKeyStoreTypes.Error_KeyStoreException(
message=_dafny.Seq(e.message)
)

if isinstance(e, ComAmazonawsDynamodb):
return software_amazon_cryptography_keystore_internaldafny_types.Error_ComAmazonawsDynamodb(
return aws_cryptographic_materialproviders.internaldafny.generated.AwsCryptographyKeyStoreTypes.Error_ComAmazonawsDynamodb(
com_amazonaws_dynamodb_sdk_error_to_dafny_error(e.message)
)

if isinstance(e, ComAmazonawsKms):
return software_amazon_cryptography_keystore_internaldafny_types.Error_ComAmazonawsKms(
return aws_cryptographic_materialproviders.internaldafny.generated.AwsCryptographyKeyStoreTypes.Error_ComAmazonawsKms(
com_amazonaws_kms_sdk_error_to_dafny_error(e.message)
)

if isinstance(e, CollectionOfErrors):
return software_amazon_cryptography_keystore_internaldafny_types.Error_CollectionOfErrors(
message=e.message, list=e.list
return aws_cryptographic_materialproviders.internaldafny.generated.AwsCryptographyKeyStoreTypes.Error_CollectionOfErrors(
message=_dafny.Seq(e.message),
list=_dafny.Seq(
_smithy_error_to_dafny_error(native_err) for native_err in e.list
),
)

if isinstance(e, OpaqueError):
return software_amazon_cryptography_keystore_internaldafny_types.Error_Opaque(
return aws_cryptographic_materialproviders.internaldafny.generated.AwsCryptographyKeyStoreTypes.Error_Opaque(
obj=e.obj
)

else:
return aws_cryptographic_materialproviders.internaldafny.generated.AwsCryptographyKeyStoreTypes.Error_Opaque(
obj=e
)
Loading

0 comments on commit 0552aa8

Please sign in to comment.