OLD | NEW |
1 # Copyright (c) 2010 Mitch Garnaat http://garnaat.org/ | 1 # Copyright (c) 2010 Mitch Garnaat http://garnaat.org/ |
2 # Copyright (c) 2011 Harry Marr http://hmarr.com/ | 2 # Copyright (c) 2011 Harry Marr http://hmarr.com/ |
3 # | 3 # |
4 # Permission is hereby granted, free of charge, to any person obtaining a | 4 # Permission is hereby granted, free of charge, to any person obtaining a |
5 # copy of this software and associated documentation files (the | 5 # copy of this software and associated documentation files (the |
6 # "Software"), to deal in the Software without restriction, including | 6 # "Software"), to deal in the Software without restriction, including |
7 # without limitation the rights to use, copy, modify, merge, publish, dis- | 7 # without limitation the rights to use, copy, modify, merge, publish, dis- |
8 # tribute, sublicense, and/or sell copies of the Software, and to permit | 8 # tribute, sublicense, and/or sell copies of the Software, and to permit |
9 # persons to whom the Software is furnished to do so, subject to the fol- | 9 # persons to whom the Software is furnished to do so, subject to the fol- |
10 # lowing conditions: | 10 # lowing conditions: |
11 # | 11 # |
12 # The above copyright notice and this permission notice shall be included | 12 # The above copyright notice and this permission notice shall be included |
13 # in all copies or substantial portions of the Software. | 13 # in all copies or substantial portions of the Software. |
14 # | 14 # |
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | 15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
16 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- | 16 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- |
17 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT | 17 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT |
18 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | 18 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
19 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 19 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | 20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
21 # IN THE SOFTWARE. | 21 # IN THE SOFTWARE. |
22 | 22 |
23 from connection import SESConnection | 23 from connection import SESConnection |
| 24 from boto.regioninfo import RegionInfo |
24 | 25 |
| 26 def regions(): |
| 27 """ |
| 28 Get all available regions for the SES service. |
| 29 |
| 30 :rtype: list |
| 31 :return: A list of :class:`boto.regioninfo.RegionInfo` instances |
| 32 """ |
| 33 return [RegionInfo(name='us-east-1', |
| 34 endpoint='email.us-east-1.amazonaws.com', |
| 35 connection_cls=SESConnection)] |
| 36 |
| 37 def connect_to_region(region_name, **kw_params): |
| 38 """ |
| 39 Given a valid region name, return a |
| 40 :class:`boto.sns.connection.SESConnection`. |
| 41 |
| 42 :type: str |
| 43 :param region_name: The name of the region to connect to. |
| 44 |
| 45 :rtype: :class:`boto.sns.connection.SESConnection` or ``None`` |
| 46 :return: A connection to the given region, or None if an invalid region |
| 47 name is given |
| 48 """ |
| 49 for region in regions(): |
| 50 if region.name == region_name: |
| 51 return region.connect(**kw_params) |
| 52 return None |
| 53 |
| 54 def get_region(region_name, **kw_params): |
| 55 """ |
| 56 Find and return a :class:`boto.regioninfo.RegionInfo` object |
| 57 given a region name. |
| 58 |
| 59 :type: str |
| 60 :param: The name of the region. |
| 61 |
| 62 :rtype: :class:`boto.regioninfo.RegionInfo` |
| 63 :return: The RegionInfo object for the given region or None if |
| 64 an invalid region name is provided. |
| 65 """ |
| 66 for region in regions(**kw_params): |
| 67 if region.name == region_name: |
| 68 return region |
| 69 return None |
OLD | NEW |