Class: Fog::AWS::IAM::ManagedPolicy

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#policy_documentObject

Returns the value of attribute policy_document.



17
18
19
# File 'lib/fog/aws/models/iam/managed_policy.rb', line 17

def policy_document
  @policy_document
end

Instance Method Details

#attach(user_or_username) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fog/aws/models/iam/managed_policy.rb', line 19

def attach(user_or_username)
  requires :arn

  username = if user_or_username.respond_to?(:identity)
               user_or_username.identity
             else
               user_or_username
             end

  service.attach_user_policy(username, self.arn)
end

#destroyObject



48
49
50
51
52
53
54
# File 'lib/fog/aws/models/iam/managed_policy.rb', line 48

def destroy
  requires :arn

  service.delete_policy(self.arn)

  true
end

#documentObject



31
32
33
34
35
36
# File 'lib/fog/aws/models/iam/managed_policy.rb', line 31

def document
  requires :arn, :default_version

  service.get_policy_version(self.arn, self.default_version).
    body['PolicyVersion']['Document']
end

#reloadObject



38
39
40
# File 'lib/fog/aws/models/iam/managed_policy.rb', line 38

def reload
  service.managed_policies.get(self.arn)
end

#saveObject



42
43
44
45
46
# File 'lib/fog/aws/models/iam/managed_policy.rb', line 42

def save
  requires :name, :policy_document

  merge_attributes(service.create_policy(self.name, self.policy_document, self.path, self.description).body["Policy"])
end