Class: AWSCDK::TagManager
- Inherits:
-
Jsii::Object
- Object
- Jsii::Object
- AWSCDK::TagManager
- Defined in:
- tag_manager.rb
Overview
TagManager facilitates a common implementation of tagging for Constructs.
Normally, you do not need to use this class, as the CloudFormation specification
will indicate which resources are taggable. However, sometimes you will need this
to make custom resources taggable. Used tagManager.renderedTags to obtain a
value that will resolve to the tags at synthesis time.
Class Method Summary collapse
-
.is_taggable(construct) ⇒ Boolean
Check whether the given construct is Taggable.
-
.is_taggable_v2(construct) ⇒ Boolean
Check whether the given construct is ITaggableV2.
- .jsii_overridable_methods ⇒ Object
-
.of(construct) ⇒ AWSCDK::TagManager?
Return the TagManager associated with the given construct, if any.
Instance Method Summary collapse
-
#apply_tag_aspect_here(include = nil, exclude = nil) ⇒ Boolean
Determine if the aspect applies here.
-
#has_tags ⇒ Boolean
Returns true if there are any tags defined.
-
#initialize(tag_type, resource_type_name, initial_tags = nil, options = nil) ⇒ TagManager
constructor
A new instance of TagManager.
-
#remove_tag(key, priority) ⇒ void
Removes the specified tag from the array if it exists.
-
#render_tags(combine_with_tags = nil) ⇒ Object
Renders tags into the proper format based on TagType.
-
#rendered_tags ⇒ AWSCDK::IResolvable
A lazy value that represents the rendered tags at synthesis time.
-
#set_tag(key, value, priority = nil, apply_to_launched_instances = nil) ⇒ void
Adds the specified tag to the array of tags.
-
#tag_property_name ⇒ String
The property name for tag values.
-
#tag_values ⇒ Hash{String => String}
Render the tags in a readable format.
Constructor Details
#initialize(tag_type, resource_type_name, initial_tags = nil, options = nil) ⇒ TagManager
Returns a new instance of TagManager.
35 36 37 38 39 40 41 42 |
# File 'tag_manager.rb', line 35 def initialize(tag_type, resource_type_name, = nil, = nil) = .is_a?(Hash) ? ::AWSCDK::TagManagerOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(tag_type, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5UYWdUeXBlIn0=")), "tagType") Jsii::Type.check_type(resource_type_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "resourceTypeName") Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJhbnkifQ==")), "initialTags") unless .nil? Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5UYWdNYW5hZ2VyT3B0aW9ucyJ9")), "options") unless .nil? Jsii::Object.instance_method(:initialize).bind(self).call(tag_type, resource_type_name, , ) end |
Class Method Details
.is_taggable(construct) ⇒ Boolean
Check whether the given construct is Taggable.
61 62 63 64 |
# File 'tag_manager.rb', line 61 def self.is_taggable(construct) Jsii::Type.check_type(construct, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJhbnkifQ==")), "construct") Jsii::Kernel.instance.call_static("aws-cdk-lib.TagManager", "isTaggable", [construct]) end |
.is_taggable_v2(construct) ⇒ Boolean
Check whether the given construct is ITaggableV2.
70 71 72 73 |
# File 'tag_manager.rb', line 70 def self.is_taggable_v2(construct) Jsii::Type.check_type(construct, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJhbnkifQ==")), "construct") Jsii::Kernel.instance.call_static("aws-cdk-lib.TagManager", "isTaggableV2", [construct]) end |
.jsii_overridable_methods ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'tag_manager.rb', line 44 def self.jsii_overridable_methods { :rendered_tags => { kind: :property, name: "renderedTags", is_optional: false }, :tag_property_name => { kind: :property, name: "tagPropertyName", is_optional: false }, :apply_tag_aspect_here => { kind: :method, name: "applyTagAspectHere", is_optional: false }, :has_tags => { kind: :method, name: "hasTags", is_optional: false }, :remove_tag => { kind: :method, name: "removeTag", is_optional: false }, :render_tags => { kind: :method, name: "renderTags", is_optional: false }, :set_tag => { kind: :method, name: "setTag", is_optional: false }, :tag_values => { kind: :method, name: "tagValues", is_optional: false }, } end |
.of(construct) ⇒ AWSCDK::TagManager?
Return the TagManager associated with the given construct, if any.
79 80 81 82 |
# File 'tag_manager.rb', line 79 def self.of(construct) Jsii::Type.check_type(construct, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJhbnkifQ==")), "construct") Jsii::Kernel.instance.call_static("aws-cdk-lib.TagManager", "of", [construct]) end |
Instance Method Details
#apply_tag_aspect_here(include = nil, exclude = nil) ⇒ Boolean
Determine if the aspect applies here.
Looks at the include and exclude resourceTypeName arrays to determine if the aspect applies here
112 113 114 115 116 |
# File 'tag_manager.rb', line 112 def apply_tag_aspect_here(include = nil, exclude = nil) Jsii::Type.check_type(include, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "include") unless include.nil? Jsii::Type.check_type(exclude, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "exclude") unless exclude.nil? jsii_call_method("applyTagAspectHere", [include, exclude]) end |
#has_tags ⇒ Boolean
Returns true if there are any tags defined.
121 122 123 |
# File 'tag_manager.rb', line 121 def () jsii_call_method("hasTags", []) end |
#remove_tag(key, priority) ⇒ void
This method returns an undefined value.
Removes the specified tag from the array if it exists.
130 131 132 133 134 |
# File 'tag_manager.rb', line 130 def remove_tag(key, priority) Jsii::Type.check_type(key, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "key") Jsii::Type.check_type(priority, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "priority") jsii_call_method("removeTag", [key, priority]) end |
#render_tags(combine_with_tags = nil) ⇒ Object
Renders tags into the proper format based on TagType.
This method will eagerly render the tags currently applied. In
most cases, you should be using tagManager.renderedTags instead,
which will return a Lazy value that will resolve to the correct
tags at synthesis time.
145 146 147 148 |
# File 'tag_manager.rb', line 145 def ( = nil) Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJhbnkifQ==")), "combineWithTags") unless .nil? jsii_call_method("renderTags", []) end |
#rendered_tags ⇒ AWSCDK::IResolvable
A lazy value that represents the rendered tags at synthesis time.
If you need to make a custom construct taggable, use the value of this
property to pass to the tags property of the underlying construct.
90 91 92 |
# File 'tag_manager.rb', line 90 def () jsii_get_property("renderedTags") end |
#set_tag(key, value, priority = nil, apply_to_launched_instances = nil) ⇒ void
This method returns an undefined value.
Adds the specified tag to the array of tags.
157 158 159 160 161 162 163 |
# File 'tag_manager.rb', line 157 def set_tag(key, value, priority = nil, apply_to_launched_instances = nil) Jsii::Type.check_type(key, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "key") Jsii::Type.check_type(value, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "value") Jsii::Type.check_type(priority, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "priority") unless priority.nil? Jsii::Type.check_type(apply_to_launched_instances, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "applyToLaunchedInstances") unless apply_to_launched_instances.nil? jsii_call_method("setTag", [key, value, priority, apply_to_launched_instances]) end |
#tag_property_name ⇒ String
The property name for tag values.
Normally this is tags but some resources choose a different name. Cognito
UserPool uses UserPoolTags
100 101 102 |
# File 'tag_manager.rb', line 100 def tag_property_name() jsii_get_property("tagPropertyName") end |
#tag_values ⇒ Hash{String => String}
Render the tags in a readable format.
168 169 170 |
# File 'tag_manager.rb', line 168 def tag_values() jsii_call_method("tagValues", []) end |