35
35
Input = TypeVar ("Input" )
36
36
Output = TypeVar ("Output" )
37
37
38
+
38
39
class DynamoDbEncryption :
39
40
"""Client for DynamoDbEncryption
40
41
41
42
:param config: Configuration for the client.
42
43
"""
44
+
43
45
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
47
47
):
48
48
if config is None :
49
49
self ._config = Config ()
@@ -60,7 +60,9 @@ def __init__(
60
60
if dafny_client is not None :
61
61
self ._config .dafnyImplInterface .impl = dafny_client
62
62
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 :
64
66
"""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.
65
67
66
68
: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
74
76
operation_name = "CreateDynamoDbEncryptionBranchKeyIdSupplier" ,
75
77
)
76
78
77
- def get_encrypted_data_key_description (self , input : GetEncryptedDataKeyDescriptionInput ) -> GetEncryptedDataKeyDescriptionOutput :
79
+ def get_encrypted_data_key_description (
80
+ self , input : GetEncryptedDataKeyDescriptionInput
81
+ ) -> GetEncryptedDataKeyDescriptionOutput :
78
82
"""Returns encrypted data key description.
79
83
80
84
:param input: Input for getting encrypted data key description.
@@ -98,9 +102,7 @@ def _execute_operation(
98
102
operation_name : str ,
99
103
) -> Output :
100
104
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 )
104
106
except Exception as e :
105
107
# Make sure every exception that we throw is an instance of ServiceError so
106
108
# customers can reliably catch everything we throw.
@@ -124,13 +126,11 @@ def _handle_execution(
124
126
transport_response = None ,
125
127
)
126
128
try :
127
- _client_interceptors = config .interceptors
129
+ _client_interceptors = config .interceptors
128
130
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 )
134
134
interceptors = client_interceptors
135
135
136
136
try :
@@ -163,9 +163,7 @@ def _handle_execution(
163
163
interceptor .read_before_serialization (context )
164
164
165
165
# 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 )
169
167
context_with_transport_request ._transport_request = serialize (
170
168
context_with_transport_request .request , config
171
169
)
@@ -176,8 +174,8 @@ def _handle_execution(
176
174
177
175
# Step 6: Invoke modify_before_retry_loop
178
176
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
181
179
)
182
180
183
181
# Step 7: Acquire the retry token.
@@ -212,7 +210,7 @@ def _handle_execution(
212
210
error_info = RetryErrorInfo (
213
211
# TODO: Determine the error type.
214
212
error_type = RetryErrorType .CLIENT_ERROR ,
215
- )
213
+ ),
216
214
)
217
215
except SmithyRetryException :
218
216
raise context_with_response .response
@@ -226,9 +224,7 @@ def _handle_execution(
226
224
# At this point, the context's request will have been definitively set, and
227
225
# The response will be set either with the modeled output or an exception. The
228
226
# 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 )
232
228
return self ._finalize_execution (interceptors , execution_context )
233
229
234
230
def _handle_attempt (
@@ -248,9 +244,7 @@ def _handle_attempt(
248
244
if config .dafnyImplInterface .impl is None :
249
245
raise Exception ("No impl found on the operation config." )
250
246
251
- context_with_response = cast (
252
- InterceptorContext [Input , None , DafnyRequest , DafnyResponse ], context
253
- )
247
+ context_with_response = cast (InterceptorContext [Input , None , DafnyRequest , DafnyResponse ], context )
254
248
255
249
context_with_response ._transport_response = config .dafnyImplInterface .handle_request (
256
250
input = context_with_response .transport_request
@@ -262,8 +256,8 @@ def _handle_attempt(
262
256
263
257
# Step 7o: Invoke modify_before_deserialization
264
258
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
267
261
)
268
262
269
263
# Step 7p: Invoke read_before_deserialization
@@ -275,9 +269,7 @@ def _handle_attempt(
275
269
InterceptorContext [Input , Output , DafnyRequest , DafnyResponse ],
276
270
context_with_response ,
277
271
)
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 )
281
273
282
274
# Step 7r: Invoke read_after_deserialization
283
275
for interceptor in interceptors :
@@ -289,9 +281,7 @@ def _handle_attempt(
289
281
# the response is either set or an exception, and the transport_resposne is either set or
290
282
# None. This will also be true after _finalize_attempt because there is no opportunity
291
283
# 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 )
295
285
return self ._finalize_attempt (interceptors , attempt_context )
296
286
297
287
def _finalize_attempt (
@@ -302,9 +292,7 @@ def _finalize_attempt(
302
292
# Step 7s: Invoke modify_before_attempt_completion
303
293
try :
304
294
for interceptor in interceptors :
305
- context ._response = interceptor .modify_before_attempt_completion (
306
- context
307
- )
295
+ context ._response = interceptor .modify_before_attempt_completion (context )
308
296
except Exception as e :
309
297
context ._response = e
310
298
0 commit comments