Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'release-2.8.0'

  • Loading branch information...
commit b5852b0aa5ac91f462b28ac9decee33d872dec4d 2 parents f325c6e + 3b1af9e
@garnaat garnaat authored
Showing with 6,378 additions and 1,294 deletions.
  1. +3 −2 README.rst
  2. +61 −15 bin/mturk
  3. +16 −6 bin/s3put
  4. +21 −1 boto/__init__.py
  5. +3 −0  boto/auth.py
  6. +29 −33 boto/beanstalk/__init__.py
  7. +2 −2 boto/beanstalk/layer1.py
  8. +120 −4 boto/cloudsearch/document.py
  9. +106 −39 boto/cloudsearch/search.py
  10. +41 −2 boto/connection.py
  11. +1 −1  boto/dynamodb/condition.py
  12. +23 −0 boto/ec2/autoscale/__init__.py
  13. +5 −1 boto/ec2/cloudwatch/alarm.py
  14. +12 −0 boto/ec2/connection.py
  15. +58 −0 boto/ec2/vmtype.py
  16. +62 −0 boto/elasticache/__init__.py
  17. +1,252 −0 boto/elasticache/layer1.py
  18. +62 −0 boto/elastictranscoder/__init__.py
  19. +46 −0 boto/elastictranscoder/exceptions.py
  20. +509 −0 boto/elastictranscoder/layer1.py
  21. +27 −1 boto/emr/connection.py
  22. +22 −3 boto/glacier/utils.py
  23. +2 −1  boto/glacier/vault.py
  24. +2 −0  boto/gs/acl.py
  25. +399 −115 boto/gs/bucket.py
  26. +309 −22 boto/gs/key.py
  27. +17 −6 boto/gs/resumable_upload_handler.py
  28. +1 −1  boto/iam/connection.py
  29. +2 −1  boto/mturk/question.py
  30. +16 −1 boto/rds/dbinstance.py
  31. +25 −9 boto/s3/bucket.py
  32. +45 −18 boto/s3/key.py
  33. +134 −0 boto/s3/keyfile.py
  34. +7 −0 boto/s3/prefix.py
  35. +4 −0 boto/s3/resumable_download_handler.py
  36. +237 −0 boto/s3/website.py
  37. +84 −20 boto/storage_uri.py
  38. +3 −1 boto/utils.py
  39. +41 −0 boto/vpc/__init__.py
  40. +231 −84 docs/source/cloudsearch_tut.rst
  41. +2 −0  docs/source/index.rst
  42. +1 −1  docs/source/ref/beanstalk.rst
  43. +19 −0 docs/source/ref/elasticache.rst
  44. +26 −0 docs/source/ref/elastictranscoder.rst
  45. +2 −2 docs/source/ref/glacier.rst
  46. +29 −5 docs/source/ref/gs.rst
  47. +2 −2 docs/source/ref/s3.rst
  48. +18 −20 docs/source/sqs_tut.rst
  49. +2 −1  setup.py
  50. 0  tests/integration/elasticache/__init__.py
  51. +67 −0 tests/integration/elasticache/test_layer1.py
  52. 0  tests/integration/elastictranscoder/__init__.py
  53. +35 −0 tests/integration/elastictranscoder/test_cert_verification.py
  54. +110 −0 tests/integration/elastictranscoder/test_layer1.py
  55. +379 −0 tests/integration/gs/test_basic.py
  56. +0 −365 tests/integration/gs/test_connection.py
  57. +399 −0 tests/integration/gs/test_generation_conditionals.py
  58. +143 −205 tests/integration/gs/test_resumable_downloads.py
  59. +195 −249 tests/integration/gs/test_resumable_uploads.py
  60. +117 −0 tests/integration/gs/test_storage_uri.py
  61. +106 −36 tests/integration/gs/test_versioning.py
  62. +116 −0 tests/integration/gs/testcase.py
  63. +48 −0 tests/integration/gs/util.py
  64. +98 −7 tests/integration/s3/mock_storage_service.py
  65. +21 −0 tests/integration/s3/test_bucket.py
  66. +34 −1 tests/unit/cloudfront/test_signed_urls.py
  67. +5 −0 tests/unit/glacier/test_utils.py
  68. +43 −11 tests/unit/glacier/test_vault.py
  69. +101 −0 tests/unit/s3/test_keyfile.py
  70. +160 −0 tests/unit/s3/test_website.py
  71. +60 −0 tests/unit/test_connection.py
View
5 README.rst
@@ -1,8 +1,8 @@
####
boto
####
-boto 2.7.0
-10-Jan-2013
+boto 2.8.0
+31-Jan-2013
.. image:: https://secure.travis-ci.org/boto/boto.png?branch=develop
:target: https://secure.travis-ci.org/boto/boto
@@ -29,6 +29,7 @@ At the moment, boto supports:
* Amazon Relational Data Service (RDS)
* Amazon DynamoDB
* Amazon SimpleDB
+ * Amazon ElastiCache
* Deployment and Management
View
76 bin/mturk
@@ -40,6 +40,28 @@ default_nicknames_path = os.path.expanduser('~/.boto_mturkcli_hit_nicknames')
nicknames = {}
nickname_pool = set(string.ascii_lowercase)
+time_units = dict(
+ s = 1,
+ min = 60,
+ h = 60 * 60,
+ d = 24 * 60 * 60)
+
+qual_requirements = dict(
+ Adult = '00000000000000000060',
+ Locale = '00000000000000000071',
+ NumberHITsApproved = '00000000000000000040',
+ PercentAssignmentsSubmitted = '00000000000000000000',
+ PercentAssignmentsAbandoned = '00000000000000000070',
+ PercentAssignmentsReturned = '000000000000000000E0',
+ PercentAssignmentsApproved = '000000000000000000L0',
+ PercentAssignmentsRejected = '000000000000000000S0')
+
+qual_comparators = {v : k for k, v in dict(
+ LessThan = '<', LessThanOrEqualTo = '<=',
+ GreaterThan = '>', GreaterThanOrEqualTo = '>=',
+ EqualTo = '==', NotEqualTo = '!=',
+ Exists = 'exists').items()}
+
example_config_file = '''Example configuration file:
{
@@ -53,7 +75,8 @@ example_config_file = '''Example configuration file:
"approval_delay": "14 d",
"qualifications": [
"PercentAssignmentsApproved > 90",
- "Locale == US"
+ "Locale == US",
+ "2ARFPLSP75KLA8M8DH1HTEQVJT3SY6 exists"
],
"question_url": "http://example.com/myhit",
"question_frame_height": 450
@@ -99,7 +122,6 @@ def save_nicknames(nicknames_path = default_nicknames_path):
json.dump(nicknames, o, sort_keys = True, indent = 4)
print >>o
-time_units = dict(s = 1, min = 60, h = 60 * 60, d = 24 * 60 * 60)
def parse_duration(s):
'''Parses durations like "2 d", "48 h", "2880 min",
"172800 s", or "172800".'''
@@ -110,17 +132,27 @@ def display_duration(n):
if n % m == 0:
return '{} {}'.format(n / m, unit)
-def parse_qualification(s):
- '''Parses qualifications like "PercentAssignmentsApproved > 90" and "Locale == US".'''
- name, comparator, value = s.split()
- f = dict(
- PercentAssignmentsApproved = boto.mturk.qualification.PercentAssignmentsApprovedRequirement,
- Locale = boto.mturk.qualification.LocaleRequirement)[name]
- comparator = {v : k for k, v in dict(
- LessThan = '<', LessThanOrEqualTo = '<=',
- GreaterThan = '>', GreaterThanOrEqualTo = '>=',
- EqualTo = '==', NotEqualTo = '!=').items()}[comparator]
- return f(comparator, value, required_to_preview = False)
+def parse_qualification(inp):
+ '''Parses qualifications like "PercentAssignmentsApproved > 90",
+"Locale == US", and "2ARFPLSP75KLA8M8DH1HTEQVJT3SY6 exists".'''
+ inp = inp.split()
+ name, comparator, value = inp.pop(0), inp.pop(0), (inp[0] if len(inp) else None)
+ qtid = qual_requirements.get(name)
+ if qtid is None:
+ # Treat "name" as a Qualification Type ID.
+ qtid = name
+ if qtid == qual_requirements['Locale']:
+ return boto.mturk.qualification.LocaleRequirement(
+ qual_comparators[comparator],
+ value,
+ required_to_preview = False)
+ return boto.mturk.qualification.Requirement(
+ qtid,
+ qual_comparators[comparator],
+ value,
+ required_to_preview = qtid == qual_requirements['Adult'])
+ # Thus required_to_preview is true only for the
+ # Worker_Adult requirement.
def preview_url(hit):
return 'https://{}/mturk/preview?groupId={}'.format(
@@ -280,6 +312,9 @@ def unreject_assignments(message, assignments):
con.approve_rejected_assignment(a, message)
if interactive: print 'Unrejected', a
+def notify_workers(subject, text, workers):
+ con.notify_workers(workers, subject, text)
+
# --------------------------------------------------
# Mainline code
# --------------------------------------------------
@@ -303,7 +338,7 @@ if __name__ == '__main__':
[get_hitid(args.hit)])
sub = subs.add_parser('hits',
- help = 'list all your HITS')
+ help = 'list all your HITs')
sub.set_defaults(f = list_hits, a = lambda: [])
sub = subs.add_parser('new',
@@ -378,7 +413,7 @@ if __name__ == '__main__':
[args.message, args.assignment])
sub = subs.add_parser('bonus',
- help = 'give a worker a bonus')
+ help = 'give some workers a bonus')
sub.add_argument('amount', type = float,
help = 'bonus amount, in USD')
sub.add_argument('message',
@@ -389,6 +424,17 @@ if __name__ == '__main__':
[args.message, args.amount,
[p.split(',') for p in args.widaid]])
+ sub = subs.add_parser('notify',
+ help = 'send a message to some workers')
+ sub.add_argument('subject',
+ help = 'subject of the message')
+ sub.add_argument('message',
+ help = 'text of the message')
+ sub.add_argument('worker', nargs = '+',
+ help = 'ID of a worker')
+ sub.set_defaults(f = notify_workers, a = lambda:
+ [args.subject, args.message, args.worker])
+
args = parser.parse_args()
init_by_args(args)
View
22 bin/s3put
@@ -53,7 +53,7 @@ SYNOPSIS
[-d/--debug <debug_level>] [-i/--ignore <ignore_dirs>]
[-n/--no_op] [-p/--prefix <prefix>] [-k/--key_prefix <key_prefix>]
[-q/--quiet] [-g/--grant grant] [-w/--no_overwrite] [-r/--reduced]
- [--header] """ + usage_string_multipart_capable + """ path [path...]
+ [--header] [--host <s3_host>]""" + usage_flag_multipart_capable + """ path [path...]
Where
access_key - Your AWS Access Key ID. If not supplied, boto will
@@ -67,7 +67,7 @@ SYNOPSIS
path - A path to a directory or file that represents the items
to be uploaded. If the path points to an individual file,
that file will be uploaded to the specified bucket. If the
- path points to a directory, s3_it will recursively traverse
+ path points to a directory, it will recursively traverse
the directory and upload all files to the specified bucket.
debug_level - 0 means no debug output (default), 1 means normal
debug output from boto, and 2 means boto debug output
@@ -101,8 +101,10 @@ SYNOPSIS
sync, even if the file has been updated locally if
the key exists on s3 the file on s3 will not be
updated.
- header - key=value paris of extra header(s) to pass along in the
- request""" + usage_string_multipart_capable + """
+ header - key=value pairs of extra header(s) to pass along in the
+ request
+ host - Hostname override, for using an endpoint other then AWS S3
+""" + usage_string_multipart_capable + """
If the -n option is provided, no files will be transferred to S3 but
@@ -238,6 +240,7 @@ def main():
no_overwrite = False
reduced = False
headers = {}
+ host = None
multipart_requested = False
try:
@@ -245,7 +248,8 @@ def main():
sys.argv[1:], 'a:b:c::d:g:hi:k:np:qs:wr',
['access_key=', 'bucket=', 'callback=', 'debug=', 'help', 'grant=',
'ignore=', 'key_prefix=', 'no_op', 'prefix=', 'quiet',
- 'secret_key=', 'no_overwrite', 'reduced', 'header=', 'multipart'])
+ 'secret_key=', 'no_overwrite', 'reduced', 'header=', 'multipart',
+ 'host='])
except:
usage()
@@ -286,6 +290,8 @@ def main():
if o in ('--header'):
(k, v) = a.split("=")
headers[k] = v
+ if o in ('--host'):
+ host = a
if o in ('--multipart'):
if multipart_capable:
multipart_requested = True
@@ -300,7 +306,11 @@ def main():
print "bucket name is required!"
usage()
- c = boto.connect_s3(aws_access_key_id=aws_access_key_id,
+ if host:
+ c = boto.connect_s3(host=host, aws_access_key_id=aws_access_key_id,
+ aws_secret_access_key=aws_secret_access_key)
+ else:
+ c = boto.connect_s3(aws_access_key_id=aws_access_key_id,
aws_secret_access_key=aws_secret_access_key)
c.debug = debug
b = c.get_bucket(bucket_name)
View
22 boto/__init__.py
@@ -35,7 +35,7 @@
import urlparse
from boto.exception import InvalidUriError
-__version__ = '2.7.0'
+__version__ = '2.8.0'
Version = __version__ # for backware compatibility
UserAgent = 'Boto/%s (%s)' % (__version__, sys.platform)
@@ -635,6 +635,26 @@ def connect_beanstalk(aws_access_key_id=None,
return Layer1(aws_access_key_id, aws_secret_access_key, **kwargs)
+def connect_elastictranscoder(aws_access_key_id=None,
+ aws_secret_access_key=None,
+ **kwargs):
+ """
+ :type aws_access_key_id: string
+ :param aws_access_key_id: Your AWS Access Key ID
+
+ :type aws_secret_access_key: string
+ :param aws_secret_access_key: Your AWS Secret Access Key
+
+ :rtype: :class:`boto.ets.layer1.ElasticTranscoderConnection`
+ :return: A connection to Amazon's Elastic Transcoder service
+ """
+ from boto.elastictranscoder.layer1 import ElasticTranscoderConnection
+ return ElasticTranscoderConnection(
+ aws_access_key_id=aws_access_key_id,
+ aws_secret_access_key=aws_secret_access_key,
+ **kwargs)
+
+
def storage_uri(uri_str, default_scheme='file', debug=0, validate=True,
bucket_storage_uri_class=BucketStorageUri,
suppress_consec_slashes=True):
View
3  boto/auth.py
@@ -188,6 +188,9 @@ def add_auth(self, http_request, **kwargs):
headers = http_request.headers
if 'Date' not in headers:
headers['Date'] = formatdate(usegmt=True)
+ if self._provider.security_token:
+ key = self._provider.security_token_header
+ headers[key] = self._provider.security_token
b64_hmac = self.sign_string(headers['Date'])
auth_hdr = self._provider.auth_header
View
62 boto/beanstalk/__init__.py
@@ -1,4 +1,3 @@
-# Copyright (c) 2013 Mitch Garnaat http://garnaat.org/
# Copyright (c) 2013 Amazon.com, Inc. or its affiliates.
# All Rights Reserved
#
@@ -20,49 +19,46 @@
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
-
-from layer1 import Layer1
+#
from boto.regioninfo import RegionInfo
-RegionData = {
- 'us-east-1': 'elasticbeanstalk.us-east-1.amazonaws.com',
- 'us-west-1': 'elasticbeanstalk.us-west-1.amazonaws.com',
- 'us-west-2': 'elasticbeanstalk.us-west-2.amazonaws.com',
- 'sa-east-1': 'elasticbeanstalk.sa-east-1.amazonaws.com',
- 'eu-west-1': 'elasticbeanstalk.eu-west-1.amazonaws.com',
- 'ap-northeast-1': 'elasticbeanstalk.ap-northeast-1.amazonaws.com',
- 'ap-southeast-1': 'elasticbeanstalk.ap-southeast-1.amazonaws.com',
- 'ap-southeast-2': 'elasticbeanstalk.ap-southeast-2.amazonaws.com',
-}
-
def regions():
"""
- Get all available regions for the Elastic Beanstalk service.
+ Get all available regions for the AWS Elastic Beanstalk service.
:rtype: list
- :return: A list of :class:`boto.RegionInfo` instances
+ :return: A list of :class:`boto.regioninfo.RegionInfo`
"""
- regions = []
- for region_name in RegionData:
- region = RegionInfo(name=region_name,
- endpoint=RegionData[region_name],
- connection_cls=Layer1)
- regions.append(region)
- return regions
+ import boto.beanstalk.layer1
+ return [RegionInfo(name='us-east-1',
+ endpoint='elasticbeanstalk.us-east-1.amazonaws.com',
+ connection_cls=boto.beanstalk.layer1.Layer1),
+ RegionInfo(name='us-west-1',
+ endpoint='elasticbeanstalk.us-west-1.amazonaws.com',
+ connection_cls=boto.beanstalk.layer1.Layer1),
+ RegionInfo(name='us-west-2',
+ endpoint='elasticbeanstalk.us-west-2.amazonaws.com',
+ connection_cls=boto.beanstalk.layer1.Layer1),
+ RegionInfo(name='ap-northeast-1',
+ endpoint='elasticbeanstalk.ap-northeast-1.amazonaws.com',
+ connection_cls=boto.beanstalk.layer1.Layer1),
+ RegionInfo(name='ap-southeast-1',
+ endpoint='elasticbeanstalk.ap-southeast-1.amazonaws.com',
+ connection_cls=boto.beanstalk.layer1.Layer1),
+ RegionInfo(name='ap-southeast-2',
+ endpoint='elasticbeanstalk.ap-southeast-2.amazonaws.com',
+ connection_cls=boto.beanstalk.layer1.Layer1),
+ RegionInfo(name='eu-west-1',
+ endpoint='elasticbeanstalk.eu-west-1.amazonaws.com',
+ connection_cls=boto.beanstalk.layer1.Layer1),
+ RegionInfo(name='sa-east-1',
+ endpoint='elasticbeanstalk.sa-east-1.amazonaws.com',
+ connection_cls=boto.beanstalk.layer1.Layer1),
+ ]
def connect_to_region(region_name, **kw_params):
- """
- Given a valid region name, return a
- :class:`boto.beanstalk.Layer1`.
-
- :param str region_name: The name of the region to connect to.
-
- :rtype: :class:`boto.beanstalk.Layer1` or ``None``
- :return: A connection to the given region, or None if an invalid region
- name is given
- """
for region in regions():
if region.name == region_name:
return region.connect(**kw_params)
View
4 boto/beanstalk/layer1.py
@@ -226,9 +226,9 @@ def create_configuration_template(self, application_name, template_name,
if solution_stack_name:
params['SolutionStackName'] = solution_stack_name
if source_configuration_application_name:
- params['ApplicationName'] = source_configuration_application_name
+ params['SourceConfiguration.ApplicationName'] = source_configuration_application_name
if source_configuration_template_name:
- params['TemplateName'] = source_configuration_template_name
+ params['SourceConfiguration.TemplateName'] = source_configuration_template_name
if environment_id:
params['EnvironmentId'] = environment_id
if description:
View
124 boto/cloudsearch/document.py
@@ -34,8 +34,50 @@ class SearchServiceException(Exception):
class CommitMismatchError(Exception):
pass
+class EncodingError(Exception):
+ """
+ Content sent for Cloud Search indexing was incorrectly encoded.
+
+ This usually happens when a document is marked as unicode but non-unicode
+ characters are present.
+ """
+ pass
+
+class ContentTooLongError(Exception):
+ """
+ Content sent for Cloud Search indexing was too long
+
+ This will usually happen when documents queued for indexing add up to more
+ than the limit allowed per upload batch (5MB)
+
+ """
+ pass
class DocumentServiceConnection(object):
+ """
+ A CloudSearch document service.
+
+ The DocumentServiceConection is used to add, remove and update documents in
+ CloudSearch. Commands are uploaded to CloudSearch in SDF (Search Document Format).
+
+ To generate an appropriate SDF, use :func:`add` to add or update documents,
+ as well as :func:`delete` to remove documents.
+
+ Once the set of documents is ready to be index, use :func:`commit` to send the
+ commands to CloudSearch.
+
+ If there are a lot of documents to index, it may be preferable to split the
+ generation of SDF data and the actual uploading into CloudSearch. Retrieve
+ the current SDF with :func:`get_sdf`. If this file is the uploaded into S3,
+ it can be retrieved back afterwards for upload into CloudSearch using
+ :func:`add_sdf_from_s3`.
+
+ The SDF is not cleared after a :func:`commit`. If you wish to continue
+ using the DocumentServiceConnection for another batch upload of commands,
+ you will need to :func:`clear_sdf` first to stop the previous batch of
+ commands from being uploaded again.
+
+ """
def __init__(self, domain=None, endpoint=None):
self.domain = domain
@@ -46,26 +88,95 @@ def __init__(self, domain=None, endpoint=None):
self._sdf = None
def add(self, _id, version, fields, lang='en'):
+ """
+ Add a document to be processed by the DocumentService
+
+ The document will not actually be added until :func:`commit` is called
+
+ :type _id: string
+ :param _id: A unique ID used to refer to this document.
+
+ :type version: int
+ :param version: Version of the document being indexed. If a file is
+ being reindexed, the version should be higher than the existing one
+ in CloudSearch.
+
+ :type fields: dict
+ :param fields: A dictionary of key-value pairs to be uploaded .
+
+ :type lang: string
+ :param lang: The language code the data is in. Only 'en' is currently
+ supported
+ """
+
d = {'type': 'add', 'id': _id, 'version': version, 'lang': lang,
'fields': fields}
self.documents_batch.append(d)
def delete(self, _id, version):
+ """
+ Schedule a document to be removed from the CloudSearch service
+
+ The document will not actually be scheduled for removal until .commit() is called
+
+ :type _id: string
+ :param _id: The unique ID of this document.
+
+ :type version: int
+ :param version: Version of the document to remove. The delete will only
+ occur if this version number is higher than the version currently
+ in the index.
+ """
+
d = {'type': 'delete', 'id': _id, 'version': version}
self.documents_batch.append(d)
def get_sdf(self):
+ """
+ Generate the working set of documents in Search Data Format (SDF)
+
+ :rtype: string
+ :returns: JSON-formatted string of the documents in SDF
+ """
+
return self._sdf if self._sdf else json.dumps(self.documents_batch)
def clear_sdf(self):
+ """
+ Clear the working documents from this DocumentServiceConnection
+
+ This should be used after a commit() if the connection will be reused
+ for another set of documents.
+ """
+
self._sdf = None
self.documents_batch = []
def add_sdf_from_s3(self, key_obj):
- """@todo (lucas) would be nice if this could just take an s3://uri..."""
+ """
+ Load an SDF from S3
+
+ Using this method will result in documents added through
+ :func:`add` and :func:`delete` being ignored.
+
+ :type key_obj: :class:`boto.s3.key.Key`
+ :param key_obj: An S3 key which contains an SDF
+ """
+ #@todo:: (lucas) would be nice if this could just take an s3://uri..."
+
self._sdf = key_obj.get_contents_as_string()
def commit(self):
+ """
+ Actually send an SDF to CloudSearch for processing
+
+ If an SDF file has been explicitly loaded it will be used. Otherwise,
+ documents added through :func:`add` and :func:`delete` will be used.
+
+ :rtype: :class:`CommitResponse`
+ :returns: A summary of documents added and deleted
+ """
+
sdf = self.get_sdf()
if ': null' in sdf:
@@ -110,8 +221,8 @@ def __init__(self, response, doc_service, sdf):
try:
self.content = json.loads(response.content)
except:
- boto.log.error('Error indexing documents.\nResponse Content:\n{}\n\n'
- 'SDF:\n{}'.format(response.content, self.sdf))
+ boto.log.error('Error indexing documents.\nResponse Content:\n{0}\n\n'
+ 'SDF:\n{1}'.format(response.content, self.sdf))
raise boto.exception.BotoServerError(self.response.status_code, '',
body=response.content)
@@ -119,6 +230,11 @@ def __init__(self, response, doc_service, sdf):
if self.status == 'error':
self.errors = [e.get('message') for e in self.content.get('errors',
[])]
+ for e in self.errors:
+ if "Illegal Unicode character" in e:
+ raise EncodingError("Illegal Unicode character in document")
+ elif e == "The Content-Length is too long":
+ raise ContentTooLongError("Content was too long")
else:
self.errors = []
@@ -143,5 +259,5 @@ def _check_num_ops(self, type_, response_num):
if response_num != commit_num:
raise CommitMismatchError(
- 'Incorrect number of {}s returned. Commit: {} Respose: {}'\
+ 'Incorrect number of {0}s returned. Commit: {1} Response: {2}'\
.format(type_, commit_num, response_num))
View
145 boto/cloudsearch/search.py
@@ -51,6 +51,11 @@ def __init__(self, **attrs):
self.query = attrs['query']
self.search_service = attrs['search_service']
+ self.facets = {}
+ if 'facets' in attrs:
+ for (facet, values) in attrs['facets'].iteritems():
+ self.facets[facet] = dict((k, v) for (k, v) in map(lambda x: (x['value'], x['count']), values['constraints']))
+
self.num_pages_needed = ceil(self.hits / self.query.real_size)
def __len__(self):
@@ -62,8 +67,8 @@ def __iter__(self):
def next_page(self):
"""Call Cloudsearch to get the next page of search results
- :rtype: :class:`exfm.cloudsearch.SearchResults`
- :return: A cloudsearch SearchResults object
+ :rtype: :class:`boto.cloudsearch.search.SearchResults`
+ :return: the following page of search results
"""
if self.query.page <= self.num_pages_needed:
self.query.start += self.query.real_size
@@ -161,43 +166,105 @@ def search(self, q=None, bq=None, rank=None, return_fields=None,
size=10, start=0, facet=None, facet_constraints=None,
facet_sort=None, facet_top_n=None, t=None):
"""
- Query Cloudsearch
+ Send a query to CloudSearch
+
+ Each search query should use at least the q or bq argument to specify
+ the search parameter. The other options are used to specify the
+ criteria of the search.
+
+ :type q: string
+ :param q: A string to search the default search fields for.
+
+ :type bq: string
+ :param bq: A string to perform a Boolean search. This can be used to
+ create advanced searches.
+
+ :type rank: List of strings
+ :param rank: A list of fields or rank expressions used to order the
+ search results. A field can be reversed by using the - operator.
+ ``['-year', 'author']``
+
+ :type return_fields: List of strings
+ :param return_fields: A list of fields which should be returned by the
+ search. If this field is not specified, only IDs will be returned.
+ ``['headline']``
+
+ :type size: int
+ :param size: Number of search results to specify
+
+ :type start: int
+ :param start: Offset of the first search result to return (can be used
+ for paging)
+
+ :type facet: list
+ :param facet: List of fields for which facets should be returned
+ ``['colour', 'size']``
+
+ :type facet_constraints: dict
+ :param facet_constraints: Use to limit facets to specific values
+ specified as comma-delimited strings in a Dictionary of facets
+ ``{'colour': "'blue','white','red'", 'size': "big"}``
+
+ :type facet_sort: dict
+ :param facet_sort: Rules used to specify the order in which facet
+ values should be returned. Allowed values are *alpha*, *count*,
+ *max*, *sum*. Use *alpha* to sort alphabetical, and *count* to sort
+ the facet by number of available result.
+ ``{'color': 'alpha', 'size': 'count'}``
+
+ :type facet_top_n: dict
+ :param facet_top_n: Dictionary of facets and number of facets to
+ return.
+ ``{'colour': 2}``
+
+ :type t: dict
+ :param t: Specify ranges for specific fields
+ ``{'year': '2000..2005'}``
- :type q:
- :param q:
+ :rtype: :class:`boto.cloudsearch.search.SearchResults`
+ :return: Returns the results of this search
- :type bq:
- :param bq:
+ The following examples all assume we have indexed a set of documents
+ with fields: *author*, *date*, *headline*
- :type rank:
- :param rank:
+ A simple search will look for documents whose default text search
+ fields will contain the search word exactly:
- :type return_fields:
- :param return_fields:
+ >>> search(q='Tim') # Return documents with the word Tim in them (but not Timothy)
- :type size:
- :param size:
+ A simple search with more keywords will return documents whose default
+ text search fields contain the search strings together or separately.
- :type start:
- :param start:
+ >>> search(q='Tim apple') # Will match "tim" and "apple"
- :type facet:
- :param facet:
+ More complex searches require the boolean search operator.
- :type facet_constraints:
- :param facet_constraints:
+ Wildcard searches can be used to search for any words that start with
+ the search string.
- :type facet_sort:
- :param facet_sort:
+ >>> search(bq="'Tim*'") # Return documents with words like Tim or Timothy)
+
+ Search terms can also be combined. Allowed operators are "and", "or",
+ "not", "field", "optional", "token", "phrase", or "filter"
+
+ >>> search(bq="(and 'Tim' (field author 'John Smith'))")
- :type facet_top_n:
- :param facet_top_n:
+ Facets allow you to show classification information about the search
+ results. For example, you can retrieve the authors who have written
+ about Tim:
- :type t:
- :param t:
+ >>> search(q='Tim', facet=['Author'])
- :rtype: :class:`exfm.cloudsearch.SearchResults`
- :return: A cloudsearch SearchResults object
+ With facet_constraints, facet_top_n and facet_sort more complicated
+ constraints can be specified such as returning the top author out of
+ John Smith and Mark Smith who have a document with the word Tim in it.
+
+ >>> search(q='Tim',
+ ... facet=['Author'],
+ ... facet_constraints={'author': "'John Smith','Mark Smith'"},
+ ... facet=['author'],
+ ... facet_top_n={'author': 1},
+ ... facet_sort={'author': 'count'})
"""
query = self.build_query(q=q, bq=bq, rank=rank,
@@ -211,11 +278,11 @@ def search(self, q=None, bq=None, rank=None, return_fields=None,
def __call__(self, query):
"""Make a call to CloudSearch
- :type query: :class:`exfm.cloudsearch.Query`
- :param query: A fully specified Query instance
+ :type query: :class:`boto.cloudsearch.search.Query`
+ :param query: A group of search criteria
- :rtype: :class:`exfm.cloudsearch.SearchResults`
- :return: A cloudsearch SearchResults object
+ :rtype: :class:`boto.cloudsearch.search.SearchResults`
+ :return: search results
"""
url = "http://%s/2011-02-01/search" % (self.endpoint)
params = query.to_params()
@@ -239,14 +306,14 @@ def __call__(self, query):
def get_all_paged(self, query, per_page):
"""Get a generator to iterate over all pages of search results
- :type query: :class:`exfm.cloudsearch.Query`
- :param query: A fully specified Query instance
+ :type query: :class:`boto.cloudsearch.search.Query`
+ :param query: A group of search criteria
:type per_page: int
- :param per_page: Number of docs in each SearchResults object.
+ :param per_page: Number of docs in each :class:`boto.cloudsearch.search.SearchResults` object.
:rtype: generator
- :return: Generator containing :class:`exfm.cloudsearch.SearchResults`
+ :return: Generator containing :class:`boto.cloudsearch.search.SearchResults`
"""
query.update_size(per_page)
page = 0
@@ -266,8 +333,8 @@ def get_all_hits(self, query):
you can iterate over all results in a reasonably efficient
manner.
- :type query: :class:`exfm.cloudsearch.Query`
- :param query: A fully specified Query instance
+ :type query: :class:`boto.cloudsearch.search.Query`
+ :param query: A group of search criteria
:rtype: generator
:return: All docs matching query
@@ -285,8 +352,8 @@ def get_all_hits(self, query):
def get_num_hits(self, query):
"""Return the total number of hits for query
- :type query: :class:`exfm.cloudsearch.Query`
- :param query: A fully specified Query instance
+ :type query: :class:`boto.cloudsearch.search.Query`
+ :param query: a group of search criteria
:rtype: int
:return: Total number of hits for query
View
43 boto/connection.py
@@ -821,7 +821,7 @@ def _mexe(self, request, sender=None, override_num_retries=None,
i = 0
connection = self.get_http_connection(request.host, self.is_secure)
while i <= num_retries:
- # Use binary exponential backoff to desynchronize client requests
+ # Use binary exponential backoff to desynchronize client requests.
next_sleep = random.random() * (2 ** i)
try:
# we now re-sign each request before it is retried
@@ -974,12 +974,51 @@ def make_request(self, action, params=None, path='/', verb='GET'):
return self._mexe(http_request)
def build_list_params(self, params, items, label):
- # Convert comma- or whitespace-delimited string to array
if isinstance(items, basestring):
items = [items]
for i in range(1, len(items) + 1):
params['%s.%d' % (label, i)] = items[i - 1]
+ def build_complex_list_params(self, params, items, label, names):
+ """Serialize a list of structures.
+
+ For example::
+
+ items = [('foo', 'bar', 'baz'), ('foo2', 'bar2', 'baz2')]
+ label = 'ParamName.member'
+ names = ('One', 'Two', 'Three')
+ self.build_complex_list_params(params, items, label, names)
+
+ would result in the params dict being updated with these params::
+
+ ParamName.member.1.One = foo
+ ParamName.member.1.Two = bar
+ ParamName.member.1.Three = baz
+
+ ParamName.member.2.One = foo2
+ ParamName.member.2.Two = bar2
+ ParamName.member.2.Three = baz2
+
+ :type params: dict
+ :param params: The params dict. The complex list params
+ will be added to this dict.
+
+ :type items: list of tuples
+ :param items: The list to serialize.
+
+ :type label: string
+ :param label: The prefix to apply to the parameter.
+
+ :type names: tuple of strings
+ :param names: The names associated with each tuple element.
+
+ """
+ for i, item in enumerate(items, 1):
+ current_prefix = '%s.%s' % (label, i)
+ for key, value in zip(names, item):
+ full_key = '%s.%s' % (current_prefix, key)
+ params[full_key] = value
+
# generics
def get_list(self, action, params, markers, path='/',
View
2  boto/dynamodb/condition.py
@@ -92,7 +92,7 @@ def __init__(self, values):
self.values = values
def __repr__(self):
- return '{}({})'.format(self.__class__.__name__,
+ return '{0}({1})'.format(self.__class__.__name__,
', '.join(self.values))
def to_dict(self):
View
23 boto/ec2/autoscale/__init__.py
@@ -703,6 +703,29 @@ def set_instance_health(self, instance_id, health_status,
params['ShouldRespectGracePeriod'] = 'false'
return self.get_status('SetInstanceHealth', params)
+ def set_desired_capacity(self, group_name, desired_capacity, honor_cooldown=False):
+ """
+ Adjusts the desired size of the AutoScalingGroup by initiating scaling
+ activities. When reducing the size of the group, it is not possible to define
+ which Amazon EC2 instances will be terminated. This applies to any Auto Scaling
+ decisions that might result in terminating instances.
+
+ :type group_name: string
+ :param group_name: name of the auto scaling group
+
+ :type desired_capacity: integer
+ :param desired_capacity: new capacity setting for auto scaling group
+
+ :type honor_cooldown: boolean
+ :param honor_cooldown: by default, overrides any cooldown period
+ """
+ params = {'AutoScalingGroupName': group_name,
+ 'DesiredCapacity': desired_capacity}
+ if honor_cooldown:
+ params['HonorCooldown'] = json.dumps('True')
+
+ return self.get_status('SetDesiredCapacity', params)
+
# Tag methods
def get_all_tags(self, filters=None, max_records=None, next_token=None):
View
6 boto/ec2/cloudwatch/alarm.py
@@ -308,5 +308,9 @@ def endElement(self, name, value, connection):
elif name == 'HistorySummary':
self.summary = value
elif name == 'Timestamp':
- self.timestamp = datetime.strptime(value, '%Y-%m-%dT%H:%M:%S.%fZ')
+ try:
+ self.timestamp = datetime.strptime(value,
+ '%Y-%m-%dT%H:%M:%S.%fZ')
+ except ValueError:
+ self.timestamp = datetime.strptime(value, '%Y-%m-%dT%H:%M:%SZ')
View
12 boto/ec2/connection.py
@@ -54,6 +54,7 @@
from boto.ec2.bundleinstance import BundleInstanceTask
from boto.ec2.placementgroup import PlacementGroup
from boto.ec2.tag import Tag
+from boto.ec2.vmtype import VmType
from boto.ec2.instancestatus import InstanceStatusSet
from boto.ec2.volumestatus import VolumeStatusSet
from boto.ec2.networkinterface import NetworkInterface
@@ -3397,3 +3398,14 @@ def delete_network_interface(self, network_interface_id):
"""
params = {'NetworkInterfaceId': network_interface_id}
return self.get_status('DeleteNetworkInterface', params, verb='POST')
+
+ def get_all_vmtypes(self):
+ """
+ Get all vmtypes available on this cloud (eucalyptus specific)
+
+ :rtype: list of :class:`boto.ec2.vmtype.VmType`
+ :return: The requested VmType objects
+ """
+ params = {}
+ return self.get_list('DescribeVmTypes', params, [('euca:item', VmType)], verb='POST')
+
View
58 boto/ec2/vmtype.py
@@ -0,0 +1,58 @@
+# Copyright (c) 2006-2009 Mitch Garnaat http://garnaat.org/
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish, dis-
+# tribute, sublicense, and/or sell copies of the Software, and to permit
+# persons to whom the Software is furnished to do so, subject to the fol-
+# lowing conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+
+
+from boto.ec2.ec2object import EC2Object
+
+class VmType(EC2Object):
+ """
+ Represents an EC2 VM Type
+
+ :ivar name: The name of the vm type
+ :ivar cores: The number of cpu cores for this vm type
+ :ivar memory: The amount of memory in megabytes for this vm type
+ :ivar disk: The amount of disk space in gigabytes for this vm type
+ """
+
+ def __init__(self, connection=None, name=None, cores=None, memory=None, disk=None):
+ EC2Object.__init__(self, connection)
+ self.connection = connection
+ self.name = name
+ self.cores = cores
+ self.memory = memory
+ self.disk = disk
+
+ def __repr__(self):
+ return 'VmType:%s-%s,%s,%s' % (self.name, self.cores, self.memory, self.disk)
+
+ def endElement(self, name, value, connection):
+ if name == 'euca:name':
+ self.name = value
+ elif name == 'euca:cpu':
+ self.cores = value
+ elif name == 'euca:disk':
+ self.disk = value
+ elif name == 'euca:memory':
+ self.memory = value
+ else:
+ setattr(self, name, value)
+
+
View
62 boto/elasticache/__init__.py
@@ -0,0 +1,62 @@
+# Copyright (c) 2013 Amazon.com, Inc. or its affiliates.
+# All Rights Reserved
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish, dis-
+# tribute, sublicense, and/or sell copies of the Software, and to permit
+# persons to whom the Software is furnished to do so, subject to the fol-
+# lowing conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+#
+from boto.regioninfo import RegionInfo
+
+
+def regions():
+ """
+ Get all available regions for the AWS Elastic Beanstalk service.
+
+ :rtype: list
+ :return: A list of :class:`boto.regioninfo.RegionInfo`
+ """
+ from boto.elasticache.layer1 import ElastiCacheConnection
+ return [RegionInfo(name='us-east-1',
+ endpoint='elasticache.us-east-1.amazonaws.com',
+ connection_cls=ElastiCacheConnection),
+ RegionInfo(name='us-west-1',
+ endpoint='elasticache.us-west-1.amazonaws.com',
+ connection_cls=ElastiCacheConnection),
+ RegionInfo(name='us-west-2',
+ endpoint='elasticache.us-west-2.amazonaws.com',
+ connection_cls=ElastiCacheConnection),
+ RegionInfo(name='eu-west-1',
+ endpoint='elasticache.eu-west-1.amazonaws.com',
+ connection_cls=ElastiCacheConnection),
+ RegionInfo(name='ap-northeast-1',
+ endpoint='elasticache.ap-northeast-1.amazonaws.com',
+ connection_cls=ElastiCacheConnection),
+ RegionInfo(name='ap-southeast-1',
+ endpoint='elasticache.ap-southeast-1.amazonaws.com',
+ connection_cls=ElastiCacheConnection),
+ RegionInfo(name='sa-east-1',
+ endpoint='elasticache.sa-east-1.amazonaws.com',
+ connection_cls=ElastiCacheConnection),
+ ]
+
+
+def connect_to_region(region_name, **kw_params):
+ for region in regions():
+ if region.name == region_name:
+ return region.connect(**kw_params)
+ return None
View
1,252 boto/elasticache/layer1.py
@@ -0,0 +1,1252 @@
+# Copyright (c) 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish, dis-
+# tribute, sublicense, and/or sell copies of the Software, and to permit
+# persons to whom the Software is furnished to do so, subject to the fol-
+# lowing conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+#
+
+import json
+import boto
+from boto.connection import AWSQueryConnection
+from boto.regioninfo import RegionInfo
+
+
+class ElastiCacheConnection(AWSQueryConnection):
+ """
+ Amazon ElastiCache
+ Amazon ElastiCache is a web service that makes it easier to set
+ up, operate, and scale a distributed cache in the cloud.
+
+ With Amazon ElastiCache, customers gain all of the benefits of a
+ high-performance, in-memory cache with far less of the
+ administrative burden of launching and managing a distributed
+ cache. The service makes set-up, scaling, and cluster failure
+ handling much simpler than in a self-managed cache deployment.
+
+ In addition, through integration with Amazon CloudWatch, customers
+ get enhanced visibility into the key performance statistics
+ associated with their cache and can receive alarms if a part of
+ their cache runs hot.
+ """
+ APIVersion = "2012-11-15"
+ DefaultRegionName = "us-east-1"
+ DefaultRegionEndpoint = "elasticache.us-east-1.amazonaws.com"
+
+ def __init__(self, **kwargs):
+ region = kwargs.get('region')
+ if not region:
+ region = RegionInfo(self, self.DefaultRegionName,
+ self.DefaultRegionEndpoint)
+ else:
+ del kwargs['region']
+ kwargs['host'] = region.endpoint
+ AWSQueryConnection.__init__(self, **kwargs)
+ self.region = region
+
+
+ def _required_auth_capability(self):
+ return ['sign-v2']
+
+ def authorize_cache_security_group_ingress(self,
+ cache_security_group_name,
+ ec2_security_group_name,
+ ec2_security_group_owner_id):
+ """
+ Authorizes ingress to a CacheSecurityGroup using EC2 Security
+ Groups as authorization (therefore the application using the
+ cache must be running on EC2 clusters). This API requires the
+ following parameters: EC2SecurityGroupName and
+ EC2SecurityGroupOwnerId.
+ You cannot authorize ingress from an EC2 security group in one
+ Region to an Amazon Cache Cluster in another.
+
+ :type cache_security_group_name: string
+ :param cache_security_group_name: The name of the Cache Security Group
+ to authorize.
+
+ :type ec2_security_group_name: string
+ :param ec2_security_group_name: Name of the EC2 Security Group to
+ include in the authorization.
+
+ :type ec2_security_group_owner_id: string
+ :param ec2_security_group_owner_id: AWS Account Number of the owner of
+ the security group specified in the EC2SecurityGroupName parameter.
+ The AWS Access Key ID is not an acceptable value.
+
+ """
+ params = {
+ 'CacheSecurityGroupName': cache_security_group_name,
+ 'EC2SecurityGroupName': ec2_security_group_name,
+ 'EC2SecurityGroupOwnerId': ec2_security_group_owner_id,
+ }
+ return self._make_request(
+ action='AuthorizeCacheSecurityGroupIngress',
+ verb='POST',
+ path='/', params=params)
+
+ def create_cache_cluster(self, cache_cluster_id, num_cache_nodes,
+ cache_node_type, engine, engine_version=None,
+ cache_parameter_group_name=None,
+ cache_subnet_group_name=None,
+ cache_security_group_names=None,
+ security_group_ids=None,
+ preferred_availability_zone=None,
+ preferred_maintenance_window=None, port=None,
+ notification_topic_arn=None,
+ auto_minor_version_upgrade=None):
+ """
+ Creates a new Cache Cluster.
+
+ :type cache_cluster_id: string
+ :param cache_cluster_id: The Cache Cluster identifier. This parameter
+ is stored as a lowercase string.
+
+ :type num_cache_nodes: integer
+ :param num_cache_nodes: The number of Cache Nodes the Cache Cluster
+ should have.
+
+ :type cache_node_type: string
+ :param cache_node_type: The compute and memory capacity of nodes in a
+ Cache Cluster.
+
+ :type engine: string
+ :param engine: The name of the cache engine to be used for this Cache
+ Cluster. Currently, memcached is the only cache engine supported
+ by the service.
+
+ :type engine_version: string
+ :param engine_version: The version of the cache engine to be used for
+ this cluster.
+
+ :type cache_parameter_group_name: string
+ :param cache_parameter_group_name: The name of the cache parameter
+ group to associate with this Cache cluster. If this argument is
+ omitted, the default CacheParameterGroup for the specified engine
+ will be used.
+
+ :type cache_subnet_group_name: string
+ :param cache_subnet_group_name: The name of the Cache Subnet Group to
+ be used for the Cache Cluster. Use this parameter only when you
+ are creating a cluster in an Amazon Virtual Private Cloud (VPC).
+
+ :type cache_security_group_names: list
+ :param cache_security_group_names: A list of Cache Security Group Names
+ to associate with this Cache Cluster. Use this parameter only when
+ you are creating a cluster outside of an Amazon Virtual Private
+ Cloud (VPC).
+
+ :type security_group_ids: list
+ :param security_group_ids: Specifies the VPC Security Groups associated
+ with the Cache Cluster. Use this parameter only when you are
+ creating a cluster in an Amazon Virtual Private Cloud (VPC).
+
+ :type preferred_availability_zone: string
+ :param preferred_availability_zone: The EC2 Availability Zone that the
+ Cache Cluster will be created in. All cache nodes belonging to a
+ cache cluster are placed in the preferred availability zone.
+ Default: System chosen (random) availability zone.
+
+ :type preferred_maintenance_window: string
+ :param preferred_maintenance_window: The weekly time range (in UTC)
+ during which system maintenance can occur. Example:
+ `sun:05:00-sun:09:00`
+
+ :type port: integer
+ :param port: The port number on which each of the Cache Nodes will
+ accept connections.
+
+ :type notification_topic_arn: string
+ :param notification_topic_arn: The Amazon Resource Name (ARN) of the
+ Amazon Simple Notification Service (SNS) topic to which
+ notifications will be sent. The Amazon SNS topic owner must be the
+ same as the Cache Cluster owner.
+
+ :type auto_minor_version_upgrade: boolean
+ :param auto_minor_version_upgrade: Indicates that minor engine upgrades
+ will be applied automatically to the Cache Cluster during the
+ maintenance window. Default: `True`
+
+ """
+ params = {
+ 'CacheClusterId': cache_cluster_id,
+ 'NumCacheNodes': num_cache_nodes,
+ 'CacheNodeType': cache_node_type,
+ 'Engine': engine,
+ }
+ if engine_version is not None:
+ params['EngineVersion'] = engine_version
+ if cache_parameter_group_name is not None:
+ params['CacheParameterGroupName'] = cache_parameter_group_name
+ if cache_subnet_group_name is not None:
+ params['CacheSubnetGroupName'] = cache_subnet_group_name
+ if cache_security_group_names is not None:
+ self.build_list_params(params,
+ cache_security_group_names,
+ 'CacheSecurityGroupNames.member')
+ if security_group_ids is not None:
+ self.build_list_params(params,
+ security_group_ids,
+ 'SecurityGroupIds.member')
+ if preferred_availability_zone is not None:
+ params['PreferredAvailabilityZone'] = preferred_availability_zone
+ if preferred_maintenance_window is not None:
+ params['PreferredMaintenanceWindow'] = preferred_maintenance_window
+ if port is not None:
+ params['Port'] = port
+ if notification_topic_arn is not None:
+ params['NotificationTopicArn'] = notification_topic_arn
+ if auto_minor_version_upgrade is not None:
+ params['AutoMinorVersionUpgrade'] = str(
+ auto_minor_version_upgrade).lower()
+ return self._make_request(
+ action='CreateCacheCluster',
+ verb='POST',
+ path='/', params=params)
+
+ def create_cache_parameter_group(self, cache_parameter_group_name,
+ cache_parameter_group_family,
+ description):
+ """
+ Creates a new Cache Parameter Group. Cache Parameter groups
+ control the parameters for a Cache Cluster.
+
+ :type cache_parameter_group_name: string
+ :param cache_parameter_group_name: The name of the Cache Parameter
+ Group.
+
+ :type cache_parameter_group_family: string
+ :param cache_parameter_group_family: The name of the Cache Parameter
+ Group Family the Cache Parameter Group can be used with.
+ Currently, memcached1.4 is the only cache parameter group family
+ supported by the service.
+
+ :type description: string
+ :param description: The description for the Cache Parameter Group.
+
+ """
+ params = {
+ 'CacheParameterGroupName': cache_parameter_group_name,
+ 'CacheParameterGroupFamily': cache_parameter_group_family,
+ 'Description': description,
+ }
+ return self._make_request(
+ action='CreateCacheParameterGroup',
+ verb='POST',
+ path='/', params=params)
+
+ def create_cache_security_group(self, cache_security_group_name,
+ description):
+ """
+ Creates a new Cache Security Group. Cache Security groups
+ control access to one or more Cache Clusters.
+
+ Only use cache security groups when you are creating a cluster
+ outside of an Amazon Virtual Private Cloud (VPC). Inside of a
+ VPC, use VPC security groups.
+
+ :type cache_security_group_name: string
+ :param cache_security_group_name: The name for the Cache Security
+ Group. This value is stored as a lowercase string. Constraints:
+ Must contain no more than 255 alphanumeric characters. Must not be
+ "Default". Example: `mysecuritygroup`
+
+ :type description: string
+ :param description: The description for the Cache Security Group.
+
+ """
+ params = {
+ 'CacheSecurityGroupName': cache_security_group_name,
+ 'Description': description,
+ }
+ return self._make_request(
+ action='CreateCacheSecurityGroup',
+ verb='POST',
+ path='/', params=params)
+
+ def create_cache_subnet_group(self, cache_subnet_group_name,
+ cache_subnet_group_description, subnet_ids):
+ """
+ Creates a new Cache Subnet Group.
+
+ :type cache_subnet_group_name: string
+ :param cache_subnet_group_name: The name for the Cache Subnet Group.
+ This value is stored as a lowercase string. Constraints: Must
+ contain no more than 255 alphanumeric characters or hyphens.
+ Example: `mysubnetgroup`
+
+ :type cache_subnet_group_description: string
+ :param cache_subnet_group_description: The description for the Cache
+ Subnet Group.
+
+ :type subnet_ids: list
+ :param subnet_ids: The EC2 Subnet IDs for the Cache Subnet Group.
+
+ """
+ params = {
+ 'CacheSubnetGroupName': cache_subnet_group_name,
+ 'CacheSubnetGroupDescription': cache_subnet_group_description,
+ }
+ self.build_list_params(params,
+ subnet_ids,
+ 'SubnetIds.member')
+ return self._make_request(
+ action='CreateCacheSubnetGroup',
+ verb='POST',
+ path='/', params=params)
+
+ def delete_cache_cluster(self, cache_cluster_id):
+ """
+ Deletes a previously provisioned Cache Cluster. A successful
+ response from the web service indicates the request was
+ received correctly. This action cannot be canceled or
+ reverted. DeleteCacheCluster deletes all associated Cache
+ Nodes, node endpoints and the Cache Cluster itself.
+
+ :type cache_cluster_id: string
+ :param cache_cluster_id: The Cache Cluster identifier for the Cache
+ Cluster to be deleted. This parameter isn't case sensitive.
+
+ """
+ params = {'CacheClusterId': cache_cluster_id, }
+ return self._make_request(
+ action='DeleteCacheCluster',
+ verb='POST',
+ path='/', params=params)
+
+ def delete_cache_parameter_group(self, cache_parameter_group_name):
+ """
+ Deletes the specified CacheParameterGroup. The
+ CacheParameterGroup cannot be deleted if it is associated with
+ any cache clusters.
+
+ :type cache_parameter_group_name: string
+ :param cache_parameter_group_name: The name of the Cache Parameter
+ Group to delete. The specified cache security group must not be
+ associated with any Cache clusters.
+
+ """
+ params = {
+ 'CacheParameterGroupName': cache_parameter_group_name,
+ }
+ return self._make_request(
+ action='DeleteCacheParameterGroup',
+ verb='POST',
+ path='/', params=params)
+
+ def delete_cache_security_group(self, cache_security_group_name):
+ """
+ Deletes a Cache Security Group.
+ The specified Cache Security Group must not be associated with
+ any Cache Clusters.
+
+ :type cache_security_group_name: string
+ :param cache_security_group_name: The name of the Cache Security Group
+ to delete. You cannot delete the default security group.
+
+ """
+ params = {
+ 'CacheSecurityGroupName': cache_security_group_name,
+ }
+ return self._make_request(
+ action='DeleteCacheSecurityGroup',
+ verb='POST',
+ path='/', params=params)
+
+ def delete_cache_subnet_group(self, cache_subnet_group_name):
+ """
+ Deletes a Cache Subnet Group.
+ The specified Cache Subnet Group must not be associated with
+ any Cache Clusters.
+
+ :type cache_subnet_group_name: string
+ :param cache_subnet_group_name: The name of the Cache Subnet Group to
+ delete. Constraints: Must contain no more than 255 alphanumeric
+ characters or hyphens.
+
+ """
+ params = {'CacheSubnetGroupName': cache_subnet_group_name, }
+ return self._make_request(
+ action='DeleteCacheSubnetGroup',
+ verb='POST',
+ path='/', params=params)
+
+ def describe_cache_clusters(self, cache_cluster_id=None,
+ max_records=None, marker=None,
+ show_cache_node_info=None):
+ """
+ Returns information about all provisioned Cache Clusters if no
+ Cache Cluster identifier is specified, or about a specific
+ Cache Cluster if a Cache Cluster identifier is supplied.
+
+ Cluster information will be returned by default. An optional
+ ShowDetails flag can be used to retrieve detailed information
+ about the Cache Nodes associated with the Cache Cluster.
+ Details include the DNS address and port for the Cache Node
+ endpoint.
+
+ If the cluster is in the CREATING state, only cluster level
+ information will be displayed until all of the nodes are
+ successfully provisioned.
+
+ If the cluster is in the DELETING state, only cluster level
+ information will be displayed.
+
+ While adding Cache Nodes, node endpoint information and
+ creation time for the additional nodes will not be displayed
+ until they are completely provisioned. The cluster lifecycle
+ tells the customer when new nodes are AVAILABLE.
+
+ While removing existing Cache Nodes from an cluster, endpoint
+ information for the removed nodes will not be displayed.
+
+ DescribeCacheClusters supports pagination.
+
+ :type cache_cluster_id: string
+ :param cache_cluster_id: The user-supplied cluster identifier. If this
+ parameter is specified, only information about that specific Cache
+ Cluster is returned. This parameter isn't case sensitive.
+
+ :type max_records: integer
+ :param max_records: The maximum number of records to include in the
+ response. If more records exist than the specified MaxRecords
+ value, a marker is included in the response so that the remaining
+ results may be retrieved.
+
+ :type marker: string
+ :param marker: An optional marker provided in the previous
+ DescribeCacheClusters request. If this parameter is specified, the
+ response includes only records beyond the marker, up to the value
+ specified by MaxRecords .
+
+ :type show_cache_node_info: boolean
+ :param show_cache_node_info: An optional flag that can be included in
+ the DescribeCacheCluster request to retrieve Cache Nodes
+ information.
+
+ """
+ params = {}
+ if cache_cluster_id is not None:
+ params['CacheClusterId'] = cache_cluster_id
+ if max_records is not None:
+ params['MaxRecords'] = max_records
+ if marker is not None:
+ params['Marker'] = marker
+ if show_cache_node_info is not None:
+ params['ShowCacheNodeInfo'] = str(
+ show_cache_node_info).lower()
+ return self._make_request(
+ action='DescribeCacheClusters',
+ verb='POST',
+ path='/', params=params)
+
+ def describe_cache_engine_versions(self, engine=None,
+ engine_version=None,
+ cache_parameter_group_family=None,
+ max_records=None, marker=None,
+ default_only=None):
+ """
+ Returns a list of the available cache engines and their
+ versions.
+
+ :type engine: string
+ :param engine: The cache engine to return.
+
+ :type engine_version: string
+ :param engine_version: The cache engine version to return. Example:
+ `1.4.14`
+
+ :type cache_parameter_group_family: string
+ :param cache_parameter_group_family: The name of a specific Cache
+ Parameter Group family to return details for. Constraints: +
+ Must be 1 to 255 alphanumeric characters + First character must be
+ a letter + Cannot end with a hyphen or contain two consecutive
+ hyphens
+
+ :type max_records: integer
+ :param max_records: The maximum number of records to include in the
+ response. If more records exist than the specified MaxRecords
+ value, a marker is included in the response so that the remaining
+ results may be retrieved.
+
+ :type marker: string
+ :param marker: An optional marker provided in the previous
+ DescribeCacheParameterGroups request. If this parameter is
+ specified, the response includes only records beyond the marker, up
+ to the value specified by MaxRecords .
+
+ :type default_only: boolean
+ :param default_only: Indicates that only the default version of the
+ specified engine or engine and major version combination is
+ returned.
+
+ """
+ params = {}
+ if engine is not None:
+ params['Engine'] = engine
+ if engine_version is not None:
+ params['EngineVersion'] = engine_version
+ if cache_parameter_group_family is not None:
+ params['CacheParameterGroupFamily'] = cache_parameter_group_family
+ if max_records is not None:
+ params['MaxRecords'] = max_records
+ if marker is not None:
+ params['Marker'] = marker
+ if default_only is not None:
+ params['DefaultOnly'] = str(
+ default_only).lower()
+ return self._make_request(
+ action='DescribeCacheEngineVersions',
+ verb='POST',
+ path='/', params=params)
+
+ def describe_cache_parameter_groups(self,
+ cache_parameter_group_name=None,
+ max_records=None, marker=None):
+ """
+ Returns a list of CacheParameterGroup descriptions. If a
+ CacheParameterGroupName is specified, the list will contain
+ only the descriptions of the specified CacheParameterGroup.
+
+ :type cache_parameter_group_name: string
+ :param cache_parameter_group_name: The name of a specific cache
+ parameter group to return details for.
+
+ :type max_records: integer
+ :param max_records: The maximum number of records to include in the
+ response. If more records exist than the specified MaxRecords
+ value, a marker is included in the response so that the remaining
+ results may be retrieved.
+
+ :type marker: string
+ :param marker: An optional marker provided in the previous
+ DescribeCacheParameterGroups request. If this parameter is
+ specified, the response includes only records beyond the marker, up
+ to the value specified by MaxRecords .
+
+ """
+ params = {}
+ if cache_parameter_group_name is not None:
+ params['CacheParameterGroupName'] = cache_parameter_group_name
+ if max_records is not None:
+ params['MaxRecords'] = max_records
+ if marker is not None:
+ params['Marker'] = marker
+ return self._make_request(
+ action='DescribeCacheParameterGroups',
+ verb='POST',
+ path='/', params=params)
+
+ def describe_cache_parameters(self, cache_parameter_group_name,
+ source=None, max_records=None, marker=None):
+ """
+ Returns the detailed parameter list for a particular
+ CacheParameterGroup.
+
+ :type cache_parameter_group_name: string
+ :param cache_parameter_group_name: The name of a specific cache
+ parameter group to return details for.
+
+ :type source: string
+ :param source: The parameter types to return. Valid values: `user` |
+ `system` | `engine-default`
+
+ :type max_records: integer
+ :param max_records: The maximum number of records to include in the
+ response. If more records exist than the specified MaxRecords
+ value, a marker is included in the response so that the remaining
+ results may be retrieved.
+
+ :type marker: string
+ :param marker: An optional marker provided in the previous
+ DescribeCacheClusters request. If this parameter is specified, the
+ response includes only records beyond the marker, up to the value
+ specified by MaxRecords .
+
+ """
+ params = {
+ 'CacheParameterGroupName': cache_parameter_group_name,
+ }
+ if source is not None:
+ params['Source'] = source
+ if max_records is not None:
+ params['MaxRecords'] = max_records
+ if marker is not None:
+ params['Marker'] = marker
+ return self._make_request(
+ action='DescribeCacheParameters',
+ verb='POST',
+ path='/', params=params)
+
+ def describe_cache_security_groups(self, cache_security_group_name=None,
+ max_records=None, marker=None):
+ """
+ Returns a list of CacheSecurityGroup descriptions. If a
+ CacheSecurityGroupName is specified, the list will contain
+ only the description of the specified CacheSecurityGroup.
+
+ :type cache_security_group_name: string
+ :param cache_security_group_name: The name of the Cache Security Group
+ to return details for.
+
+ :type max_records: integer
+ :param max_records: The maximum number of records to include in the
+ response. If more records exist than the specified MaxRecords
+ value, a marker is included in the response so that the remaining
+ results may be retrieved.
+
+ :type marker: string
+ :param marker: An optional marker provided in the previous
+ DescribeCacheClusters request. If this parameter is specified, the
+ response includes only records beyond the marker, up to the value
+ specified by MaxRecords .
+
+ """
+ params = {}
+ if cache_security_group_name is not None:
+ params['CacheSecurityGroupName'] = cache_security_group_name
+ if max_records is not None:
+ params['MaxRecords'] = max_records
+ if marker is not None:
+ params['Marker'] = marker
+ return self._make_request(
+ action='DescribeCacheSecurityGroups',
+ verb='POST',
+ path='/', params=params)
+
+ def describe_cache_subnet_groups(self, cache_subnet_group_name=None,
+ max_records=None, marker=None):
+ """
+ Returns a list of CacheSubnetGroup descriptions. If a
+ CacheSubnetGroupName is specified, the list will contain only
+ the description of the specified Cache Subnet Group.
+
+ :type cache_subnet_group_name: string
+ :param cache_subnet_group_name: The name of the Cache Subnet Group to
+ return details for.
+
+ :type max_records: integer
+ :param max_records: The maximum number of records to include in the
+ response. If more records exist than the specified `MaxRecords`
+ value, a marker is included in the response so that the remaining
+ results may be retrieved. Default: 100 Constraints: minimum 20,
+ maximum 100
+
+ :type marker: string
+ :param marker: An optional marker provided in the previous
+ DescribeCacheSubnetGroups request. If this parameter is specified,
+ the response includes only records beyond the marker, up to the
+ value specified by `MaxRecords`.
+
+ """
+ params = {}
+ if cache_subnet_group_name is not None:
+ params['CacheSubnetGroupName'] = cache_subnet_group_name
+ if max_records is not None:
+ params['MaxRecords'] = max_records
+ if marker is not None:
+ params['Marker'] = marker
+ return self._make_request(
+ action='DescribeCacheSubnetGroups',
+ verb='POST',
+ path='/', params=params)
+
+ def describe_engine_default_parameters(self,
+ cache_parameter_group_family,
+ max_records=None, marker=None):
+ """
+ Returns the default engine and system parameter information
+ for the specified cache engine.
+
+ :type cache_parameter_group_family: string
+ :param cache_parameter_group_family: The name of the Cache Parameter
+ Group Family. Currently, memcached1.4 is the only cache parameter
+ group family supported by the service.
+
+ :type max_records: integer
+ :param max_records: The maximum number of records to include in the
+ response. If more records exist than the specified MaxRecords
+ value, a marker is included in the response so that the remaining
+ results may be retrieved.
+
+ :type marker: string
+ :param marker: An optional marker provided in the previous
+ DescribeCacheClusters request. If this parameter is specified, the
+ response includes only records beyond the marker, up to the value
+ specified by MaxRecords .
+
+ """
+ params = {
+ 'CacheParameterGroupFamily': cache_parameter_group_family,
+ }
+ if max_records is not None:
+ params['MaxRecords'] = max_records
+ if marker is not None:
+ params['Marker'] = marker
+ return self._make_request(
+ action='DescribeEngineDefaultParameters',
+ verb='POST',
+ path='/', params=params)
+
+ def describe_events(self, source_identifier=None, source_type=None,
+ start_time=None, end_time=None, duration=None,
+ max_records=None, marker=None):
+ """
+ Returns events related to Cache Clusters, Cache Security
+ Groups, and Cache Parameter Groups for the past 14 days.
+ Events specific to a particular Cache Cluster, Cache Security
+ Group, or Cache Parameter Group can be obtained by providing
+ the name as a parameter. By default, the past hour of events
+ are returned.
+
+ :type source_identifier: string
+ :param source_identifier: The identifier of the event source for which
+ events will be returned. If not specified, then all sources are
+ included in the response.
+
+ :type source_type: string
+ :param source_type: The event source to retrieve events for. If no
+ value is specified, all events are returned.
+
+ :type start_time: string
+ :param start_time: The beginning of the time interval to retrieve
+ events for, specified in ISO 8601 format.
+
+ :type end_time: string
+ :param end_time: The end of the time interval for which to retrieve
+ events, specified in ISO 8601 format.
+
+ :type duration: integer
+ :param duration: The number of minutes to retrieve events for.
+
+ :type max_records: integer
+ :param max_records: The maximum number of records to include in the
+ response. If more records exist than the specified MaxRecords
+ value, a marker is included in the response so that the remaining
+ results may be retrieved.
+
+ :type marker: string
+ :param marker: An optional marker provided in the previous
+ DescribeCacheClusters request. If this parameter is specified, the
+ response includes only records beyond the marker, up to the value
+ specified by MaxRecords .
+
+ """
+ params = {}
+ if source_identifier is not None:
+ params['SourceIdentifier'] = source_identifier
+ if source_type is not None:
+ params['SourceType'] = source_type
+ if start_time is not None:
+ params['StartTime'] = start_time
+ if end_time is not None:
+ params['EndTime'] = end_time
+ if duration is not None:
+ params['Duration'] = duration
+ if max_records is not None:
+ params['MaxRecords'] = max_records
+ if marker is not None:
+ params['Marker'] = marker
+ return self._make_request(
+ action='DescribeEvents',
+ verb='POST',
+ path='/', params=params)
+
+ def describe_reserved_cache_nodes(self, reserved_cache_node_id=None,
+ reserved_cache_nodes_offering_id=None,
+ cache_node_type=None, duration=None,
+ product_description=None,
+ offering_type=None, max_records=None,
+ marker=None):
+ """
+ Returns information about reserved Cache Nodes for this
+ account, or about a specified reserved Cache Node.
+
+ :type reserved_cache_node_id: string
+ :param reserved_cache_node_id: The reserved Cache Node identifier
+ filter value. Specify this parameter to show only the reservation
+ that matches the specified reservation ID.
+
+ :type reserved_cache_nodes_offering_id: string
+ :param reserved_cache_nodes_offering_id: The offering identifier filter
+ value. Specify this parameter to show only purchased reservations
+ matching the specified offering identifier.
+
+ :type cache_node_type: string
+ :param cache_node_type: The Cache Node type filter value. Specify this
+ parameter to show only those reservations matching the specified
+ Cache Nodes type.
+
+ :type duration: string
+ :param duration: The duration filter value, specified in years or
+ seconds. Specify this parameter to show only reservations for this
+ duration. Valid Values: `1 | 3 | 31536000 | 94608000`
+
+ :type product_description: string
+ :param product_description: The product description filter value.
+ Specify this parameter to show only those reservations matching the
+ specified product description.
+
+ :type offering_type: string
+ :param offering_type: The offering type filter value. Specify this
+ parameter to show only the available offerings matching the
+ specified offering type. Valid Values: `"Light Utilization" |
+ "Medium Utilization" | "Heavy Utilization" `
+
+ :type max_records: integer
+ :param max_records: The maximum number of records to include in the
+ response. If more than the `MaxRecords` value is available, a
+ marker is included in the response so that the following results
+ can be retrieved. Default: 100 Constraints: minimum 20, maximum
+ 100
+
+ :type marker: string
+ :param marker: The marker provided in the previous request. If this
+ parameter is specified, the response includes records beyond the
+ marker only, up to `MaxRecords`.
+
+ """
+ params = {}
+ if reserved_cache_node_id is not None:
+ params['ReservedCacheNodeId'] = reserved_cache_node_id
+ if reserved_cache_nodes_offering_id is not None:
+ params['ReservedCacheNodesOfferingId'] = reserved_cache_nodes_offering_id
+ if cache_node_type is not None:
+ params['CacheNodeType'] = cache_node_type
+ if duration is not None:
+ params['Duration'] = duration
+ if product_description is not None:
+ params['ProductDescription'] = product_description
+ if offering_type is not None:
+ params['OfferingType'] = offering_type
+ if max_records is not None:
+ params['MaxRecords'] = max_records
+ if marker is not None:
+ params['Marker'] = marker
+ return self._make_request(
+ action='DescribeReservedCacheNodes',
+ verb='POST',
+ path='/', params=params)
+
+ def describe_reserved_cache_nodes_offerings(self,
+ reserved_cache_nodes_offering_id=None,
+ cache_node_type=None,
+ duration=None,
+ product_description=None,
+ offering_type=None,
+ max_records=None,
+ marker=None):
+ """
+ Lists available reserved Cache Node offerings.
+
+ :type reserved_cache_nodes_offering_id: string
+ :param reserved_cache_nodes_offering_id: The offering identifier filter
+ value. Specify this parameter to show only the available offering
+ that matches the specified reservation identifier. Example:
+ `438012d3-4052-4cc7-b2e3-8d3372e0e706`
+
+ :type cache_node_type: string
+ :param cache_node_type: The Cache Node type filter value. Specify this
+ parameter to show only the available offerings matching the
+ specified Cache Node type.
+
+ :type duration: string
+ :param duration: Duration filter value, specified in years or seconds.
+ Specify this parameter to show only reservations for this duration.
+ Valid Values: `1 | 3 | 31536000 | 94608000`
+
+ :type product_description: string
+ :param product_description: Product description filter value. Specify
+ this parameter to show only the available offerings matching the
+ specified product description.
+
+ :type offering_type: string
+ :param offering_type: The offering type filter value. Specify this
+ parameter to show only the available offerings matching the
+ specified offering type. Valid Values: `"Light Utilization" |
+ "Medium Utilization" | "Heavy Utilization" `
+
+ :type max_records: integer
+ :param max_records: The maximum number of records to include in the
+ response. If more than the `MaxRecords` value is available, a
+ marker is included in the response so that the following results
+ can be retrieved. Default: 100 Constraints: minimum 20, maximum
+ 100
+
+ :type marker: string
+ :param marker: The marker provided in the previous request. If this
+ parameter is specified, the response includes records beyond the
+ marker only, up to `MaxRecords`.
+
+ """
+ params = {}
+ if reserved_cache_nodes_offering_id is not None:
+ params['ReservedCacheNodesOfferingId'] = reserved_cache_nodes_offering_id
+ if cache_node_type is not None:
+ params['CacheNodeType'] = cache_node_type
+ if duration is not None:
+ params['Duration'] = duration
+ if product_description is not None:
+ params['ProductDescription'] = product_description
+ if offering_type is not None:
+ params['OfferingType'] = offering_type
+ if max_records is not None:
+ params['MaxRecords'] = max_records
+ if marker is not None:
+ params['Marker'] = marker
+ return self._make_request(
+ action='DescribeReservedCacheNodesOfferings',
+ verb='POST',
+ path='/', params=params)
+
+ def modify_cache_cluster(self, cache_cluster_id, num_cache_nodes=None,
+ cache_node_ids_to_remove=None,
+ cache_security_group_names=None,
+ security_group_ids=None,
+ preferred_maintenance_window=None,
+ notification_topic_arn=None,
+ cache_parameter_group_name=None,
+ notification_topic_status=None,
+ apply_immediately=None, engine_version=None,
+ auto_minor_version_upgrade=None):
+ """
+ Modifies the Cache Cluster settings. You can change one or
+ more Cache Cluster configuration parameters by specifying the
+ parameters and the new values in the request.
+
+ :type cache_cluster_id: string
+ :param cache_cluster_id: The Cache Cluster identifier. This value is
+ stored as a lowercase string.
+
+ :type num_cache_nodes: integer
+ :param num_cache_nodes: The number of Cache Nodes the Cache Cluster
+ should have. If NumCacheNodes is greater than the existing number
+ of Cache Nodes, Cache Nodes will be added. If NumCacheNodes is less
+ than the existing number of Cache Nodes, Cache Nodes will be
+ removed. When removing Cache Nodes, the Ids of the specific Cache
+ Nodes to be removed must be supplied using the CacheNodeIdsToRemove
+ parameter.
+
+ :type cache_node_ids_to_remove: list
+ :param cache_node_ids_to_remove: The list of Cache Node IDs to be
+ removed. This parameter is only valid when NumCacheNodes is less
+ than the existing number of Cache Nodes. The number of Cache Node
+ Ids supplied in this parameter must match the difference between
+ the existing number of Cache Nodes in the cluster and the new
+ NumCacheNodes requested.
+
+ :type cache_security_group_names: list
+ :param cache_security_group_names: A list of Cache Security Group Names
+ to authorize on this Cache Cluster. This change is asynchronously
+ applied as soon as possible. This parameter can be used only with
+ clusters that are created outside of an Amazon Virtual Private
+ Cloud (VPC). Constraints: Must contain no more than 255
+ alphanumeric characters. Must not be "Default".
+
+ :type security_group_ids: list
+ :param security_group_ids: Specifies the VPC Security Groups associated
+ with the Cache Cluster. This parameter can be used only with
+ clusters that are created in an Amazon Virtual Private Cloud (VPC).
+
+ :type preferred_maintenance_window: string
+ :param preferred_maintenance_window: The weekly time range (in UTC)
+ during which system maintenance can occur, which may result in an
+ outage. This change is made immediately. If moving this window to
+ the current time, there must be at least 120 minutes between the
+ current time and end of the window to ensure pending changes are
+ applied.
+
+ :type notification_topic_arn: string
+ :param notification_topic_arn: The Amazon Resource Name (ARN) of the
+ SNS topic to which notifications will be sent. The SNS topic owner
+ must be same as the Cache Cluster owner.
+
+ :type cache_parameter_group_name: string
+ :param cache_parameter_group_name: The name of the Cache Parameter
+ Group to apply to this Cache Cluster. This change is asynchronously
+ applied as soon as possible for parameters when the
+ ApplyImmediately parameter is specified as true for this request.
+
+ :type notification_topic_status: string
+ :param notification_topic_status: The status of the Amazon SNS
+ notification topic. The value can be active or inactive .
+ Notifications are sent only if the status is active .
+
+ :type apply_immediately: boolean
+ :param apply_immediately: Specifies whether or not the modifications in
+ this request and any pending modifications are asynchronously
+ applied as soon as possible, regardless of the
+ PreferredMaintenanceWindow setting for the Cache Cluster. If this
+ parameter is passed as `False`, changes to the Cache Cluster are
+ applied on the next maintenance reboot, or the next failure reboot,
+ whichever occurs first. Default: `False`
+
+ :type engine_version: string
+ :param engine_version: The version of the cache engine to upgrade this
+ cluster to.
+
+ :type auto_minor_version_upgrade: boolean
+ :param auto_minor_version_upgrade: Indicates that minor engine upgrades
+ will be applied automatically to the Cache Cluster during the
+ maintenance window. Default: `True`
+
+ """
+ params = {'CacheClusterId': cache_cluster_id, }
+ if num_cache_nodes is not None:
+ params['NumCacheNodes'] = num_cache_nodes
+ if cache_node_ids_to_remove is not None:
+ self.build_list_params(params,
+ cache_node_ids_to_remove,
+ 'CacheNodeIdsToRemove.member')
+ if cache_security_group_names is not None:
+ self.build_list_params(params,
+ cache_security_group_names,
+ 'CacheSecurityGroupNames.member')
+ if security_group_ids is not None:
+ self.build_list_params(params,
+ security_group_ids,
+ 'SecurityGroupIds.member')
+ if preferred_maintenance_window is not None:
+ params['PreferredMaintenanceWindow'] = preferred_maintenance_window
+ if notification_topic_arn is not None:
+ params['NotificationTopicArn'] = notification_topic_arn
+ if cache_parameter_group_name is not None:
+ params['CacheParameterGroupName'] = cache_parameter_group_name
+ if notification_topic_status is not None:
+ params['NotificationTopicStatus'] = notification_topic_status
+ if apply_immediately is not None:
+ params['ApplyImmediately'] = str(
+ apply_immediately).lower()
+ if engine_version is not None:
+ params['EngineVersion'] = engine_version
+ if auto_minor_version_upgrade is not None:
+ params['AutoMinorVersionUpgrade'] = str(
+ auto_minor_version_upgrade).lower()
+ return self._make_request(
+ action='ModifyCacheCluster',
+ verb='POST',
+ path='/', params=params)
+
+ def modify_cache_parameter_group(self, cache_parameter_group_name,
+ parameter_name_values):
+ """
+ Modifies the parameters of a CacheParameterGroup. To modify
+ more than one parameter, submit a list of ParameterName and
+ ParameterValue parameters. A maximum of 20 parameters can be
+ modified in a single request.
+
+ :type cache_parameter_group_name: string
+ :param cache_parameter_group_name: The name of the cache parameter
+ group to modify.
+
+ :type parameter_name_values: list
+ :param parameter_name_values: An array of parameter names and values
+ for the parameter update. At least one parameter name and value
+ must be supplied; subsequent arguments are optional. A maximum of
+ 20 parameters may be modified in a single request.
+
+ """
+ params = {
+ 'CacheParameterGroupName': cache_parameter_group_name,
+ }
+ self.build_complex_list_params(
+ params, parameter_name_values,
+ 'ParameterNameValues.member',
+ ('ParameterName', 'ParameterValue'))
+ return self._make_request(
+ action='ModifyCacheParameterGroup',
+ verb='POST',
+ path='/', params=params)
+
+ def modify_cache_subnet_group(self, cache_subnet_group_name,
+ cache_subnet_group_description=None,
+ subnet_ids=None):
+ """
+ Modifies an existing Cache Subnet Group.
+
+ :type cache_subnet_group_name: string
+ :param cache_subnet_group_name: The name for the Cache Subnet Group.
+ This value is stored as a lowercase string. Constraints: Must
+ contain no more than 255 alphanumeric characters or hyphens.
+ Example: `mysubnetgroup`
+
+ :type cache_subnet_group_description: string
+ :param cache_subnet_group_description: The description for the Cache
+ Subnet Group.
+
+ :type subnet_ids: list
+ :param subnet_ids: The EC2 Subnet IDs for the Cache Subnet Group.
+
+ """
+ params = {'CacheSubnetGroupName': cache_subnet_group_name, }
+ if cache_subnet_group_description is not None:
+ params['CacheSubnetGroupDescription'] = cache_subnet_group_description
+ if subnet_ids is not None:
+ self.build_list_params(params,
+ subnet_ids,
+ 'SubnetIds.member')
+ return self._make_request(
+ action='ModifyCacheSubnetGroup',
+ verb='POST',
+ path='/', params=params)
+
+ def purchase_reserved_cache_nodes_offering(self,
+ reserved_cache_nodes_offering_id,
+ reserved_cache_node_id=None,
+ cache_node_count=None):
+ """
+ Purchases a reserved Cache Node offering.
+
+ :type reserved_cache_nodes_offering_id: string
+ :param reserved_cache_nodes_offering_id: The ID of the Reserved Cache
+ Node offering to purchase. Example:
+ 438012d3-4052-4cc7-b2e3-8d3372e0e706
+
+ :type reserved_cache_node_id: string
+ :param reserved_cache_node_id: Customer-specified identifier to track
+ this reservation. Example: myreservationID
+
+ :type cache_node_count: integer
+ :param cache_node_count: The number of instances to reserve. Default:
+ `1`
+
+ """
+ params = {
+ 'ReservedCacheNodesOfferingId': reserved_cache_nodes_offering_id,
+ }
+ if reserved_cache_node_id is not None:
+ params['ReservedCacheNodeId'] = reserved_cache_node_id
+ if cache_node_count is not None:
+ params['CacheNodeCount'] = cache_node_count
+ return self._make_request(
+ action='PurchaseReservedCacheNodesOffering',
+ verb='POST',
+ path='/', params=params)
+
+ def reboot_cache_cluster(self, cache_cluster_id,
+ cache_node_ids_to_reboot):
+ """
+ Reboots some (or all) of the cache cluster nodes within a
+ previously provisioned ElastiCache cluster. This API results
+ in the application of modified CacheParameterGroup parameters
+ to the cache cluster. This action is taken as soon as
+ possible, and results in a momentary outage to the cache
+ cluster during which the cache cluster status is set to
+ rebooting. During that momentary outage, the contents of the
+ cache (for each cache cluster node being rebooted) are lost. A
+ CacheCluster event is created when the reboot is completed.
+
+ :type cache_cluster_id: string
+ :param cache_cluster_id: The Cache Cluster identifier. This parameter
+ is stored as a lowercase string.
+
+ :type cache_node_ids_to_reboot: list
+ :param cache_node_ids_to_reboot: A list of Cache Cluster Node Ids to
+ reboot. To reboot an entire cache cluster, specify all cache
+ cluster node Ids.
+
+ """
+ params = {'CacheClusterId': cache_cluster_id, }
+ self.build_list_params(params,
+ cache_node_ids_to_reboot,
+ 'CacheNodeIdsToReboot.member')
+ return self._make_request(
+ action='RebootCacheCluster',
+ verb='POST',
+ path='/', params=params)
+
+ def reset_cache_parameter_group(self, cache_parameter_group_name,
+ parameter_name_values,
+ reset_all_parameters=None):
+ """
+ Modifies the parameters of a CacheParameterGroup to the engine
+ or system default value. To reset specific parameters submit a
+ list of the parameter names. To reset the entire
+ CacheParameterGroup, specify the CacheParameterGroup name and
+ ResetAllParameters parameters.
+
+ :type cache_parameter_group_name: string
+ :param cache_parameter_group_name: The name of the Cache Parameter
+ Group.
+
+ :type reset_all_parameters: boolean
+ :param reset_all_parameters: Specifies whether ( true ) or not ( false
+ ) to reset all parameters in the Cache Parameter Group to default
+ values.
+
+ :type parameter_name_values: list
+ :param parameter_name_values: An array of parameter names which should
+ be reset. If not resetting the entire CacheParameterGroup, at least
+ one parameter name must be supplied.
+
+ """
+ params = {
+ 'CacheParameterGroupName': cache_parameter_group_name,
+ }
+ self.build_complex_list_params(
+ params, parameter_name_values,
+ 'ParameterNameValues.member',
+ ('ParameterName', 'ParameterValue'))
+ if reset_all_parameters is not None:
+ params['ResetAllParameters'] = str(
+ reset_all_parameters).lower()
+ return self._make_request(
+ action='ResetCacheParameterGroup',
+ verb='POST',
+ path='/', params=params)
+
+ def revoke_cache_security_group_ingress(self, cache_security_group_name,
+ ec2_security_group_name,
+ ec2_security_group_owner_id):
+ """
+ Revokes ingress from a CacheSecurityGroup for previously
+ authorized EC2 Security Groups.
+
+ :type cache_security_group_name: string
+ :param cache_security_group_name: The name of the Cache Security Group
+ to revoke ingress from.
+
+ :type ec2_security_group_name: string
+ :param ec2_security_group_name: The name of the EC2 Security Group to
+ revoke access from.
+
+ :type ec2_security_group_owner_id: string
+ :param ec2_security_group_owner_id: The AWS Account Number of the owner
+ of the security group specified in the EC2SecurityGroupName
+ parameter. The AWS Access Key ID is not an acceptable value.
+
+ """
+ params = {
+ 'CacheSecurityGroupName': cache_security_group_name,
+ 'EC2SecurityGroupName': ec2_security_group_name,
+ 'EC2SecurityGroupOwnerId': ec2_security_group_owner_id,
+ }
+ return self._make_request(
+ action='RevokeCacheSecurityGroupIngress',
+ verb='POST',
+ path='/', params=params)
+