Index: boto/sts/__init__.py |
diff --git a/boto/ec2/__init__.py b/boto/sts/__init__.py |
similarity index 53% |
copy from boto/ec2/__init__.py |
copy to boto/sts/__init__.py |
index 8bb3f537909e443c0360023344d4808b106491c3..7ee10b42836777614a9b40d069433a26a6e760b1 100644 |
--- a/boto/ec2/__init__.py |
+++ b/boto/sts/__init__.py |
@@ -1,4 +1,5 @@ |
-# Copyright (c) 2006-2008 Mitch Garnaat http://garnaat.org/ |
+# Copyright (c) 2010-2011 Mitch Garnaat http://garnaat.org/ |
+# Copyright (c) 2010-2011, Eucalyptus Systems, Inc. |
# |
# Permission is hereby granted, free of charge, to any person obtaining a |
# copy of this software and associated documentation files (the |
@@ -18,35 +19,52 @@ |
# 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. |
-# |
-""" |
-This module provides an interface to the Elastic Compute Cloud (EC2) |
-service from AWS. |
-""" |
-from boto.ec2.connection import EC2Connection |
-def regions(**kw_params): |
+from connection import STSConnection |
+from boto.regioninfo import RegionInfo |
+ |
+def regions(): |
""" |
- Get all available regions for the EC2 service. |
- You may pass any of the arguments accepted by the EC2Connection |
- object's constructor as keyword arguments and they will be |
- passed along to the EC2Connection object. |
- |
+ Get all available regions for the STS service. |
+ |
:rtype: list |
- :return: A list of :class:`boto.ec2.regioninfo.RegionInfo` |
+ :return: A list of :class:`boto.regioninfo.RegionInfo` instances |
""" |
- c = EC2Connection(**kw_params) |
- return c.get_all_regions() |
+ return [RegionInfo(name='us-east-1', |
+ endpoint='sts.amazonaws.com', |
+ connection_cls=STSConnection) |
+ ] |
def connect_to_region(region_name, **kw_params): |
- for region in regions(**kw_params): |
+ """ |
+ Given a valid region name, return a |
+ :class:`boto.sts.connection.STSConnection`. |
+ |
+ :type: str |
+ :param region_name: The name of the region to connect to. |
+ |
+ :rtype: :class:`boto.sts.connection.STSConnection` 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) |
return None |
- |
+ |
def get_region(region_name, **kw_params): |
+ """ |
+ Find and return a :class:`boto.regioninfo.RegionInfo` object |
+ given a region name. |
+ |
+ :type: str |
+ :param: The name of the region. |
+ |
+ :rtype: :class:`boto.regioninfo.RegionInfo` |
+ :return: The RegionInfo object for the given region or None if |
+ an invalid region name is provided. |
+ """ |
for region in regions(**kw_params): |
if region.name == region_name: |
return region |
return None |
- |