Class: AWSCDK::Annotations

Inherits:
Jsii::Object
  • Object
show all
Defined in:
annotations.rb

Overview

Includes API for attaching annotations such as warning messages to constructs.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Annotations

Returns a new instance of Annotations.

Raises:

  • (NoMethodError)


8
9
10
# File 'annotations.rb', line 8

def initialize(*args)
  raise NoMethodError, "aws-cdk-lib.Annotations does not have a visible constructor; use the provided factory methods"
end

Class Method Details

.jsii_overridable_methodsObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'annotations.rb', line 12

def self.jsii_overridable_methods
  {
    :acknowledge_info => { kind: :method, name: "acknowledgeInfo", is_optional: false },
    :acknowledge_warning => { kind: :method, name: "acknowledgeWarning", is_optional: false },
    :add_deprecation => { kind: :method, name: "addDeprecation", is_optional: false },
    :add_error => { kind: :method, name: "addError", is_optional: false },
    :add_info => { kind: :method, name: "addInfo", is_optional: false },
    :add_info_v2 => { kind: :method, name: "addInfoV2", is_optional: false },
    :add_warning => { kind: :method, name: "addWarning", is_optional: false },
    :add_warning_v2 => { kind: :method, name: "addWarningV2", is_optional: false },
  }
end

.of(scope) ⇒ AWSCDK::Annotations

Returns the annotations API for a construct scope.

Parameters:

  • scope (Constructs::IConstruct)

    The scope.

Returns:

  • (AWSCDK::Annotations)


29
30
31
32
# File 'annotations.rb', line 29

def self.of(scope)
  Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklDb25zdHJ1Y3QifQ==")), "scope")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.Annotations", "of", [scope])
end

Instance Method Details

#acknowledge_info(id, message = nil) ⇒ void

This method returns an undefined value.

Acknowledge a info. When a info is acknowledged for a scope all infos that match the id will be ignored.

The acknowledgement will apply to all child scopes

Examples:

my_construct = nil # Constructs::Construct

AWSCDK::Annotations.of(my_construct).acknowledge_info("SomeInfoId", "This info can be ignored because...")

Parameters:

  • id (String)
    • the id of the info message to acknowledge.
  • message (String, nil) (defaults to: nil)

    optional message to explain the reason for acknowledgement.



45
46
47
48
49
# File 'annotations.rb', line 45

def acknowledge_info(id, message = nil)
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  Jsii::Type.check_type(message, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "message") unless message.nil?
  jsii_call_method("acknowledgeInfo", [id, message])
end

#acknowledge_warning(id, message = nil) ⇒ void

This method returns an undefined value.

Acknowledge a warning. When a warning is acknowledged for a scope all warnings that match the id will be ignored.

The acknowledgement will apply to all child scopes

Examples:

my_construct = nil # Constructs::Construct

AWSCDK::Annotations.of(my_construct).acknowledge_warning("SomeWarningId", "This warning can be ignored because...")

Parameters:

  • id (String)
    • the id of the warning message to acknowledge.
  • message (String, nil) (defaults to: nil)

    optional message to explain the reason for acknowledgement.



62
63
64
65
66
# File 'annotations.rb', line 62

def acknowledge_warning(id, message = nil)
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  Jsii::Type.check_type(message, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "message") unless message.nil?
  jsii_call_method("acknowledgeWarning", [id, message])
end

#add_deprecation(api, message) ⇒ void

This method returns an undefined value.

Adds a deprecation warning for a specific API.

Deprecations will be added only once per construct as a warning and will be deduplicated based on the api.

If the environment variable CDK_BLOCK_DEPRECATIONS is set, this method will throw an error instead with the deprecation message.

Parameters:

  • api (String)

    The API being deprecated in the format module.Class.property (e.g. @aws-cdk/core.Construct.node).

  • message (String)

    The deprecation message to display, with information about alternatives.



79
80
81
82
83
# File 'annotations.rb', line 79

def add_deprecation(api, message)
  Jsii::Type.check_type(api, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "api")
  Jsii::Type.check_type(message, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "message")
  jsii_call_method("addDeprecation", [api, message])
end

#add_error(message) ⇒ void

This method returns an undefined value.

Adds an { "error": } metadata entry to this construct.

The toolkit will fail deployment of any stack that has errors reported against it. Prefer using Validations.of(scope).addError() instead.

Parameters:

  • message (String)

    The error message.



92
93
94
95
# File 'annotations.rb', line 92

def add_error(message)
  Jsii::Type.check_type(message, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "message")
  jsii_call_method("addError", [message])
end

#add_info(message) ⇒ void

This method returns an undefined value.

Adds an info metadata entry to this construct.

The CLI will display the info message when apps are synthesized.

Parameters:

  • message (String)

    The info message.



103
104
105
106
# File 'annotations.rb', line 103

def add_info(message)
  Jsii::Type.check_type(message, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "message")
  jsii_call_method("addInfo", [message])
end

#add_info_v2(id, message) ⇒ void

This method returns an undefined value.

Adds an acknowledgeable info metadata entry to this construct.

The CLI will display the info when an app is synthesized.

If the info is acknowledged using acknowledge_info(), it will not be shown by the CLI.

Examples:

my_construct = nil # Constructs::Construct

AWSCDK::Annotations.of(my_construct).add_info_v2("my-library:Construct.someInfo", "Some message explaining the info")

Parameters:

  • id (String)

    the unique identifier for the info.

  • message (String)

    The info message.



121
122
123
124
125
# File 'annotations.rb', line 121

def add_info_v2(id, message)
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  Jsii::Type.check_type(message, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "message")
  jsii_call_method("addInfoV2", [id, message])
end

#add_warning(message) ⇒ void

This method returns an undefined value.

Adds a warning metadata entry to this construct. Prefer using Validations.of(scope).addWarning().

The CLI will display the warning when an app is synthesized, or fail if run in --strict mode.

Warnings added by this call cannot be acknowledged. This will block users from running in --strict mode until the deal with the warning, which makes it effectively not very different from add_error. Prefer using add_warning_v2 instead.

Parameters:

  • message (String)

    The warning message.



138
139
140
141
# File 'annotations.rb', line 138

def add_warning(message)
  Jsii::Type.check_type(message, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "message")
  jsii_call_method("addWarning", [message])
end

#add_warning_v2(id, message) ⇒ void

This method returns an undefined value.

Adds an acknowledgeable warning metadata entry to this construct.

The CLI will display the warning when an app is synthesized, or fail if run in --strict mode.

If the warning is acknowledged using acknowledge_warning(), it will not be shown by the CLI, and will not cause --strict mode to fail synthesis.

Prefer using Validations.of(scope).addWarning() instead.

Examples:

my_construct = nil # Constructs::Construct

AWSCDK::Annotations.of(my_construct).add_warning_v2("my-library:Construct.someWarning", "Some message explaining the warning")

Parameters:

  • id (String)

    the unique identifier for the warning.

  • message (String)

    The warning message.



160
161
162
163
164
# File 'annotations.rb', line 160

def add_warning_v2(id, message)
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  Jsii::Type.check_type(message, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "message")
  jsii_call_method("addWarningV2", [id, message])
end