Skip to content

Commit 9057fcb

Browse files
author
Lucas McDonald
committed
m
1 parent 85edd6a commit 9057fcb

File tree

42 files changed

+2674
-2464
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2674
-2464
lines changed

DynamoDbEncryption/runtimes/python/src/aws_dbesdk_dynamodb/internaldafny/extern/InternalLegacyOverride.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def Build(config: DynamoDbItemEncryptorConfig_DynamoDbItemEncryptorConfig):
4848
maybe_actions = InternalLegacyOverride.legacyActions(legacy_override.attributeActionsOnEncrypt)
4949
if maybe_actions.is_Failure:
5050
return InternalLegacyOverride.CreateBuildFailure(maybe_actions.error())
51-
51+
5252
# TODO: Implement this
5353

5454
@staticmethod
@@ -64,7 +64,7 @@ def legacyEncryptionContext(config: DynamoDbItemEncryptorConfig_DynamoDbItemEncr
6464
return InternalLegacyOverride.CreateBuildSuccess(encryption_context)
6565
except Exception as e:
6666
return InternalLegacyOverride.CreateBuildFailure(InternalLegacyOverride.CreateError(str(e)))
67-
67+
6868
@staticmethod
6969
def legacyActions(attribute_actions_on_encrypt):
7070
# TODO: Implement this
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
33
# Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
4-

DynamoDbEncryption/runtimes/python/src/aws_dbesdk_dynamodb/smithygenerated/aws_cryptography_dbencryptionsdk_dynamodb/aws_sdk_to_dafny.py

Lines changed: 74 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,89 @@
2020

2121
def com_amazonaws_dynamodb_AttributeValue(native_input):
2222
if "S" in native_input.keys():
23-
AttributeValue_union_value = AttributeValue_S(Seq(''.join([chr(int.from_bytes(pair, 'big')) for pair in zip(*[iter(native_input["S"].encode('utf-16-be'))]*2)])))
23+
AttributeValue_union_value = AttributeValue_S(
24+
Seq(
25+
"".join(
26+
[
27+
chr(int.from_bytes(pair, "big"))
28+
for pair in zip(*[iter(native_input["S"].encode("utf-16-be"))] * 2)
29+
]
30+
)
31+
)
32+
)
2433
elif "N" in native_input.keys():
25-
AttributeValue_union_value = AttributeValue_N(Seq(''.join([chr(int.from_bytes(pair, 'big')) for pair in zip(*[iter(native_input["N"].encode('utf-16-be'))]*2)])))
34+
AttributeValue_union_value = AttributeValue_N(
35+
Seq(
36+
"".join(
37+
[
38+
chr(int.from_bytes(pair, "big"))
39+
for pair in zip(*[iter(native_input["N"].encode("utf-16-be"))] * 2)
40+
]
41+
)
42+
)
43+
)
2644
elif "B" in native_input.keys():
2745
AttributeValue_union_value = AttributeValue_B(Seq(native_input["B"]))
2846
elif "SS" in native_input.keys():
29-
AttributeValue_union_value = AttributeValue_SS(Seq([Seq(''.join([chr(int.from_bytes(pair, 'big')) for pair in zip(*[iter(list_element.encode('utf-16-be'))]*2)])) for list_element in native_input["SS"]]))
47+
AttributeValue_union_value = AttributeValue_SS(
48+
Seq(
49+
[
50+
Seq(
51+
"".join(
52+
[
53+
chr(int.from_bytes(pair, "big"))
54+
for pair in zip(*[iter(list_element.encode("utf-16-be"))] * 2)
55+
]
56+
)
57+
)
58+
for list_element in native_input["SS"]
59+
]
60+
)
61+
)
3062
elif "NS" in native_input.keys():
31-
AttributeValue_union_value = AttributeValue_NS(Seq([Seq(''.join([chr(int.from_bytes(pair, 'big')) for pair in zip(*[iter(list_element.encode('utf-16-be'))]*2)])) for list_element in native_input["NS"]]))
63+
AttributeValue_union_value = AttributeValue_NS(
64+
Seq(
65+
[
66+
Seq(
67+
"".join(
68+
[
69+
chr(int.from_bytes(pair, "big"))
70+
for pair in zip(*[iter(list_element.encode("utf-16-be"))] * 2)
71+
]
72+
)
73+
)
74+
for list_element in native_input["NS"]
75+
]
76+
)
77+
)
3278
elif "BS" in native_input.keys():
3379
AttributeValue_union_value = AttributeValue_BS(Seq([Seq(list_element) for list_element in native_input["BS"]]))
3480
elif "M" in native_input.keys():
35-
AttributeValue_union_value = AttributeValue_M(Map({Seq(''.join([chr(int.from_bytes(pair, 'big')) for pair in zip(*[iter(key.encode('utf-16-be'))]*2)])): aws_cryptography_internal_dynamodb.smithygenerated.com_amazonaws_dynamodb.aws_sdk_to_dafny.com_amazonaws_dynamodb_AttributeValue(value) for (key, value) in native_input["M"].items() }))
81+
AttributeValue_union_value = AttributeValue_M(
82+
Map(
83+
{
84+
Seq(
85+
"".join(
86+
[chr(int.from_bytes(pair, "big")) for pair in zip(*[iter(key.encode("utf-16-be"))] * 2)]
87+
)
88+
): aws_cryptography_internal_dynamodb.smithygenerated.com_amazonaws_dynamodb.aws_sdk_to_dafny.com_amazonaws_dynamodb_AttributeValue(
89+
value
90+
)
91+
for (key, value) in native_input["M"].items()
92+
}
93+
)
94+
)
3695
elif "L" in native_input.keys():
37-
AttributeValue_union_value = AttributeValue_L(Seq([aws_cryptography_internal_dynamodb.smithygenerated.com_amazonaws_dynamodb.aws_sdk_to_dafny.com_amazonaws_dynamodb_AttributeValue(list_element) for list_element in native_input["L"]]))
96+
AttributeValue_union_value = AttributeValue_L(
97+
Seq(
98+
[
99+
aws_cryptography_internal_dynamodb.smithygenerated.com_amazonaws_dynamodb.aws_sdk_to_dafny.com_amazonaws_dynamodb_AttributeValue(
100+
list_element
101+
)
102+
for list_element in native_input["L"]
103+
]
104+
)
105+
)
38106
elif "NULL" in native_input.keys():
39107
AttributeValue_union_value = AttributeValue_NULL(native_input["NULL"])
40108
elif "BOOL" in native_input.keys():

DynamoDbEncryption/runtimes/python/src/aws_dbesdk_dynamodb/smithygenerated/aws_cryptography_dbencryptionsdk_dynamodb/client.py

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@
3535
Input = TypeVar("Input")
3636
Output = TypeVar("Output")
3737

38+
3839
class DynamoDbEncryption:
3940
"""Client for DynamoDbEncryption
4041
4142
:param config: Configuration for the client.
4243
"""
44+
4345
def __init__(
44-
self,
45-
config: DynamoDbEncryptionConfig | None = None,
46-
dafny_client: IDynamoDbEncryptionClient | None = None
46+
self, config: DynamoDbEncryptionConfig | None = None, dafny_client: IDynamoDbEncryptionClient | None = None
4747
):
4848
if config is None:
4949
self._config = Config()
@@ -60,7 +60,9 @@ def __init__(
6060
if dafny_client is not None:
6161
self._config.dafnyImplInterface.impl = dafny_client
6262

63-
def create_dynamo_db_encryption_branch_key_id_supplier(self, input: CreateDynamoDbEncryptionBranchKeyIdSupplierInput) -> CreateDynamoDbEncryptionBranchKeyIdSupplierOutput:
63+
def create_dynamo_db_encryption_branch_key_id_supplier(
64+
self, input: CreateDynamoDbEncryptionBranchKeyIdSupplierInput
65+
) -> CreateDynamoDbEncryptionBranchKeyIdSupplierOutput:
6466
"""Create a Branch Key Supplier for use with the Hierarchical Keyring that decides what Branch Key to use based on the primary key of the DynamoDB item being read or written.
6567
6668
:param input: Inputs for creating a Branch Key Supplier from a DynamoDB Key Branch Key Id Supplier
@@ -74,7 +76,9 @@ def create_dynamo_db_encryption_branch_key_id_supplier(self, input: CreateDynamo
7476
operation_name="CreateDynamoDbEncryptionBranchKeyIdSupplier",
7577
)
7678

77-
def get_encrypted_data_key_description(self, input: GetEncryptedDataKeyDescriptionInput) -> GetEncryptedDataKeyDescriptionOutput:
79+
def get_encrypted_data_key_description(
80+
self, input: GetEncryptedDataKeyDescriptionInput
81+
) -> GetEncryptedDataKeyDescriptionOutput:
7882
"""Returns encrypted data key description.
7983
8084
:param input: Input for getting encrypted data key description.
@@ -98,9 +102,7 @@ def _execute_operation(
98102
operation_name: str,
99103
) -> Output:
100104
try:
101-
return self._handle_execution(
102-
input, plugins, serialize, deserialize, config, operation_name
103-
)
105+
return self._handle_execution(input, plugins, serialize, deserialize, config, operation_name)
104106
except Exception as e:
105107
# Make sure every exception that we throw is an instance of ServiceError so
106108
# customers can reliably catch everything we throw.
@@ -124,13 +126,11 @@ def _handle_execution(
124126
transport_response=None,
125127
)
126128
try:
127-
_client_interceptors = config.interceptors
129+
_client_interceptors = config.interceptors
128130
except AttributeError:
129-
config.interceptors = []
130-
_client_interceptors = config.interceptors
131-
client_interceptors = cast(
132-
list[Interceptor[Input, Output, DafnyRequest, DafnyResponse]], _client_interceptors
133-
)
131+
config.interceptors = []
132+
_client_interceptors = config.interceptors
133+
client_interceptors = cast(list[Interceptor[Input, Output, DafnyRequest, DafnyResponse]], _client_interceptors)
134134
interceptors = client_interceptors
135135

136136
try:
@@ -163,9 +163,7 @@ def _handle_execution(
163163
interceptor.read_before_serialization(context)
164164

165165
# Step 4: Serialize the request
166-
context_with_transport_request = cast(
167-
InterceptorContext[Input, None, DafnyRequest, None], context
168-
)
166+
context_with_transport_request = cast(InterceptorContext[Input, None, DafnyRequest, None], context)
169167
context_with_transport_request._transport_request = serialize(
170168
context_with_transport_request.request, config
171169
)
@@ -176,8 +174,8 @@ def _handle_execution(
176174

177175
# Step 6: Invoke modify_before_retry_loop
178176
for interceptor in interceptors:
179-
context_with_transport_request._transport_request = (
180-
interceptor.modify_before_retry_loop(context_with_transport_request)
177+
context_with_transport_request._transport_request = interceptor.modify_before_retry_loop(
178+
context_with_transport_request
181179
)
182180

183181
# Step 7: Acquire the retry token.
@@ -212,7 +210,7 @@ def _handle_execution(
212210
error_info=RetryErrorInfo(
213211
# TODO: Determine the error type.
214212
error_type=RetryErrorType.CLIENT_ERROR,
215-
)
213+
),
216214
)
217215
except SmithyRetryException:
218216
raise context_with_response.response
@@ -226,9 +224,7 @@ def _handle_execution(
226224
# At this point, the context's request will have been definitively set, and
227225
# The response will be set either with the modeled output or an exception. The
228226
# transport_request and transport_response may be set or None.
229-
execution_context = cast(
230-
InterceptorContext[Input, Output, DafnyRequest | None, DafnyResponse | None], context
231-
)
227+
execution_context = cast(InterceptorContext[Input, Output, DafnyRequest | None, DafnyResponse | None], context)
232228
return self._finalize_execution(interceptors, execution_context)
233229

234230
def _handle_attempt(
@@ -248,9 +244,7 @@ def _handle_attempt(
248244
if config.dafnyImplInterface.impl is None:
249245
raise Exception("No impl found on the operation config.")
250246

251-
context_with_response = cast(
252-
InterceptorContext[Input, None, DafnyRequest, DafnyResponse], context
253-
)
247+
context_with_response = cast(InterceptorContext[Input, None, DafnyRequest, DafnyResponse], context)
254248

255249
context_with_response._transport_response = config.dafnyImplInterface.handle_request(
256250
input=context_with_response.transport_request
@@ -262,8 +256,8 @@ def _handle_attempt(
262256

263257
# Step 7o: Invoke modify_before_deserialization
264258
for interceptor in interceptors:
265-
context_with_response._transport_response = (
266-
interceptor.modify_before_deserialization(context_with_response)
259+
context_with_response._transport_response = interceptor.modify_before_deserialization(
260+
context_with_response
267261
)
268262

269263
# Step 7p: Invoke read_before_deserialization
@@ -275,9 +269,7 @@ def _handle_attempt(
275269
InterceptorContext[Input, Output, DafnyRequest, DafnyResponse],
276270
context_with_response,
277271
)
278-
context_with_output._response = deserialize(
279-
context_with_output._transport_response, config
280-
)
272+
context_with_output._response = deserialize(context_with_output._transport_response, config)
281273

282274
# Step 7r: Invoke read_after_deserialization
283275
for interceptor in interceptors:
@@ -289,9 +281,7 @@ def _handle_attempt(
289281
# the response is either set or an exception, and the transport_resposne is either set or
290282
# None. This will also be true after _finalize_attempt because there is no opportunity
291283
# there to set the transport_response.
292-
attempt_context = cast(
293-
InterceptorContext[Input, Output, DafnyRequest, DafnyResponse | None], context
294-
)
284+
attempt_context = cast(InterceptorContext[Input, Output, DafnyRequest, DafnyResponse | None], context)
295285
return self._finalize_attempt(interceptors, attempt_context)
296286

297287
def _finalize_attempt(
@@ -302,9 +292,7 @@ def _finalize_attempt(
302292
# Step 7s: Invoke modify_before_attempt_completion
303293
try:
304294
for interceptor in interceptors:
305-
context._response = interceptor.modify_before_attempt_completion(
306-
context
307-
)
295+
context._response = interceptor.modify_before_attempt_completion(context)
308296
except Exception as e:
309297
context._response = e
310298

DynamoDbEncryption/runtimes/python/src/aws_dbesdk_dynamodb/smithygenerated/aws_cryptography_dbencryptionsdk_dynamodb/config.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818

1919
_ServiceInterceptor = Any
20+
21+
2022
@dataclass(init=False)
2123
class Config:
2224
"""Configuration for DynamoDbEncryption."""
@@ -46,28 +48,25 @@ def __init__(
4648
self.retry_strategy = retry_strategy or SimpleRetryStrategy()
4749
self.dafnyImplInterface = dafnyImplInterface
4850

51+
4952
# A callable that allows customizing the config object on each request.
5053
Plugin: TypeAlias = Callable[[Config], None]
5154

55+
5256
class DynamoDbEncryptionConfig(Config):
5357
def __init__(
5458
self,
5559
):
56-
"""Constructor for DynamoDbEncryptionConfig
57-
"""
60+
"""Constructor for DynamoDbEncryptionConfig"""
5861
super().__init__()
5962

6063
def as_dict(self) -> Dict[str, Any]:
61-
"""Converts the DynamoDbEncryptionConfig to a dictionary.
62-
63-
"""
64+
"""Converts the DynamoDbEncryptionConfig to a dictionary."""
6465
return {}
6566

6667
@staticmethod
6768
def from_dict(d: Dict[str, Any]) -> "DynamoDbEncryptionConfig":
68-
"""Creates a DynamoDbEncryptionConfig from a dictionary.
69-
70-
"""
69+
"""Creates a DynamoDbEncryptionConfig from a dictionary."""
7170
return DynamoDbEncryptionConfig()
7271

7372
def __repr__(self) -> str:
@@ -78,16 +77,22 @@ def __repr__(self) -> str:
7877
def __eq__(self, other: Any) -> bool:
7978
return isinstance(other, DynamoDbEncryptionConfig)
8079

80+
8181
def dafny_config_to_smithy_config(dafny_config) -> DynamoDbEncryptionConfig:
8282
"""
8383
Converts the provided Dafny shape for this localService's config
8484
into the corresponding Smithy-modelled shape.
8585
"""
86-
return aws_dbesdk_dynamodb.smithygenerated.aws_cryptography_dbencryptionsdk_dynamodb.dafny_to_smithy.aws_cryptography_dbencryptionsdk_dynamodb_DynamoDbEncryptionConfig(dafny_config)
86+
return aws_dbesdk_dynamodb.smithygenerated.aws_cryptography_dbencryptionsdk_dynamodb.dafny_to_smithy.aws_cryptography_dbencryptionsdk_dynamodb_DynamoDbEncryptionConfig(
87+
dafny_config
88+
)
89+
8790

8891
def smithy_config_to_dafny_config(smithy_config) -> DafnyDynamoDbEncryptionConfig:
8992
"""
9093
Converts the provided Smithy-modelled shape for this localService's config
9194
into the corresponding Dafny shape.
9295
"""
93-
return aws_dbesdk_dynamodb.smithygenerated.aws_cryptography_dbencryptionsdk_dynamodb.smithy_to_dafny.aws_cryptography_dbencryptionsdk_dynamodb_DynamoDbEncryptionConfig(smithy_config)
96+
return aws_dbesdk_dynamodb.smithygenerated.aws_cryptography_dbencryptionsdk_dynamodb.smithy_to_dafny.aws_cryptography_dbencryptionsdk_dynamodb_DynamoDbEncryptionConfig(
97+
smithy_config
98+
)

DynamoDbEncryption/runtimes/python/src/aws_dbesdk_dynamodb/smithygenerated/aws_cryptography_dbencryptionsdk_dynamodb/dafnyImplInterface.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from aws_dbesdk_dynamodb.internaldafny.generated.DynamoDbEncryption import DynamoDbEncryptionClient
66
from .dafny_protocol import DafnyRequest
77

8+
89
class DafnyImplInterface:
910
impl: DynamoDbEncryptionClient | None = None
1011

@@ -22,9 +23,9 @@ def handle_request(self, input: DafnyRequest):
2223
"GetEncryptedDataKeyDescription": self.impl.GetEncryptedDataKeyDescription,
2324
}
2425

25-
# This logic is where a typical Smithy client would expect the "server" to be.
26-
# This code can be thought of as logic our Dafny "server" uses
27-
# to route incoming client requests to the correct request handler code.
26+
# This logic is where a typical Smithy client would expect the "server" to be.
27+
# This code can be thought of as logic our Dafny "server" uses
28+
# to route incoming client requests to the correct request handler code.
2829
if input.dafny_operation_input is None:
2930
return self.operation_map[input.operation_name]()
3031
else:

DynamoDbEncryption/runtimes/python/src/aws_dbesdk_dynamodb/smithygenerated/aws_cryptography_dbencryptionsdk_dynamodb/dafny_protocol.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import smithy_dafny_standard_library.internaldafny.generated.Wrappers as Wrappers
1313
from typing import Union
1414

15+
1516
class DafnyRequest:
1617
operation_name: str
1718

@@ -26,6 +27,7 @@ def __init__(self, operation_name, dafny_operation_input):
2627
self.operation_name = operation_name
2728
self.dafny_operation_input = dafny_operation_input
2829

30+
2931
class DafnyResponse(Wrappers.Result):
3032
def __init__(self):
3133
super().__init__(self)

0 commit comments

Comments
 (0)