class AWS::IAM::UserPolicy

Attributes

name[R]

@return [String] Returns the name of this user policy.

user[R]

@return [User] Returns the user this user policy belongs to.

Public Class Methods

new(user, name, options = {}) click to toggle source

@param [User] The user this user policy belongs to. @param [String] The name of this user policy.

# File lib/aws/iam/user_policy.rb, line 22
def initialize user, name, options = {}
  @user = user
  @name = name
  super
end

Public Instance Methods

delete() click to toggle source

Deletes this user policy. @return [nil]

# File lib/aws/iam/user_policy.rb, line 80
def delete
  client.delete_user_policy(:user_name => user.name, :policy_name => name)
  nil
end
policy() click to toggle source

@return [Policy] Returns the actual policy document for this

user policy.
# File lib/aws/iam/user_policy.rb, line 48
def policy

  response = client.get_user_policy(
    :user_name => user.name,
    :policy_name => name)

  policy = Policy.from_json(URI.decode(response.policy_document))
  policy.extend(PolicyProxy)
  policy.user_policy = self
  policy

end
policy=(policy) click to toggle source

Replaces or updates the user policy with the given policy document. @param [Policy] policy @return [nil]

# File lib/aws/iam/user_policy.rb, line 64
def policy= policy

  policy_document = policy.is_a?(String) ? policy : policy.to_json

  options = {}
  options[:user_name] = user.name
  options[:policy_name] = name
  options[:policy_document] = policy_document

  client.put_user_policy(options)

  nil
end