Permalink
Browse files

Implement a wrapper object for User-data from IAM

  • Loading branch information...
1 parent b60c12a commit 8e0fbbc4328a567ce03a243aca13b00097216ea3 @gertjanol gertjanol committed Oct 12, 2012
Showing with 66 additions and 1 deletion.
  1. +5 −1 boto/iam/connection.py
  2. +61 −0 boto/iam/user.py
View
@@ -29,6 +29,7 @@
from boto.resultset import ResultSet
from boto.iam.summarymap import SummaryMap
from boto.connection import AWSQueryConnection
+from boto.iam.user import User
ASSUME_ROLE_POLICY_DOCUMENT = json.dumps({
@@ -358,11 +359,14 @@ def get_user(self, user_name=None):
:type user_name: string
:param user_name: The name of the user to delete.
If not specified, defaults to user making request.
+
+ :rtype: :class:`boto.iam.user.User`
+ :return: The requested User instance
"""
params = {}
if user_name:
params['UserName'] = user_name
- return self.get_response('GetUser', params)
+ return self.get_object('GetUser', params, User)
def update_user(self, user_name, new_user_name=None, new_path=None):
"""
View
@@ -0,0 +1,61 @@
+# Copyright (c) 2012 Byte BV, http://byte.nl
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish, dis-
+# tribute, sublicense, and/or sell copies of the Software, and to permit
+# persons to whom the Software is furnished to do so, subject to the fol-
+# lowing conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# 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,
+# 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.
+
+
+class User(object):
+ """
+ Represents an IAM User
+
+ :ivar arn: The Amazon Resource Name (ARN) specifying the user
+ :ivar create_date: The date when the user was created
+ :ivar id: The stable and unique string identifying the user
+ :ivar name: The name identifying the user
+ :ivar path: Path to the user
+ """
+
+ def __init__(self, connection=None, name=None):
+ self.connection = connection
+ self.name = name
+ self.arn = None
+ self.create_date = None
+ self.id = None
+ self.path = None
+
+ def __repr__(self):
+ return 'User:%s' % self.name
+
+ def startElement(self, name, attrs, connection):
+ pass
+
+ def endElement(self, name, value, connection):
+ if name == 'Arn':
+ self.arn = value
+ elif name == 'Path':
+ self.path = value
+ elif name == 'UserId':
+ self.id = value
+ elif name == 'UserName':
+ self.name = value
+ elif name == 'CreateDate':
+ self.create_date = value
+ else:
+ setattr(self, name, value)
+

0 comments on commit 8e0fbbc

Please sign in to comment.