Mercurial > repos > guerler > springsuite
comparison planemo/lib/python3.7/site-packages/boto/cloudsearch2/layer2.py @ 0:d30785e31577 draft
"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
| author | guerler |
|---|---|
| date | Fri, 31 Jul 2020 00:18:57 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:d30785e31577 |
|---|---|
| 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 boto.cloudsearch2.layer1 import CloudSearchConnection | |
| 26 from boto.cloudsearch2.domain import Domain | |
| 27 from boto.compat import six | |
| 28 | |
| 29 | |
| 30 class Layer2(object): | |
| 31 | |
| 32 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None, | |
| 33 is_secure=True, port=None, proxy=None, proxy_port=None, | |
| 34 host=None, debug=0, session_token=None, region=None, | |
| 35 validate_certs=True, sign_request=False): | |
| 36 | |
| 37 if isinstance(region, six.string_types): | |
| 38 import boto.cloudsearch2 | |
| 39 for region_info in boto.cloudsearch2.regions(): | |
| 40 if region_info.name == region: | |
| 41 region = region_info | |
| 42 break | |
| 43 | |
| 44 self.layer1 = CloudSearchConnection( | |
| 45 aws_access_key_id=aws_access_key_id, | |
| 46 aws_secret_access_key=aws_secret_access_key, | |
| 47 is_secure=is_secure, | |
| 48 port=port, | |
| 49 proxy=proxy, | |
| 50 proxy_port=proxy_port, | |
| 51 host=host, | |
| 52 debug=debug, | |
| 53 security_token=session_token, | |
| 54 region=region, | |
| 55 validate_certs=validate_certs, | |
| 56 sign_request=sign_request) | |
| 57 | |
| 58 def list_domains(self, domain_names=None): | |
| 59 """ | |
| 60 Return a list of objects for each domain defined in the | |
| 61 current account. | |
| 62 :rtype: list of :class:`boto.cloudsearch2.domain.Domain` | |
| 63 """ | |
| 64 domain_data = self.layer1.describe_domains(domain_names) | |
| 65 | |
| 66 domain_data = (domain_data['DescribeDomainsResponse'] | |
| 67 ['DescribeDomainsResult'] | |
| 68 ['DomainStatusList']) | |
| 69 | |
| 70 return [Domain(self.layer1, data) for data in domain_data] | |
| 71 | |
| 72 def create_domain(self, domain_name): | |
| 73 """ | |
| 74 Create a new CloudSearch domain and return the corresponding object. | |
| 75 :return: Domain object, or None if the domain isn't found | |
| 76 :rtype: :class:`boto.cloudsearch2.domain.Domain` | |
| 77 """ | |
| 78 data = self.layer1.create_domain(domain_name) | |
| 79 return Domain(self.layer1, data['CreateDomainResponse'] | |
| 80 ['CreateDomainResult'] | |
| 81 ['DomainStatus']) | |
| 82 | |
| 83 def lookup(self, domain_name): | |
| 84 """ | |
| 85 Lookup a single domain | |
| 86 :param domain_name: The name of the domain to look up | |
| 87 :type domain_name: str | |
| 88 | |
| 89 :return: Domain object, or None if the domain isn't found | |
| 90 :rtype: :class:`boto.cloudsearch2.domain.Domain` | |
| 91 """ | |
| 92 domains = self.list_domains(domain_names=[domain_name]) | |
| 93 if len(domains) > 0: | |
| 94 return domains[0] |
