generated from pulumi/pulumi-tf-provider-boilerplate
/
token.go
335 lines (282 loc) · 10 KB
/
token.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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
// Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package tcr
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Use this resource to create tcr long term token.
//
// ## Example Usage
// ### Create a token for tcr instance
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// "github.com/tencentcloudstack/pulumi-tencentcloud/sdk/go/tencentcloud/Tcr"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// exampleInstance, err := Tcr.NewInstance(ctx, "exampleInstance", &Tcr.InstanceArgs{
// InstanceType: pulumi.String("basic"),
// DeleteBucket: pulumi.Bool(true),
// Tags: pulumi.AnyMap{
// "createdBy": pulumi.Any("terraform"),
// },
// })
// if err != nil {
// return err
// }
// _, err = Tcr.NewToken(ctx, "exampleToken", &Tcr.TokenArgs{
// InstanceId: exampleInstance.ID(),
// Description: pulumi.String("example for the tcr token"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// tcr token can be imported using the id, e.g.
//
// ```sh
// $ pulumi import tencentcloud:Tcr/token:Token example instance_id#token_id
// ```
type Token struct {
pulumi.CustomResourceState
// Create time.
CreateTime pulumi.StringOutput `pulumi:"createTime"`
// Description of the token. Valid length is [0~255].
Description pulumi.StringPtrOutput `pulumi:"description"`
// Indicate to enable this token or not.
Enable pulumi.BoolPtrOutput `pulumi:"enable"`
// ID of the TCR instance.
InstanceId pulumi.StringOutput `pulumi:"instanceId"`
// The content of the token.
Token pulumi.StringOutput `pulumi:"token"`
// Sub ID of the TCR token. The full ID of token format like `instance_id#token_id`.
TokenId pulumi.StringOutput `pulumi:"tokenId"`
// User name of the token.
UserName pulumi.StringOutput `pulumi:"userName"`
}
// NewToken registers a new resource with the given unique name, arguments, and options.
func NewToken(ctx *pulumi.Context,
name string, args *TokenArgs, opts ...pulumi.ResourceOption) (*Token, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.InstanceId == nil {
return nil, errors.New("invalid value for required argument 'InstanceId'")
}
opts = pkgResourceDefaultOpts(opts)
var resource Token
err := ctx.RegisterResource("tencentcloud:Tcr/token:Token", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetToken gets an existing Token resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetToken(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *TokenState, opts ...pulumi.ResourceOption) (*Token, error) {
var resource Token
err := ctx.ReadResource("tencentcloud:Tcr/token:Token", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Token resources.
type tokenState struct {
// Create time.
CreateTime *string `pulumi:"createTime"`
// Description of the token. Valid length is [0~255].
Description *string `pulumi:"description"`
// Indicate to enable this token or not.
Enable *bool `pulumi:"enable"`
// ID of the TCR instance.
InstanceId *string `pulumi:"instanceId"`
// The content of the token.
Token *string `pulumi:"token"`
// Sub ID of the TCR token. The full ID of token format like `instance_id#token_id`.
TokenId *string `pulumi:"tokenId"`
// User name of the token.
UserName *string `pulumi:"userName"`
}
type TokenState struct {
// Create time.
CreateTime pulumi.StringPtrInput
// Description of the token. Valid length is [0~255].
Description pulumi.StringPtrInput
// Indicate to enable this token or not.
Enable pulumi.BoolPtrInput
// ID of the TCR instance.
InstanceId pulumi.StringPtrInput
// The content of the token.
Token pulumi.StringPtrInput
// Sub ID of the TCR token. The full ID of token format like `instance_id#token_id`.
TokenId pulumi.StringPtrInput
// User name of the token.
UserName pulumi.StringPtrInput
}
func (TokenState) ElementType() reflect.Type {
return reflect.TypeOf((*tokenState)(nil)).Elem()
}
type tokenArgs struct {
// Description of the token. Valid length is [0~255].
Description *string `pulumi:"description"`
// Indicate to enable this token or not.
Enable *bool `pulumi:"enable"`
// ID of the TCR instance.
InstanceId string `pulumi:"instanceId"`
}
// The set of arguments for constructing a Token resource.
type TokenArgs struct {
// Description of the token. Valid length is [0~255].
Description pulumi.StringPtrInput
// Indicate to enable this token or not.
Enable pulumi.BoolPtrInput
// ID of the TCR instance.
InstanceId pulumi.StringInput
}
func (TokenArgs) ElementType() reflect.Type {
return reflect.TypeOf((*tokenArgs)(nil)).Elem()
}
type TokenInput interface {
pulumi.Input
ToTokenOutput() TokenOutput
ToTokenOutputWithContext(ctx context.Context) TokenOutput
}
func (*Token) ElementType() reflect.Type {
return reflect.TypeOf((**Token)(nil)).Elem()
}
func (i *Token) ToTokenOutput() TokenOutput {
return i.ToTokenOutputWithContext(context.Background())
}
func (i *Token) ToTokenOutputWithContext(ctx context.Context) TokenOutput {
return pulumi.ToOutputWithContext(ctx, i).(TokenOutput)
}
// TokenArrayInput is an input type that accepts TokenArray and TokenArrayOutput values.
// You can construct a concrete instance of `TokenArrayInput` via:
//
// TokenArray{ TokenArgs{...} }
type TokenArrayInput interface {
pulumi.Input
ToTokenArrayOutput() TokenArrayOutput
ToTokenArrayOutputWithContext(context.Context) TokenArrayOutput
}
type TokenArray []TokenInput
func (TokenArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Token)(nil)).Elem()
}
func (i TokenArray) ToTokenArrayOutput() TokenArrayOutput {
return i.ToTokenArrayOutputWithContext(context.Background())
}
func (i TokenArray) ToTokenArrayOutputWithContext(ctx context.Context) TokenArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(TokenArrayOutput)
}
// TokenMapInput is an input type that accepts TokenMap and TokenMapOutput values.
// You can construct a concrete instance of `TokenMapInput` via:
//
// TokenMap{ "key": TokenArgs{...} }
type TokenMapInput interface {
pulumi.Input
ToTokenMapOutput() TokenMapOutput
ToTokenMapOutputWithContext(context.Context) TokenMapOutput
}
type TokenMap map[string]TokenInput
func (TokenMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Token)(nil)).Elem()
}
func (i TokenMap) ToTokenMapOutput() TokenMapOutput {
return i.ToTokenMapOutputWithContext(context.Background())
}
func (i TokenMap) ToTokenMapOutputWithContext(ctx context.Context) TokenMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(TokenMapOutput)
}
type TokenOutput struct{ *pulumi.OutputState }
func (TokenOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Token)(nil)).Elem()
}
func (o TokenOutput) ToTokenOutput() TokenOutput {
return o
}
func (o TokenOutput) ToTokenOutputWithContext(ctx context.Context) TokenOutput {
return o
}
// Create time.
func (o TokenOutput) CreateTime() pulumi.StringOutput {
return o.ApplyT(func(v *Token) pulumi.StringOutput { return v.CreateTime }).(pulumi.StringOutput)
}
// Description of the token. Valid length is [0~255].
func (o TokenOutput) Description() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Token) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput)
}
// Indicate to enable this token or not.
func (o TokenOutput) Enable() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *Token) pulumi.BoolPtrOutput { return v.Enable }).(pulumi.BoolPtrOutput)
}
// ID of the TCR instance.
func (o TokenOutput) InstanceId() pulumi.StringOutput {
return o.ApplyT(func(v *Token) pulumi.StringOutput { return v.InstanceId }).(pulumi.StringOutput)
}
// The content of the token.
func (o TokenOutput) Token() pulumi.StringOutput {
return o.ApplyT(func(v *Token) pulumi.StringOutput { return v.Token }).(pulumi.StringOutput)
}
// Sub ID of the TCR token. The full ID of token format like `instance_id#token_id`.
func (o TokenOutput) TokenId() pulumi.StringOutput {
return o.ApplyT(func(v *Token) pulumi.StringOutput { return v.TokenId }).(pulumi.StringOutput)
}
// User name of the token.
func (o TokenOutput) UserName() pulumi.StringOutput {
return o.ApplyT(func(v *Token) pulumi.StringOutput { return v.UserName }).(pulumi.StringOutput)
}
type TokenArrayOutput struct{ *pulumi.OutputState }
func (TokenArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Token)(nil)).Elem()
}
func (o TokenArrayOutput) ToTokenArrayOutput() TokenArrayOutput {
return o
}
func (o TokenArrayOutput) ToTokenArrayOutputWithContext(ctx context.Context) TokenArrayOutput {
return o
}
func (o TokenArrayOutput) Index(i pulumi.IntInput) TokenOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Token {
return vs[0].([]*Token)[vs[1].(int)]
}).(TokenOutput)
}
type TokenMapOutput struct{ *pulumi.OutputState }
func (TokenMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Token)(nil)).Elem()
}
func (o TokenMapOutput) ToTokenMapOutput() TokenMapOutput {
return o
}
func (o TokenMapOutput) ToTokenMapOutputWithContext(ctx context.Context) TokenMapOutput {
return o
}
func (o TokenMapOutput) MapIndex(k pulumi.StringInput) TokenOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Token {
return vs[0].(map[string]*Token)[vs[1].(string)]
}).(TokenOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*TokenInput)(nil)).Elem(), &Token{})
pulumi.RegisterInputType(reflect.TypeOf((*TokenArrayInput)(nil)).Elem(), TokenArray{})
pulumi.RegisterInputType(reflect.TypeOf((*TokenMapInput)(nil)).Elem(), TokenMap{})
pulumi.RegisterOutputType(TokenOutput{})
pulumi.RegisterOutputType(TokenArrayOutput{})
pulumi.RegisterOutputType(TokenMapOutput{})
}