module AWS::IAM::PolicyCollection
def [] name
-
(Policy)
- The policy with the given name. If no such
Parameters:
-
name
(String
) -- The name of the policy to retrieve.
def [] name resp = get_policy(:policy_name => name) Policy.from_json(URI.unescape(resp.policy_document)) rescue Errors::NoSuchEntity => e nil end
def []= name, document
-
document
(Policy, String
) -- The policy document. This can -
name
(String
) -- The name of the policy document.
def []= name, document document = document.to_json if document.respond_to?(:to_json) and !document.kind_of?(String) put_policy(:policy_name => name, :policy_document => document) end
def clear
def clear keys.each { |k| delete(k) } end
def client_opts(opts = {})
def client_opts(opts = {}) Hash[[[:"#{resource_name}_name", send(resource_name).name]]].merge(opts) end
def delete(name)
-
name
(String
) -- The name of the policy document.
def delete(name) delete_policy(:policy_name => name) nil rescue Errors::NoSuchEntity => e nil end
def delete_policy(opts = {})
def delete_policy(opts = {}) client.send("delete_#{resource_name}_policy", client_opts(opts)) end
def each opts = {}, &block
- Yield: - The name and document for each policy
def each opts = {}, &block opts = opts.dup names_only = opts.delete(:names_only) values_only = opts.delete(:values_only) super(client_opts(opts)) do |pn| case when names_only yield pn when values_only yield self[pn] when block.arity == 2 yield pn, self[pn] else yield [pn, self[pn]] end end end
def each_item(response, &block)
def each_item(response, &block) response.data[:policy_names].each(&block) end
def get_policy(opts = {})
def get_policy(opts = {}) client.send("get_#{resource_name}_policy", client_opts(opts)) end
def has_key? name
-
(Boolean)
- True if there is a policy with the given name.
Parameters:
-
name
(String
) -- The name of the policy to check.
def has_key? name get_policy(:policy_name => name) true rescue Errors::NoSuchEntity => e false end
def keys
-
(Enumerator
- An enumerator for retrieving all)
def keys enumerator(:names_only => true) end
def put_policy(opts = {})
def put_policy(opts = {}) client.send("put_#{resource_name}_policy", client_opts(opts)) end
def request_method
def request_method :"list_#{resource_name}_policies" end
def resource_name
def resource_name raise NotImplementedError unless self.class.name =~ /AWS::IAM::(.*)PolicyCollection$/ $1.downcase end
def to_h
-
(Hash)
- The contents of the collection as a hash.
def to_h inject({}) do |hash, (name, policy)| hash[name] = policy hash end end
def values
-
(Enumerator
- An enumerator for retrieving all)
def values enumerator(:values_only => true) end
def values_at(*names)
-
(Array
- An array containing the requested)
Parameters:
-
names
() -- Each argument is the name of a policy to retrieve.
def values_at(*names) names.map { |n| self[n] } end