@@ -71,6 +71,32 @@ def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
71
71
security_token = security_token ,
72
72
validate_certs = validate_certs )
73
73
74
+ def _build_dict_as_list_params (self , params , dictionary , name ):
75
+ """
76
+ Serialize a parameter 'name' which value is a 'dictionary' into a list of parameters.
77
+
78
+ See: http://docs.aws.amazon.com/sns/latest/api/API_SetPlatformApplicationAttributes.html
79
+ For example::
80
+
81
+ dictionary = {'PlatformPrincipal': 'foo', 'PlatformCredential': 'bar'}
82
+ name = 'Attributes'
83
+
84
+ would result in params dict being populated with:
85
+ Attributes.entry.1.key = PlatformPrincipal
86
+ Attributes.entry.1.value = foo
87
+ Attributes.entry.2.key = PlatformCredential
88
+ Attributes.entry.2.value = bar
89
+
90
+ :param params: the resulting parameters will be added to this dict
91
+ :param dictionary: dict - value of the serialized parameter
92
+ :param name: name of the serialized parameter
93
+ """
94
+ for kv , index in zip (dictionary .items (), range (1 , len (dictionary .items ())+ 1 )):
95
+ key , value = kv
96
+ prefix = '%s.entry.%s' % (name , index )
97
+ params ['%s.key' % prefix ] = key
98
+ params ['%s.value' % prefix ] = value
99
+
74
100
def _required_auth_capability (self ):
75
101
return ['hmac-v4' ]
76
102
@@ -406,7 +432,7 @@ def create_platform_application(self, name=None, platform=None,
406
432
if platform is not None :
407
433
params ['Platform' ] = platform
408
434
if attributes is not None :
409
- params [ 'Attributes' ] = attributes
435
+ self . _build_dict_as_list_params ( params , attributes , 'Attributes' )
410
436
return self ._make_request (action = 'CreatePlatformApplication' ,
411
437
params = params )
412
438
@@ -453,7 +479,7 @@ def set_platform_application_attributes(self,
453
479
if platform_application_arn is not None :
454
480
params ['PlatformApplicationArn' ] = platform_application_arn
455
481
if attributes is not None :
456
- params [ 'Attributes' ] = attributes
482
+ self . _build_dict_as_list_params ( params , attributes , 'Attributes' )
457
483
return self ._make_request (action = 'SetPlatformApplicationAttributes' ,
458
484
params = params )
459
485
@@ -601,7 +627,7 @@ def create_platform_endpoint(self, platform_application_arn=None,
601
627
if custom_user_data is not None :
602
628
params ['CustomUserData' ] = custom_user_data
603
629
if attributes is not None :
604
- params [ 'Attributes' ] = attributes
630
+ self . _build_dict_as_list_params ( params , attributes , 'Attributes' )
605
631
return self ._make_request (action = 'CreatePlatformEndpoint' ,
606
632
params = params )
607
633
@@ -654,7 +680,7 @@ def set_endpoint_attributes(self, endpoint_arn=None, attributes=None):
654
680
if endpoint_arn is not None :
655
681
params ['EndpointArn' ] = endpoint_arn
656
682
if attributes is not None :
657
- params [ 'Attributes' ] = attributes
683
+ self . _build_dict_as_list_params ( params , attributes , 'Attributes' )
658
684
return self ._make_request (action = 'SetEndpointAttributes' ,
659
685
params = params )
660
686
0 commit comments