Class: Fog::AWS::IAM::User
- Inherits:
-
Model
- Object
- Model
- Fog::AWS::IAM::User
- Defined in:
- lib/fog/aws/models/iam/user.rb
Instance Method Summary collapse
- #access_keys ⇒ Object
- #attach(policy_or_arn) ⇒ Object
- #attached_policies ⇒ Object
- #destroy ⇒ Object
- #detach(policy_or_arn) ⇒ Object
- #groups ⇒ Object
- #password=(password) ⇒ Object
- #password_created_at ⇒ Object
- #policies ⇒ Object
- #save ⇒ Object
Instance Method Details
#access_keys ⇒ Object
12 13 14 15 16 |
# File 'lib/fog/aws/models/iam/user.rb', line 12 def access_keys requires :id service.access_keys(:username => id) end |
#attach(policy_or_arn) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/fog/aws/models/iam/user.rb', line 18 def attach(policy_or_arn) requires :identity arn = if policy_or_arn.respond_to?(:arn) policy_or_arn.arn else policy_or_arn end service.attach_user_policy(self.identity, arn) end |
#attached_policies ⇒ Object
42 43 44 45 46 |
# File 'lib/fog/aws/models/iam/user.rb', line 42 def attached_policies requires :identity service.managed_policies(:username => self.identity) end |
#destroy ⇒ Object
48 49 50 51 52 53 |
# File 'lib/fog/aws/models/iam/user.rb', line 48 def destroy requires :id service.delete_user(id) true end |
#detach(policy_or_arn) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/fog/aws/models/iam/user.rb', line 30 def detach(policy_or_arn) requires :identity arn = if policy_or_arn.respond_to?(:arn) policy_or_arn.arn else policy_or_arn end service.detach_user_policy(self.identity, arn) end |
#groups ⇒ Object
55 56 57 58 59 |
# File 'lib/fog/aws/models/iam/user.rb', line 55 def groups requires :identity service.groups(:username => self.identity) end |
#password=(password) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/fog/aws/models/iam/user.rb', line 67 def password=(password) requires :identity has_password = !!self.password_created_at if has_password && password.nil? service.delete_login_profile(self.identity) elsif has_password service.update_login_profile(self.identity, password) elsif !password.nil? service.create_login_profile(self.identity, password) end end |
#password_created_at ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/fog/aws/models/iam/user.rb', line 81 def password_created_at requires :identity service.get_login_profile(self.identity).body["LoginProfile"]["CreateDate"] rescue Fog::AWS::IAM::NotFound nil end |
#policies ⇒ Object
61 62 63 64 65 |
# File 'lib/fog/aws/models/iam/user.rb', line 61 def policies requires :identity service.policies(:username => self.identity) end |
#save ⇒ Object
89 90 91 92 93 94 |
# File 'lib/fog/aws/models/iam/user.rb', line 89 def save requires :id data = service.create_user(id, path || '/').body['User'] merge_attributes(data) true end |