Method: AWS::Policy::ConditionBlock#add
- Defined in:
- lib/aws/policy.rb
#add(operator, key, *values) ⇒ Object
Adds a condition to the block. This method defines a convenient set of abbreviations for operators based on the type of value passed in. For example:
conditions.add(:is, :secure_transport, true)
Maps to:
{ "Bool": { "aws:SecureTransport": true } }
While:
conditions.add(:is, :s3_prefix, "photos/")
Maps to:
{ "StringEquals": { "s3:prefix": "photos/" } }
The following list shows which operators are accepted as symbols and how they are represented in the JSON policy:
-
:is(StringEquals, NumericEquals, DateEquals, or Bool) -
:like(StringLike) -
:not_like(StringNotLike) -
:not(StringNotEquals, NumericNotEquals, or DateNotEquals) -
:greater_than,:gt(NumericGreaterThan or DateGreaterThan) -
:greater_than_equals,:gte(NumericGreaterThanEquals or DateGreaterThanEquals) -
:less_than,:lt(NumericLessThan or DateLessThan) -
:less_than_equals,:lte(NumericLessThanEquals or DateLessThanEquals) -
:is_ip_address(IpAddress) -
:not_ip_address(NotIpAddress) -
:is_arn(ArnEquals) -
:not_arn(ArnNotEquals) -
:is_arn_like(ArnLike) -
:not_arn_like(ArnNotLike)
364 365 366 367 368 369 370 371 372 373 374 |
# File 'lib/aws/policy.rb', line 364 def add(operator, key, *values) if operator.kind_of?(Symbol) converted_values = values.map { |v| convert_value(v) } else converted_values = values end operator = translate_operator(operator, values.first) op = (@conditions[operator] ||= {}) raise "duplicate #{operator} conditions for #{key}" if op[key] op[translate_key(key)] = converted_values end |