summaryrefslogtreecommitdiff
path: root/boto/iam
diff options
context:
space:
mode:
authorMitch Garnaat <mitch@garnaat.com>2012-09-05 15:44:29 -0700
committerMitch Garnaat <mitch@garnaat.com>2012-09-05 15:44:29 -0700
commitc8864be2ebf1f452da90308350bdc0d17615d7a6 (patch)
treeec1ab954eda3ca06419c8adbfa42677585c28a46 /boto/iam
parent58879d9988b063792f2996d164a226e766f15d09 (diff)
downloadboto-c8864be2ebf1f452da90308350bdc0d17615d7a6.tar.gz
WIP: This should be a complete set of changes to enable testing of cert verification across all services.
Diffstat (limited to 'boto/iam')
-rw-r--r--boto/iam/__init__.py53
1 files changed, 50 insertions, 3 deletions
diff --git a/boto/iam/__init__.py b/boto/iam/__init__.py
index 498d736b..71cf7177 100644
--- a/boto/iam/__init__.py
+++ b/boto/iam/__init__.py
@@ -15,7 +15,7 @@
# 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,
+# 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.
@@ -23,5 +23,52 @@
# this is here for backward compatibility
# originally, the IAMConnection class was defined here
from connection import IAMConnection
-
-
+from boto.regioninfo import RegionInfo
+
+
+class IAMRegionInfo(RegionInfo):
+
+ def connect(self, **kw_params):
+ """
+ Connect to this Region's endpoint. Returns an connection
+ object pointing to the endpoint associated with this region.
+ You may pass any of the arguments accepted by the connection
+ class's constructor as keyword arguments and they will be
+ passed along to the connection object.
+
+ :rtype: Connection object
+ :return: The connection to this regions endpoint
+ """
+ if self.connection_cls:
+ return self.connection_cls(host=self.endpoint, **kw_params)
+
+
+def regions():
+ """
+ Get all available regions for the IAM service.
+
+ :rtype: list
+ :return: A list of :class:`boto.regioninfo.RegionInfo` instances
+ """
+ return [IAMRegionInfo(name='universal',
+ endpoint='iam.amazonaws.com',
+ connection_cls=IAMConnection)
+ ]
+
+
+def connect_to_region(region_name, **kw_params):
+ """
+ Given a valid region name, return a
+ :class:`boto.iam.connection.IAMConnection`.
+
+ :type: str
+ :param region_name: The name of the region to connect to.
+
+ :rtype: :class:`boto.iam.connection.IAMConnection` 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