@@ -317,22 +317,32 @@ def assert_failed(status, response):
317
317
return error_code
318
318
319
319
@staticmethod
320
+ # pylint: disable=R0913
320
321
def make_request (
321
322
desired_resource_state ,
322
323
previous_resource_state ,
323
324
region ,
324
325
account ,
325
326
partition ,
327
+ action ,
328
+ creds ,
329
+ token ,
330
+ callback_context = None ,
326
331
** kwargs
327
332
):
328
333
return {
329
- "desiredResourceState" : desired_resource_state ,
330
- "previousResourceState" : previous_resource_state ,
331
- "logicalResourceIdentifier" : "test" ,
332
- ** kwargs ,
334
+ "requestData" : {
335
+ "callerCredentials" : creds ,
336
+ "resourceProperties" : desired_resource_state ,
337
+ "previousResourceProperties" : previous_resource_state ,
338
+ "logicalResourceIdentifier" : token ,
339
+ },
333
340
"region" : region ,
334
341
"awsPartition" : partition ,
335
342
"awsAccountId" : account ,
343
+ "action" : action ,
344
+ "callbackContext" : callback_context ,
345
+ ** kwargs ,
336
346
}
337
347
338
348
@staticmethod
@@ -368,17 +378,30 @@ def is_primary_identifier_equal(
368
378
for primary_identifier in primary_identifier_path
369
379
)
370
380
371
- def _make_payload (self , action , request , callback_context = None ):
372
- return {
373
- "credentials" : self ._creds .copy (),
374
- "action" : action ,
375
- "request" : {"clientRequestToken" : self .generate_token (), ** request },
376
- "callbackContext" : callback_context ,
377
- }
381
+ def _make_payload (self , action , current_model , previous_model = None , ** kwargs ):
382
+ return self .make_request (
383
+ current_model ,
384
+ previous_model ,
385
+ self .region ,
386
+ self .account ,
387
+ self .partition ,
388
+ action ,
389
+ self ._creds .copy (),
390
+ self .generate_token (),
391
+ ** kwargs
392
+ )
378
393
379
394
def _call (self , payload ):
380
395
payload_to_log = {
381
- key : payload [key ] for key in ["callbackContext" , "action" , "request" ]
396
+ key : payload [key ]
397
+ for key in [
398
+ "callbackContext" ,
399
+ "action" ,
400
+ "requestData" ,
401
+ "region" ,
402
+ "awsPartition" ,
403
+ "awsAccountId" ,
404
+ ]
382
405
}
383
406
LOG .debug (
384
407
"Sending request\n %s" ,
@@ -397,27 +420,19 @@ def call_and_assert(
397
420
):
398
421
if assert_status not in [OperationStatus .SUCCESS , OperationStatus .FAILED ]:
399
422
raise ValueError ("Assert status {} not supported." .format (assert_status ))
400
- request = self .make_request (
401
- current_model ,
402
- previous_model ,
403
- self .region ,
404
- self .account ,
405
- self .partition ,
406
- ** kwargs
407
- )
408
423
409
- status , response = self .call (action , request )
424
+ status , response = self .call (action , current_model , previous_model , ** kwargs )
410
425
if assert_status == OperationStatus .SUCCESS :
411
426
self .assert_success (status , response )
412
427
error_code = None
413
428
else :
414
429
error_code = self .assert_failed (status , response )
415
430
return status , response , error_code
416
431
417
- def call (self , action , request ):
418
- payload = self ._make_payload (action , request )
432
+ def call (self , action , current_model , previous_model = None , ** kwargs ):
433
+ request = self ._make_payload (action , current_model , previous_model , ** kwargs )
419
434
start_time = time .time ()
420
- response = self ._call (payload )
435
+ response = self ._call (request )
421
436
self .assert_time (start_time , time .time (), action )
422
437
423
438
# this throws a KeyError if status isn't present, or if it isn't a valid status
@@ -434,11 +449,10 @@ def call(self, action, request):
434
449
)
435
450
sleep (callback_delay_seconds )
436
451
437
- request ["desiredResourceState" ] = response .get ("resourceModel" )
438
- payload ["callbackContext" ] = response .get ("callbackContext" )
439
- payload ["request" ] = request
452
+ request ["requestData" ]["resourceProperties" ] = response .get ("resourceModel" )
453
+ request ["callbackContext" ] = response .get ("callbackContext" )
440
454
441
- response = self ._call (payload )
455
+ response = self ._call (request )
442
456
status = OperationStatus [response ["status" ]]
443
457
444
458
# ensure writeOnlyProperties are not returned on final responses
0 commit comments