Skip to content

Commit

Permalink
Merge branch 'release-0.32.0'
Browse files Browse the repository at this point in the history
* release-0.32.0:
  Bumping version to 0.32.0
  Update models to the lastet version
  Backing out #221 for now.  It's causing errors in the integration tests.
  Add handler to override signature version based on cfg value
  Support one level of nested configs
  Add event handler to quote the x-amz-copy-source header value as expected by S3.  Fixes aws/aws-cli#614.
  Update EC2 to latest model
  Adding new EU endpoint for SES.
  • Loading branch information
jamesls committed Jan 29, 2014
2 parents dce39e3 + 2b7abff commit d3fdbca
Show file tree
Hide file tree
Showing 17 changed files with 6,285 additions and 9,571 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.31.0'
__version__ = '0.32.0'


class NullHandler(logging.Handler):
Expand Down
32 changes: 31 additions & 1 deletion botocore/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,35 @@ def get_config(session):
for section in cp.sections():
config[section] = {}
for option in cp.options(section):
config[section][option] = cp.get(section, option)
config_value = cp.get(section, option)
if config_value.startswith('\n'):
# Then we need to parse the inner contents as
# hierarchical. We support a single level
# of nesting for now.
try:
config_value = _parse_nested(config_value)
except ValueError:
raise botocore.exceptions.ConfigParseError(
path=path)
config[section][option] = config_value
return config


def _parse_nested(config_value):
# Given a value like this:
# \n
# foo = bar
# bar = baz
# We need to parse this into
# {'foo': 'bar', 'bar': 'baz}
parsed = {}
for line in config_value.splitlines():
line = line.strip()
if not line:
continue
# The caller will catch ValueError
# and raise an appropriate error
# if this fails.
key, value = line.split('=', 1)
parsed[key.strip()] = value.strip()
return parsed
7,624 changes: 2,983 additions & 4,641 deletions botocore/data/aws/ec2.json

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions botocore/data/aws/ses.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"service_abbreviation": "Amazon SES",
"endpoint_prefix": "email",
"xmlnamespace": "http://ses.amazonaws.com/doc/2010-12-01/",
"documentation": "\n <fullname>Amazon Simple Email Service</fullname>\n <p>\n This is the API Reference for Amazon Simple Email Service (Amazon SES). This documentation is intended to be\n used in conjunction with the Amazon SES Developer Guide.\n </p>\n <p>\n For specific details on how to construct a service request, please consult the <a href=\"http://docs.aws.amazon.com/ses/latest/DeveloperGuide\">Amazon SES Developer Guide</a>.\n </p>\n <note>The endpoint for Amazon SES is located at:\n <code>https://email.us-east-1.amazonaws.com</code>\n </note>\n ",
"documentation": "\n <fullname>Amazon Simple Email Service</fullname>\n <p>\n This is the API Reference for Amazon Simple Email Service (Amazon SES). This documentation is intended to be\n used in conjunction with the <a href=\"http://docs.aws.amazon.com/ses/latest/DeveloperGuide/Welcome.html\">Amazon SES Developer Guide</a>.\n </p>\n <note>For a list of Amazon SES endpoints to use in service requests, see <a href=\"http://docs.aws.amazon.com/ses/latest/DeveloperGuide/regions.html\">Regions and Amazon SES</a> \n in the Amazon SES Developer Guide. \n </note>\n ",
"operations": {
"DeleteIdentity": {
"name": "DeleteIdentity",
Expand Down Expand Up @@ -859,7 +859,9 @@
},
"metadata": {
"regions": {
"us-east-1": null
"us-east-1": null,
"eu-west-1": null,
"us-west-2": null
},
"protocols": [
"https",
Expand Down
253 changes: 152 additions & 101 deletions botocore/data/aws/sqs.json

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions botocore/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,19 @@ def maybe_switch_to_sigv4(service, region_name, **kwargs):
service.signature_version = 'v4'


def signature_overrides(service_data, service_name, session, **kwargs):
config = session.get_config()
service_config = config.get(service_name)
if service_config is None or not isinstance(service_config, dict):
return
signature_version_override = service_config.get('signature_version')
if signature_version_override is not None:
logger.debug("Switching signature version for service %s "
"to version %s based on config file override.",
service_name, signature_version_override)
service_data['signature_version'] = signature_version_override


# This is a list of (event_name, handler).
# When a Session is created, everything in this list will be
# automatically registered with that Session.
Expand All @@ -204,4 +217,5 @@ def maybe_switch_to_sigv4(service, region_name, **kwargs):
('service-created', register_retries_for_service),
('creating-endpoint.s3', maybe_switch_to_s3sigv4),
('creating-endpoint.ec2', maybe_switch_to_sigv4),
('service-data-loaded', signature_overrides),
]
13 changes: 10 additions & 3 deletions botocore/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@
from botocore import handlers





class Session(object):
"""
The Session object collects together useful functionality
Expand All @@ -62,6 +59,7 @@ class Session(object):
'before-parameter-build': '.%s.%s',
'before-call': '.%s.%s',
'service-created': '',
'service-data-loaded': '.%s',
'creating-endpoint': '.%s',
'before-auth': '.%s',
'needs-retry': '.%s.%s',
Expand Down Expand Up @@ -315,6 +313,12 @@ def get_config(self):
using the default ``profile`` session variable. If it has already been
loaded, the cached configuration will be returned.
The configuration data is loaded **only** from the config file.
It does not resolve variables based on different locations
(e.g. first from the session instance, then from environment
variables, then from the config file). If you want this lookup
behavior, use the ``get_config_variable`` method instead.
Note that this configuration is specific to a single profile (the
``profile`` session variable).
Expand Down Expand Up @@ -432,6 +436,9 @@ def get_service_data(self, service_name):
"""
data_path = '%s/%s' % (self.provider.name, service_name)
service_data = self.get_data(data_path)
event_name = self.create_event('service-data-loaded', service_name)
self._events.emit(event_name, service_data=service_data,
service_name=service_name, session=self)
return service_data

def get_available_services(self):
Expand Down
Loading

0 comments on commit d3fdbca

Please sign in to comment.