Class: AWS::IAM::UserPolicy
- Inherits:
-
Resource
- Object
- Core::Resource
- Resource
- AWS::IAM::UserPolicy
- Defined in:
- lib/aws/iam/user_policy.rb
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
Returns the name of this user policy.
-
#user ⇒ User
readonly
Returns the user this user policy belongs to.
Instance Method Summary collapse
-
#delete ⇒ nil
Deletes this user policy.
-
#initialize(user, name, options = {}) ⇒ UserPolicy
constructor
A new instance of UserPolicy.
-
#policy ⇒ Policy
Returns the actual policy document for this user policy.
-
#policy=(policy) ⇒ nil
Replaces or updates the user policy with the given policy document.
Constructor Details
#initialize(user, name, options = {}) ⇒ UserPolicy
Returns a new instance of UserPolicy.
24 25 26 27 28 |
# File 'lib/aws/iam/user_policy.rb', line 24 def initialize user, name, = {} @user = user @name = name super end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns the name of this user policy.
34 35 36 |
# File 'lib/aws/iam/user_policy.rb', line 34 def name @name end |
#user ⇒ User (readonly)
Returns the user this user policy belongs to.
31 32 33 |
# File 'lib/aws/iam/user_policy.rb', line 31 def user @user end |
Instance Method Details
#delete ⇒ nil
Deletes this user policy.
82 83 84 85 |
# File 'lib/aws/iam/user_policy.rb', line 82 def delete client.delete_user_policy(:user_name => user.name, :policy_name => name) nil end |
#policy ⇒ Policy
Returns the actual policy document for this user policy.
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/aws/iam/user_policy.rb', line 50 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) ⇒ nil
Replaces or updates the user policy with the given policy document.
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/aws/iam/user_policy.rb', line 66 def policy= policy policy_document = policy.is_a?(String) ? policy : policy.to_json = {} [:user_name] = user.name [:policy_name] = name [:policy_document] = policy_document client.put_user_policy() nil end |