OLD | NEW |
(Empty) | |
| 1 # Copyright (c) 2012 Mitch Garnaat http://garnaat.org/ |
| 2 # Copyright (c) 2012 Amazon.com, Inc. or its affiliates. |
| 3 # All Rights Reserved |
| 4 # |
| 5 # Permission is hereby granted, free of charge, to any person obtaining a |
| 6 # copy of this software and associated documentation files (the |
| 7 # "Software"), to deal in the Software without restriction, including |
| 8 # without limitation the rights to use, copy, modify, merge, publish, dis- |
| 9 # tribute, sublicense, and/or sell copies of the Software, and to permit |
| 10 # persons to whom the Software is furnished to do so, subject to the fol- |
| 11 # lowing conditions: |
| 12 # |
| 13 # The above copyright notice and this permission notice shall be included |
| 14 # in all copies or substantial portions of the Software. |
| 15 # |
| 16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 17 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- |
| 18 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT |
| 19 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
| 20 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 22 # IN THE SOFTWARE. |
| 23 # |
| 24 |
| 25 from .layer1 import Layer1 |
| 26 from .domain import Domain |
| 27 |
| 28 |
| 29 class Layer2(object): |
| 30 |
| 31 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None, |
| 32 is_secure=True, port=None, proxy=None, proxy_port=None, |
| 33 host=None, debug=0, session_token=None, region=None, |
| 34 validate_certs=True): |
| 35 self.layer1 = Layer1(aws_access_key_id, aws_secret_access_key, |
| 36 is_secure, port, proxy, proxy_port, |
| 37 host, debug, session_token, region, |
| 38 validate_certs=validate_certs) |
| 39 |
| 40 def list_domains(self, domain_names=None): |
| 41 """ |
| 42 Return a list of :class:`boto.cloudsearch.domain.Domain` |
| 43 objects for each domain defined in the current account. |
| 44 """ |
| 45 domain_data = self.layer1.describe_domains(domain_names) |
| 46 return [Domain(self.layer1, data) for data in domain_data] |
| 47 |
| 48 def create_domain(self, domain_name): |
| 49 """ |
| 50 Create a new CloudSearch domain and return the corresponding |
| 51 :class:`boto.cloudsearch.domain.Domain` object. |
| 52 """ |
| 53 data = self.layer1.create_domain(domain_name) |
| 54 return Domain(self.layer1, data) |
| 55 |
| 56 def lookup(self, domain_name): |
| 57 """ |
| 58 Lookup a single domain |
| 59 :param domain_name: The name of the domain to look up |
| 60 :type domain_name: str |
| 61 |
| 62 :return: Domain object, or None if the domain isn't found |
| 63 :rtype: :class:`boto.cloudsearch.domain.Domain` |
| 64 """ |
| 65 domains = self.list_domains(domain_names=[domain_name]) |
| 66 if len(domains) > 0: |
| 67 return domains[0] |
OLD | NEW |