Class: AWSCDK::Validations
- Inherits:
-
Jsii::Object
- Object
- Jsii::Object
- AWSCDK::Validations
- Defined in:
- validations.rb
Overview
Manages validations for CDK constructs.
Class Method Summary collapse
-
.ACKNOWLEDGED_RULES_METADATA_KEY ⇒ String
Metadata key used to store acknowledged rules on construct nodes.
- .jsii_overridable_methods ⇒ Object
-
.of(scope) ⇒ AWSCDK::Validations
Returns the Validations for the given construct scope.
Instance Method Summary collapse
-
#acknowledge(*rules) ⇒ void
Acknowledge one or more rules, suppressing them from validation output.
-
#add_error(id, message) ⇒ void
Adds an error metadata entry to this construct.
-
#add_plugins(*plugins) ⇒ void
Register one or more validation plugins that will be executed during synthesis.
-
#add_warning(id, message) ⇒ void
Adds a warning metadata entry to this construct that can be acknowledged.
-
#initialize(*args) ⇒ Validations
constructor
A new instance of Validations.
Constructor Details
#initialize(*args) ⇒ Validations
Returns a new instance of Validations.
14 15 16 |
# File 'validations.rb', line 14 def initialize(*args) raise NoMethodError, "aws-cdk-lib.Validations does not have a visible constructor; use the provided factory methods" end |
Class Method Details
.ACKNOWLEDGED_RULES_METADATA_KEY ⇒ String
Metadata key used to store acknowledged rules on construct nodes.
Plugin authors can read this metadata to build audit trails from
acknowledgments recorded via acknowledge().
42 43 44 |
# File 'validations.rb', line 42 def self.ACKNOWLEDGED_RULES_METADATA_KEY() Jsii::Kernel.instance.get_static("aws-cdk-lib.Validations", "ACKNOWLEDGED_RULES_METADATA_KEY") end |
.jsii_overridable_methods ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'validations.rb', line 18 def self.jsii_overridable_methods { :acknowledge => { kind: :method, name: "acknowledge", is_optional: false }, :add_error => { kind: :method, name: "addError", is_optional: false }, :add_plugins => { kind: :method, name: "addPlugins", is_optional: false }, :add_warning => { kind: :method, name: "addWarning", is_optional: false }, } end |
.of(scope) ⇒ AWSCDK::Validations
Returns the Validations for the given construct scope.
31 32 33 34 |
# File 'validations.rb', line 31 def self.of(scope) Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklDb25zdHJ1Y3QifQ==")), "scope") Jsii::Kernel.instance.call_static("aws-cdk-lib.Validations", "of", [scope]) end |
Instance Method Details
#acknowledge(*rules) ⇒ void
This method returns an undefined value.
Acknowledge one or more rules, suppressing them from validation output.
Acknowledgments are recorded to construct metadata so that downstream plugins (e.g. CDK Nag) can read them for audit trails.
Currently only annotation warnings can be suppressed. Annotation errors are not yet acknowledgeable.
If an ID has no well-known prefix, it is assumed to be an annotation rule for backwards compatibility.
59 60 61 62 63 64 65 |
# File 'validations.rb', line 59 def acknowledge(*rules) rules.map! { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::Acknowledgment.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 } rules.each_with_index do |item, index| Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5BY2tub3dsZWRnbWVudCJ9")), "rules[#{index}]") end jsii_call_method("acknowledge", [*rules]) end |
#add_error(id, message) ⇒ void
This method returns an undefined value.
Adds an error metadata entry to this construct.
Synthesis will be interrupted when errors are reported.
Note: Annotation errors are not currently acknowledgeable. The ID is
recorded for identification purposes but acknowledge() will not
suppress errors added via this method.
78 79 80 81 82 |
# File 'validations.rb', line 78 def add_error(id, ) Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id") Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "message") jsii_call_method("addError", [id, ]) end |
#add_plugins(*plugins) ⇒ void
This method returns an undefined value.
Register one or more validation plugins that will be executed during synthesis.
Plugins can only be registered within a Stage or App scope. If any plugin reports a violation, synthesis will be interrupted and the report displayed to the user.
92 93 94 95 96 97 |
# File 'validations.rb', line 92 def add_plugins(*plugins) plugins.each_with_index do |item, index| Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5JUG9saWN5VmFsaWRhdGlvblBsdWdpbiJ9")), "plugins[#{index}]") end jsii_call_method("addPlugins", [*plugins]) end |
#add_warning(id, message) ⇒ void
This method returns an undefined value.
Adds a warning metadata entry to this construct that can be acknowledged.
The CLI will display the warning when an app is synthesized, or fail if run
in --strict mode.
The ID will be stored with the annotation prefix (e.g. annotation::MyWarning).
Use this prefixed ID when calling acknowledge() to suppress the warning.
110 111 112 113 114 |
# File 'validations.rb', line 110 def add_warning(id, ) Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id") Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "message") jsii_call_method("addWarning", [id, ]) end |