Class: AWSCDK::IAM::PolicyDocument
- Inherits:
-
Jsii::Object
- Object
- Jsii::Object
- AWSCDK::IAM::PolicyDocument
- Includes:
- AWSCDK::IResolvable
- Defined in:
- iam/policy_document.rb
Overview
A PolicyDocument is a collection of statements.
Class Method Summary collapse
-
.from_json(obj) ⇒ AWSCDK::IAM::PolicyDocument
Creates a new PolicyDocument based on the object provided.
- .jsii_overridable_methods ⇒ Object
Instance Method Summary collapse
-
#add_statements(*statement) ⇒ void
Adds a statement to the policy document.
-
#creation_stack ⇒ Array<String>
The creation stack of this resolvable which will be appended to errors thrown during resolution.
-
#initialize(props = nil) ⇒ PolicyDocument
constructor
A new instance of PolicyDocument.
-
#is_empty ⇒ Boolean
Whether the policy document contains any statements.
-
#resolve(context) ⇒ Object
Produce the Token's value at resolution time.
-
#statement_count ⇒ Numeric
The number of statements already added to this policy.
-
#to_json ⇒ Object
JSON-ify the document.
-
#to_string ⇒ String
Encode the policy document as a string.
-
#validate_for_any_policy ⇒ Array<String>
Validate that all policy statements in the policy document satisfies the requirements for any policy.
-
#validate_for_identity_policy ⇒ Array<String>
Validate that all policy statements in the policy document satisfies the requirements for an identity-based policy.
-
#validate_for_resource_policy ⇒ Array<String>
Validate that all policy statements in the policy document satisfies the requirements for a resource-based policy.
Constructor Details
#initialize(props = nil) ⇒ PolicyDocument
Returns a new instance of PolicyDocument.
10 11 12 13 14 |
# File 'iam/policy_document.rb', line 10 def initialize(props = nil) props = props.is_a?(Hash) ? ::AWSCDK::IAM::PolicyDocumentProps.new(**props.transform_keys(&:to_sym)) : props Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLlBvbGljeURvY3VtZW50UHJvcHMifQ==")), "props") unless props.nil? Jsii::Object.instance_method(:initialize).bind(self).call(props) end |
Class Method Details
.from_json(obj) ⇒ AWSCDK::IAM::PolicyDocument
Creates a new PolicyDocument based on the object provided.
This will accept an object created from the .toJSON() call
37 38 39 40 |
# File 'iam/policy_document.rb', line 37 def self.from_json(obj) Jsii::Type.check_type(obj, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJhbnkifQ==")), "obj") Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_iam.PolicyDocument", "fromJson", [obj]) end |
.jsii_overridable_methods ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'iam/policy_document.rb', line 16 def self.jsii_overridable_methods { :creation_stack => { kind: :property, name: "creationStack", is_optional: false }, :is_empty => { kind: :property, name: "isEmpty", is_optional: false }, :statement_count => { kind: :property, name: "statementCount", is_optional: false }, :add_statements => { kind: :method, name: "addStatements", is_optional: false }, :resolve => { kind: :method, name: "resolve", is_optional: false }, :to_json => { kind: :method, name: "toJSON", is_optional: false }, :to_string => { kind: :method, name: "toString", is_optional: false }, :validate_for_any_policy => { kind: :method, name: "validateForAnyPolicy", is_optional: false }, :validate_for_identity_policy => { kind: :method, name: "validateForIdentityPolicy", is_optional: false }, :validate_for_resource_policy => { kind: :method, name: "validateForResourcePolicy", is_optional: false }, } end |
Instance Method Details
#add_statements(*statement) ⇒ void
This method returns an undefined value.
Adds a statement to the policy document.
72 73 74 75 76 77 |
# File 'iam/policy_document.rb', line 72 def add_statements(*statement) statement.each_with_index do |item, index| Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLlBvbGljeVN0YXRlbWVudCJ9")), "statement[#{index}]") end jsii_call_method("addStatements", [*statement]) end |
#creation_stack ⇒ Array<String>
The creation stack of this resolvable which will be appended to errors thrown during resolution.
This may return an array with a single informational element indicating how to get this property populated, if it was skipped for performance reasons.
48 49 50 |
# File 'iam/policy_document.rb', line 48 def creation_stack() jsii_get_property("creationStack") end |
#is_empty ⇒ Boolean
Whether the policy document contains any statements.
55 56 57 |
# File 'iam/policy_document.rb', line 55 def is_empty() jsii_get_property("isEmpty") end |
#resolve(context) ⇒ Object
Produce the Token's value at resolution time.
83 84 85 86 |
# File 'iam/policy_document.rb', line 83 def resolve(context) Jsii::Type.check_type(context, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5JUmVzb2x2ZUNvbnRleHQifQ==")), "context") jsii_call_method("resolve", [context]) end |
#statement_count ⇒ Numeric
The number of statements already added to this policy.
Can be used, for example, to generate unique "sid"s within the policy.
64 65 66 |
# File 'iam/policy_document.rb', line 64 def statement_count() jsii_get_property("statementCount") end |
#to_json ⇒ Object
JSON-ify the document.
Used when JSON.stringify() is called
93 94 95 |
# File 'iam/policy_document.rb', line 93 def to_json() jsii_call_method("toJSON", []) end |
#to_string ⇒ String
Encode the policy document as a string.
100 101 102 |
# File 'iam/policy_document.rb', line 100 def to_string() jsii_call_method("toString", []) end |
#validate_for_any_policy ⇒ Array<String>
Validate that all policy statements in the policy document satisfies the requirements for any policy.
108 109 110 |
# File 'iam/policy_document.rb', line 108 def validate_for_any_policy() jsii_call_method("validateForAnyPolicy", []) end |
#validate_for_identity_policy ⇒ Array<String>
Validate that all policy statements in the policy document satisfies the requirements for an identity-based policy.
116 117 118 |
# File 'iam/policy_document.rb', line 116 def validate_for_identity_policy() jsii_call_method("validateForIdentityPolicy", []) end |
#validate_for_resource_policy ⇒ Array<String>
Validate that all policy statements in the policy document satisfies the requirements for a resource-based policy.
124 125 126 |
# File 'iam/policy_document.rb', line 124 def validate_for_resource_policy() jsii_call_method("validateForResourcePolicy", []) end |