Skip to content

Commit 85edd6a

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

Some content is hidden

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

45 files changed

+2884
-3216
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
13
from aws_dbesdk_dynamodb.internaldafny.generated.AwsCryptographyDbEncryptionSdkDynamoDbItemEncryptorTypes import (
2-
DynamoDbItemEncryptorConfig,
34
DynamoDbItemEncryptorConfig_DynamoDbItemEncryptorConfig,
45
)
56
import smithy_dafny_standard_library.internaldafny.generated.Wrappers as Wrappers
@@ -47,7 +48,10 @@ def Build(config: DynamoDbItemEncryptorConfig_DynamoDbItemEncryptorConfig):
4748
maybe_actions = InternalLegacyOverride.legacyActions(legacy_override.attributeActionsOnEncrypt)
4849
if maybe_actions.is_Failure:
4950
return InternalLegacyOverride.CreateBuildFailure(maybe_actions.error())
51+
52+
# TODO: Implement this
5053

54+
@staticmethod
5155
def legacyEncryptionContext(config: DynamoDbItemEncryptorConfig_DynamoDbItemEncryptorConfig):
5256
try:
5357
encryption_context_kwargs = {
@@ -60,17 +64,25 @@ def legacyEncryptionContext(config: DynamoDbItemEncryptorConfig_DynamoDbItemEncr
6064
return InternalLegacyOverride.CreateBuildSuccess(encryption_context)
6165
except Exception as e:
6266
return InternalLegacyOverride.CreateBuildFailure(InternalLegacyOverride.CreateError(str(e)))
67+
68+
@staticmethod
69+
def legacyActions(attribute_actions_on_encrypt):
70+
# TODO: Implement this
71+
pass
6372

6473
@staticmethod
6574
def EncryptItem(input):
75+
# TODO: Implement this
6676
return Wrappers.Result_Failure("TODO-legacy-Encryptitem")
6777

6878
@staticmethod
6979
def DecryptItem(input):
80+
# TODO: Implement this
7081
return Wrappers.Result_Failure("TODO-legacy-Decryptitem")
7182

7283
@staticmethod
7384
def IsLegacyinput(input):
85+
# TODO: Implement this
7486
return False
7587

7688

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
13
from . import (
24
InternalLegacyOverride,
35
)
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
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: 6 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -20,89 +20,21 @@
2020

2121
def com_amazonaws_dynamodb_AttributeValue(native_input):
2222
if "S" in native_input.keys():
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-
)
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)])))
3324
elif "N" in native_input.keys():
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-
)
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)])))
4426
elif "B" in native_input.keys():
4527
AttributeValue_union_value = AttributeValue_B(Seq(native_input["B"]))
4628
elif "SS" in native_input.keys():
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-
)
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"]]))
6230
elif "NS" in native_input.keys():
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-
)
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"]]))
7832
elif "BS" in native_input.keys():
7933
AttributeValue_union_value = AttributeValue_BS(Seq([Seq(list_element) for list_element in native_input["BS"]]))
8034
elif "M" in native_input.keys():
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-
)
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() }))
9536
elif "L" in native_input.keys():
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-
)
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"]]))
10638
elif "NULL" in native_input.keys():
10739
AttributeValue_union_value = AttributeValue_NULL(native_input["NULL"])
10840
elif "BOOL" in native_input.keys():

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

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

38-
3938
class DynamoDbEncryption:
40-
"""Client for DynamoDbEncryption.
39+
"""Client for DynamoDbEncryption
4140
4241
:param config: Configuration for the client.
4342
"""
44-
4543
def __init__(
4644
self,
4745
config: DynamoDbEncryptionConfig | None = None,
48-
dafny_client: IDynamoDbEncryptionClient | None = None,
46+
dafny_client: IDynamoDbEncryptionClient | None = None
4947
):
5048
if config is None:
5149
self._config = Config()
@@ -62,15 +60,10 @@ def __init__(
6260
if dafny_client is not None:
6361
self._config.dafnyImplInterface.impl = dafny_client
6462

65-
def create_dynamo_db_encryption_branch_key_id_supplier(
66-
self, input: CreateDynamoDbEncryptionBranchKeyIdSupplierInput
67-
) -> CreateDynamoDbEncryptionBranchKeyIdSupplierOutput:
68-
"""Create a Branch Key Supplier for use with the Hierarchical Keyring
69-
that decides what Branch Key to use based on the primary key of the
70-
DynamoDB item being read or written.
63+
def create_dynamo_db_encryption_branch_key_id_supplier(self, input: CreateDynamoDbEncryptionBranchKeyIdSupplierInput) -> CreateDynamoDbEncryptionBranchKeyIdSupplierOutput:
64+
"""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.
7165
72-
:param input: Inputs for creating a Branch Key Supplier from a
73-
DynamoDB Key Branch Key Id Supplier
66+
:param input: Inputs for creating a Branch Key Supplier from a DynamoDB Key Branch Key Id Supplier
7467
"""
7568
return self._execute_operation(
7669
input=input,
@@ -81,9 +74,7 @@ def create_dynamo_db_encryption_branch_key_id_supplier(
8174
operation_name="CreateDynamoDbEncryptionBranchKeyIdSupplier",
8275
)
8376

84-
def get_encrypted_data_key_description(
85-
self, input: GetEncryptedDataKeyDescriptionInput
86-
) -> GetEncryptedDataKeyDescriptionOutput:
77+
def get_encrypted_data_key_description(self, input: GetEncryptedDataKeyDescriptionInput) -> GetEncryptedDataKeyDescriptionOutput:
8778
"""Returns encrypted data key description.
8879
8980
:param input: Input for getting encrypted data key description.
@@ -107,7 +98,9 @@ def _execute_operation(
10798
operation_name: str,
10899
) -> Output:
109100
try:
110-
return self._handle_execution(input, plugins, serialize, deserialize, config, operation_name)
101+
return self._handle_execution(
102+
input, plugins, serialize, deserialize, config, operation_name
103+
)
111104
except Exception as e:
112105
# Make sure every exception that we throw is an instance of ServiceError so
113106
# customers can reliably catch everything we throw.
@@ -131,13 +124,12 @@ def _handle_execution(
131124
transport_response=None,
132125
)
133126
try:
134-
_client_interceptors = config.interceptors
127+
_client_interceptors = config.interceptors
135128
except AttributeError:
136-
config.interceptors = []
137-
_client_interceptors = config.interceptors
129+
config.interceptors = []
130+
_client_interceptors = config.interceptors
138131
client_interceptors = cast(
139-
list[Interceptor[Input, Output, DafnyRequest, DafnyResponse]],
140-
_client_interceptors,
132+
list[Interceptor[Input, Output, DafnyRequest, DafnyResponse]], _client_interceptors
141133
)
142134
interceptors = client_interceptors
143135

@@ -171,7 +163,9 @@ def _handle_execution(
171163
interceptor.read_before_serialization(context)
172164

173165
# Step 4: Serialize the request
174-
context_with_transport_request = cast(InterceptorContext[Input, None, DafnyRequest, None], context)
166+
context_with_transport_request = cast(
167+
InterceptorContext[Input, None, DafnyRequest, None], context
168+
)
175169
context_with_transport_request._transport_request = serialize(
176170
context_with_transport_request.request, config
177171
)
@@ -182,8 +176,8 @@ def _handle_execution(
182176

183177
# Step 6: Invoke modify_before_retry_loop
184178
for interceptor in interceptors:
185-
context_with_transport_request._transport_request = interceptor.modify_before_retry_loop(
186-
context_with_transport_request
179+
context_with_transport_request._transport_request = (
180+
interceptor.modify_before_retry_loop(context_with_transport_request)
187181
)
188182

189183
# Step 7: Acquire the retry token.
@@ -218,7 +212,7 @@ def _handle_execution(
218212
error_info=RetryErrorInfo(
219213
# TODO: Determine the error type.
220214
error_type=RetryErrorType.CLIENT_ERROR,
221-
),
215+
)
222216
)
223217
except SmithyRetryException:
224218
raise context_with_response.response
@@ -233,8 +227,7 @@ def _handle_execution(
233227
# The response will be set either with the modeled output or an exception. The
234228
# transport_request and transport_response may be set or None.
235229
execution_context = cast(
236-
InterceptorContext[Input, Output, DafnyRequest | None, DafnyResponse | None],
237-
context,
230+
InterceptorContext[Input, Output, DafnyRequest | None, DafnyResponse | None], context
238231
)
239232
return self._finalize_execution(interceptors, execution_context)
240233

@@ -255,7 +248,9 @@ def _handle_attempt(
255248
if config.dafnyImplInterface.impl is None:
256249
raise Exception("No impl found on the operation config.")
257250

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

260255
context_with_response._transport_response = config.dafnyImplInterface.handle_request(
261256
input=context_with_response.transport_request
@@ -267,8 +262,8 @@ def _handle_attempt(
267262

268263
# Step 7o: Invoke modify_before_deserialization
269264
for interceptor in interceptors:
270-
context_with_response._transport_response = interceptor.modify_before_deserialization(
271-
context_with_response
265+
context_with_response._transport_response = (
266+
interceptor.modify_before_deserialization(context_with_response)
272267
)
273268

274269
# Step 7p: Invoke read_before_deserialization
@@ -280,7 +275,9 @@ def _handle_attempt(
280275
InterceptorContext[Input, Output, DafnyRequest, DafnyResponse],
281276
context_with_response,
282277
)
283-
context_with_output._response = deserialize(context_with_output._transport_response, config)
278+
context_with_output._response = deserialize(
279+
context_with_output._transport_response, config
280+
)
284281

285282
# Step 7r: Invoke read_after_deserialization
286283
for interceptor in interceptors:
@@ -293,8 +290,7 @@ def _handle_attempt(
293290
# None. This will also be true after _finalize_attempt because there is no opportunity
294291
# there to set the transport_response.
295292
attempt_context = cast(
296-
InterceptorContext[Input, Output, DafnyRequest, DafnyResponse | None],
297-
context,
293+
InterceptorContext[Input, Output, DafnyRequest, DafnyResponse | None], context
298294
)
299295
return self._finalize_attempt(interceptors, attempt_context)
300296

@@ -306,7 +302,9 @@ def _finalize_attempt(
306302
# Step 7s: Invoke modify_before_attempt_completion
307303
try:
308304
for interceptor in interceptors:
309-
context._response = interceptor.modify_before_attempt_completion(context)
305+
context._response = interceptor.modify_before_attempt_completion(
306+
context
307+
)
310308
except Exception as e:
311309
context._response = e
312310

0 commit comments

Comments
 (0)