-
Notifications
You must be signed in to change notification settings - Fork 17
/
TagManager.go
251 lines (212 loc) · 5.88 KB
/
TagManager.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
package awscdk
import (
_init_ "github.com/aws/aws-cdk-go/awscdk/v2/jsii"
_jsii_ "github.com/aws/jsii-runtime-go/runtime"
)
// 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.
//
// Example:
// type myConstruct struct {
// resource
// tags
// }
//
// func newMyConstruct(scope construct, id *string) *myConstruct {
// this := &myConstruct{}
// newResource_Override(this, scope, id)
//
// awscdk.NewCfnResource(this, jsii.String("Resource"), &cfnResourceProps{
// Type: jsii.String("Whatever::The::Type"),
// Properties: map[string]interface{}{
// // ...
// "Tags": this.tags.renderedTags,
// },
// })
// return this
// }
//
type TagManager interface {
// 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.
RenderedTags() IResolvable
// The property name for tag values.
//
// Normally this is `tags` but some resources choose a different name. Cognito
// UserPool uses UserPoolTags.
TagPropertyName() *string
// Determine if the aspect applies here.
//
// Looks at the include and exclude resourceTypeName arrays to determine if
// the aspect applies here.
ApplyTagAspectHere(include *[]*string, exclude *[]*string) *bool
// Returns true if there are any tags defined.
HasTags() *bool
// Removes the specified tag from the array if it exists.
RemoveTag(key *string, priority *float64)
// 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.
RenderTags(combineWithTags interface{}) interface{}
// Adds the specified tag to the array of tags.
SetTag(key *string, value *string, priority *float64, applyToLaunchedInstances *bool)
// Render the tags in a readable format.
TagValues() *map[string]*string
}
// The jsii proxy struct for TagManager
type jsiiProxy_TagManager struct {
_ byte // padding
}
func (j *jsiiProxy_TagManager) RenderedTags() IResolvable {
var returns IResolvable
_jsii_.Get(
j,
"renderedTags",
&returns,
)
return returns
}
func (j *jsiiProxy_TagManager) TagPropertyName() *string {
var returns *string
_jsii_.Get(
j,
"tagPropertyName",
&returns,
)
return returns
}
func NewTagManager(tagType TagType, resourceTypeName *string, initialTags interface{}, options *TagManagerOptions) TagManager {
_init_.Initialize()
if err := validateNewTagManagerParameters(tagType, resourceTypeName, options); err != nil {
panic(err)
}
j := jsiiProxy_TagManager{}
_jsii_.Create(
"aws-cdk-lib.TagManager",
[]interface{}{tagType, resourceTypeName, initialTags, options},
&j,
)
return &j
}
func NewTagManager_Override(t TagManager, tagType TagType, resourceTypeName *string, initialTags interface{}, options *TagManagerOptions) {
_init_.Initialize()
_jsii_.Create(
"aws-cdk-lib.TagManager",
[]interface{}{tagType, resourceTypeName, initialTags, options},
t,
)
}
// Check whether the given construct is Taggable.
func TagManager_IsTaggable(construct interface{}) *bool {
_init_.Initialize()
if err := validateTagManager_IsTaggableParameters(construct); err != nil {
panic(err)
}
var returns *bool
_jsii_.StaticInvoke(
"aws-cdk-lib.TagManager",
"isTaggable",
[]interface{}{construct},
&returns,
)
return returns
}
// Check whether the given construct is ITaggableV2.
func TagManager_IsTaggableV2(construct interface{}) *bool {
_init_.Initialize()
if err := validateTagManager_IsTaggableV2Parameters(construct); err != nil {
panic(err)
}
var returns *bool
_jsii_.StaticInvoke(
"aws-cdk-lib.TagManager",
"isTaggableV2",
[]interface{}{construct},
&returns,
)
return returns
}
// Return the TagManager associated with the given construct, if any.
func TagManager_Of(construct interface{}) TagManager {
_init_.Initialize()
if err := validateTagManager_OfParameters(construct); err != nil {
panic(err)
}
var returns TagManager
_jsii_.StaticInvoke(
"aws-cdk-lib.TagManager",
"of",
[]interface{}{construct},
&returns,
)
return returns
}
func (t *jsiiProxy_TagManager) ApplyTagAspectHere(include *[]*string, exclude *[]*string) *bool {
var returns *bool
_jsii_.Invoke(
t,
"applyTagAspectHere",
[]interface{}{include, exclude},
&returns,
)
return returns
}
func (t *jsiiProxy_TagManager) HasTags() *bool {
var returns *bool
_jsii_.Invoke(
t,
"hasTags",
nil, // no parameters
&returns,
)
return returns
}
func (t *jsiiProxy_TagManager) RemoveTag(key *string, priority *float64) {
if err := t.validateRemoveTagParameters(key, priority); err != nil {
panic(err)
}
_jsii_.InvokeVoid(
t,
"removeTag",
[]interface{}{key, priority},
)
}
func (t *jsiiProxy_TagManager) RenderTags(combineWithTags interface{}) interface{} {
var returns interface{}
_jsii_.Invoke(
t,
"renderTags",
[]interface{}{combineWithTags},
&returns,
)
return returns
}
func (t *jsiiProxy_TagManager) SetTag(key *string, value *string, priority *float64, applyToLaunchedInstances *bool) {
if err := t.validateSetTagParameters(key, value); err != nil {
panic(err)
}
_jsii_.InvokeVoid(
t,
"setTag",
[]interface{}{key, value, priority, applyToLaunchedInstances},
)
}
func (t *jsiiProxy_TagManager) TagValues() *map[string]*string {
var returns *map[string]*string
_jsii_.Invoke(
t,
"tagValues",
nil, // no parameters
&returns,
)
return returns
}