Class: Fog::AWS::IAM::User

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/aws/models/iam/user.rb

Instance Method Summary collapse

Instance Method Details

#access_keysObject



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_policiesObject



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

#destroyObject



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

#groupsObject



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.(self.identity)
  elsif has_password
    service.(self.identity, password)
  elsif !password.nil?
    service.(self.identity, password)
  end
end

#password_created_atObject



81
82
83
84
85
86
87
# File 'lib/fog/aws/models/iam/user.rb', line 81

def password_created_at
  requires :identity

  service.(self.identity).body["LoginProfile"]["CreateDate"]
rescue Fog::AWS::IAM::NotFound
  nil
end

#policiesObject



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

#saveObject



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