Skip to content

Commit

Permalink
Merge branch 'release-0.27.0'
Browse files Browse the repository at this point in the history
* release-0.27.0:
  Bumping version to 0.27.0
  Bump jmespath version to 0.2.0
  Mark WebsiteRedirectLocation with no_paramfile
  Update service model to the latest version
  Add a botocore-specific test for updated handling of maps in query interfaces.
  Fix handling of unflattened map parameters in query services.  Part of the fix for aws/aws-cli#407.
  Fix handling of empty values for required list parameters.  Fixes aws/aws-cli#524.
  Merge branch 'develop', remote-tracking branch 'origin' into develop
  • Loading branch information
jamesls committed Dec 6, 2013
2 parents b2d4024 + 7dd7f44 commit 309cdc7
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 19 deletions.
2 changes: 1 addition & 1 deletion botocore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import re
import logging

__version__ = '0.26.0'
__version__ = '0.27.0'


class NullHandler(logging.Handler):
Expand Down
9 changes: 6 additions & 3 deletions botocore/data/aws/s3.json
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@
"type": "string",
"location": "header",
"location_name": "x-amz-website-redirect-location",
"documentation": "If the bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. Amazon S3 stores the value of this header in the object metadata."
"documentation": "If the bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. Amazon S3 stores the value of this header in the object metadata.",
"no_paramfile": true
}
}
},
Expand Down Expand Up @@ -604,7 +605,8 @@
"type": "string",
"location": "header",
"location_name": "x-amz-website-redirect-location",
"documentation": "If the bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. Amazon S3 stores the value of this header in the object metadata."
"documentation": "If the bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. Amazon S3 stores the value of this header in the object metadata.",
"no_paramfile": true
}
}
},
Expand Down Expand Up @@ -3816,7 +3818,8 @@
"type": "string",
"location": "header",
"location_name": "x-amz-website-redirect-location",
"documentation": "If the bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. Amazon S3 stores the value of this header in the object metadata."
"documentation": "If the bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. Amazon S3 stores the value of this header in the object metadata.",
"no_paramfile": true
}
}
},
Expand Down
6 changes: 2 additions & 4 deletions botocore/data/aws/support.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@
"shape_name": "ServiceCode",
"type": "string",
"pattern": "[0-9a-z\\-_]+",
"documentation": "\n <p>Code for the AWS service returned by the call to <a href=\"http://docs.aws.amazon.com/awssupport/latest/APIReference/API_DescribeServices.html\" title=\"DescribeServices\">DescribeServices</a>.</p>\n ",
"required": true
"documentation": "\n <p>Code for the AWS service returned by the call to <a href=\"http://docs.aws.amazon.com/awssupport/latest/APIReference/API_DescribeServices.html\" title=\"DescribeServices\">DescribeServices</a>.</p>\n "
},
"severityCode": {
"shape_name": "SeverityCode",
Expand All @@ -110,8 +109,7 @@
"categoryCode": {
"shape_name": "CategoryCode",
"type": "string",
"documentation": "\n <p>Specifies the category of problem for the AWS Support case. </p>\n ",
"required": true
"documentation": "\n <p>Specifies the category of problem for the AWS Support case. </p>\n "
},
"communicationBody": {
"shape_name": "CommunicationBody",
Expand Down
26 changes: 21 additions & 5 deletions botocore/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,17 @@ def build_parameter_query(self, value, built_params, label=''):
else:
label = self.get_label()
label = '%s.%s' % (label, 'member')
for i, v in enumerate(value, 1):
member_type.build_parameter_query(v, built_params,
'%s.%d' % (label, i))
if len(value) == 0 and self.required:
# If the parameter is required and an empty list is
# provided as a value, we should insert a parameter
# into the dictionary with the base name of the
# parameter and a value of the empty string. See
# ELB SetLoadBalancerPoliciesForBackendServer for example.
built_params[label.split('.')[0]] = ''
else:
for i, v in enumerate(value, 1):
member_type.build_parameter_query(v, built_params,
'%s.%d' % (label, i))

def build_parameter_json(self, value, built_params, label=''):
value = self.validate(value)
Expand Down Expand Up @@ -415,13 +423,21 @@ def _handle_subtypes(self):

def build_parameter_query(self, value, built_params, label=''):
label = self.get_label()
if not self.flattened:
label = '%s.entry' % label
key_type = self.keys
member_type = self.members
for i, v in enumerate(value, 1):
built_params['%s.%d.%s' % (label, i, key_type.xmlname)] = v
key_name = key_type.xmlname
if not key_name:
key_name = 'key'
built_params['%s.%d.%s' % (label, i, key_name)] = v
member_name = member_type.xmlname
if not member_name:
member_name = 'value'
member_type.build_parameter_query(
value[v], built_params,
'%s.%d.%s' % (label, i, member_type.xmlname))
'%s.%d.%s' % (label, i, member_name))

def build_parameter_json(self, value, built_params, label=''):
label = self.get_label()
Expand Down
27 changes: 27 additions & 0 deletions services/s3.extra.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,33 @@
}
}
}
},
"PutObject": {
"input": {
"members": {
"WebsiteRedirectLocation": {
"no_paramfile": true
}
}
}
},
"CopyObject": {
"input": {
"members": {
"WebsiteRedirectLocation": {
"no_paramfile": true
}
}
}
},
"CreateMultipartUpload": {
"input": {
"members": {
"WebsiteRedirectLocation": {
"no_paramfile": true
}
}
}
}
},
"pagination": {
Expand Down
6 changes: 2 additions & 4 deletions services/support.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@
"shape_name": "ServiceCode",
"type": "string",
"pattern": "[0-9a-z\\-_]+",
"documentation": "\n <p>Code for the AWS service returned by the call to <a href=\"http://docs.aws.amazon.com/awssupport/latest/APIReference/API_DescribeServices.html\" title=\"DescribeServices\">DescribeServices</a>.</p>\n ",
"required": true
"documentation": "\n <p>Code for the AWS service returned by the call to <a href=\"http://docs.aws.amazon.com/awssupport/latest/APIReference/API_DescribeServices.html\" title=\"DescribeServices\">DescribeServices</a>.</p>\n "
},
"severityCode": {
"shape_name": "SeverityCode",
Expand All @@ -110,8 +109,7 @@
"categoryCode": {
"shape_name": "CategoryCode",
"type": "string",
"documentation": "\n <p>Specifies the category of problem for the AWS Support case. </p>\n ",
"required": true
"documentation": "\n <p>Specifies the category of problem for the AWS Support case. </p>\n "
},
"communicationBody": {
"shape_name": "CommunicationBody",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


requires = ['six>=1.1.0',
'jmespath==0.1.0',
'jmespath==0.2.0',
'python-dateutil>=2.1']


Expand Down
21 changes: 21 additions & 0 deletions tests/unit/test_elb_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,27 @@ def test_register_instances_with_load_balancer(self):
'Instances.member.2.InstanceId': 'i-87654321'}
self.assertEqual(params, result)

def test_set_lb_policies_for_backend_server(self):
op = self.elb.get_operation('SetLoadBalancerPoliciesForBackendServer')
params = op.build_parameters(load_balancer_name='foobar',
instance_port=443,
policy_names=['fie', 'baz'])
result = {'LoadBalancerName': 'foobar',
'InstancePort': '443',
'PolicyNames.member.1': 'fie',
'PolicyNames.member.2': 'baz'}
self.assertEqual(params, result)

def test_clear_lb_policies_for_backend_server(self):
op = self.elb.get_operation('SetLoadBalancerPoliciesForBackendServer')
params = op.build_parameters(load_balancer_name='foobar',
instance_port=443,
policy_names=[])
result = {'LoadBalancerName': 'foobar',
'InstancePort': '443',
'PolicyNames': ''}
self.assertEqual(params, result)


if __name__ == "__main__":
unittest.main()
18 changes: 17 additions & 1 deletion tests/unit/test_sns_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
#
import unittest

from mock import Mock, sentinel
from mock import Mock

from botocore.compat import OrderedDict
import botocore.session


Expand Down Expand Up @@ -74,6 +75,21 @@ def test_sns_post_send_event_is_invoked(self):
self.assertEqual(calls[0]['http_response'], self.http_response)
self.assertEqual(calls[0]['parsed'], self.parsed_response)

def test_create_platform_application(self):
op = self.sns.get_operation('CreatePlatformApplication')
attributes = OrderedDict()
attributes['PlatformCredential'] = 'foo'
attributes['PlatformPrincipal'] = 'bar'
params = op.build_parameters(name='gcmpushapp', platform='GCM',
attributes=attributes)
result = {'Name': 'gcmpushapp',
'Platform': 'GCM',
'Attributes.entry.1.key': 'PlatformCredential',
'Attributes.entry.1.value': 'foo',
'Attributes.entry.2.key': 'PlatformPrincipal',
'Attributes.entry.2.value': 'bar'}
self.assertEqual(params, result)


if __name__ == "__main__":
unittest.main()

0 comments on commit 309cdc7

Please sign in to comment.