Class: AWSCDK::Assertions::Tags

Inherits:
Jsii::Object
  • Object
show all
Defined in:
assertions/tags.rb

Overview

Allows assertions on the tags associated with a synthesized CDK stack's manifest.

Stack tags are not part of the synthesized template, so can only be checked from the manifest in this manner.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Tags

Returns a new instance of Tags.

Raises:

  • (NoMethodError)


11
12
13
# File 'assertions/tags.rb', line 11

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

Class Method Details

.from_stack(stack) ⇒ AWSCDK::Assertions::Tags

Find tags associated with a synthesized CDK Stack.

Parameters:

Returns:

  • (AWSCDK::Assertions::Tags)


27
28
29
30
# File 'assertions/tags.rb', line 27

def self.from_stack(stack)
  Jsii::Type.check_type(stack, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5TdGFjayJ9")), "stack")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.assertions.Tags", "fromStack", [stack])
end

.jsii_overridable_methodsObject



15
16
17
18
19
20
21
# File 'assertions/tags.rb', line 15

def self.jsii_overridable_methods
  {
    :all => { kind: :method, name: "all", is_optional: false },
    :has_none => { kind: :method, name: "hasNone", is_optional: false },
    :has_values => { kind: :method, name: "hasValues", is_optional: false },
  }
end

Instance Method Details

#allHash{String => String}

Get the tags associated with the manifest.

This will be an empty object if no tags were supplied.

Returns:

  • (Hash{String => String})

    The tags associated with the stack's synthesized manifest.



38
39
40
# File 'assertions/tags.rb', line 38

def all()
  jsii_call_method("all", [])
end

#has_nonevoid

This method returns an undefined value.

Assert that the there are no tags associated with the synthesized CDK Stack's manifest.

This is a convenience method over hasValues(Match.exact({})), and is present because the more obvious method of detecting no tags (Match.absent()) will not work. Manifests default the tag set to an empty object.



50
51
52
# File 'assertions/tags.rb', line 50

def has_none()
  jsii_call_method("hasNone", [])
end

#has_values(tags) ⇒ void

This method returns an undefined value.

Assert that the given Matcher or object matches the tags associated with the synthesized CDK Stack's manifest.

Parameters:

  • tags (Object)

    the expected set of tags.



58
59
60
61
# File 'assertions/tags.rb', line 58

def has_values(tags)
  Jsii::Type.check_type(tags, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJhbnkifQ==")), "tags")
  jsii_call_method("hasValues", [tags])
end