generated from pulumi/pulumi-tf-provider-boilerplate
/
tunnel.go
423 lines (367 loc) · 14.5 KB
/
tunnel.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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
// 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 ots
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Provides an OTS tunnel resource.
//
// For information about OTS tunnel and how to use it, see [Tunnel overview](https://www.alibabacloud.com/help/en/tablestore/latest/tunnel-service-overview).
//
// > **NOTE:** Available in v1.172.0+.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-alicloud/sdk/go/alicloud/ots"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
// "github.com/rhysmdnz/pulumi-alicloud/sdk/go/alicloud/ots"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// cfg := config.New(ctx, "")
// name := "terraformtest"
// if param := cfg.Get("name"); param != "" {
// name = param
// }
// fooInstance, err := ots.NewInstance(ctx, "fooInstance", &ots.InstanceArgs{
// Description: pulumi.String(name),
// AccessedBy: pulumi.String("Any"),
// Tags: pulumi.AnyMap{
// "Created": pulumi.Any("TF"),
// "For": pulumi.Any("acceptance test"),
// },
// })
// if err != nil {
// return err
// }
// fooTable, err := ots.NewTable(ctx, "fooTable", &ots.TableArgs{
// InstanceName: fooInstance.Name,
// TableName: pulumi.String(name),
// PrimaryKeys: ots.TablePrimaryKeyArray{
// &ots.TablePrimaryKeyArgs{
// Name: pulumi.String("pk1"),
// Type: pulumi.String("Integer"),
// },
// &ots.TablePrimaryKeyArgs{
// Name: pulumi.String("pk2"),
// Type: pulumi.String("String"),
// },
// &ots.TablePrimaryKeyArgs{
// Name: pulumi.String("pk3"),
// Type: pulumi.String("Binary"),
// },
// },
// TimeToLive: -1,
// MaxVersion: pulumi.Int(1),
// DeviationCellVersionInSec: pulumi.String("1"),
// })
// if err != nil {
// return err
// }
// _, err = ots.NewTunnel(ctx, "fooTunnel", &ots.TunnelArgs{
// InstanceName: fooInstance.Name,
// TableName: fooTable.TableName,
// TunnelName: pulumi.String(name),
// TunnelType: pulumi.String("BaseAndStream"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// OTS tunnel can be imported using id, e.g.
//
// ```sh
//
// $ pulumi import alicloud:ots/tunnel:Tunnel foo <instance_name>:<table_name>:<tunnel_name>
//
// ```
type Tunnel struct {
pulumi.CustomResourceState
// The channels of OTS tunnel. Each element contains the following attributes:
Channels TunnelChannelArrayOutput `pulumi:"channels"`
// The creation time of the Tunnel.
CreateTime pulumi.IntOutput `pulumi:"createTime"`
// Whether the tunnel has expired.
Expired pulumi.BoolOutput `pulumi:"expired"`
// The name of the OTS instance in which table will located.
InstanceName pulumi.StringOutput `pulumi:"instanceName"`
// The name of the OTS table. If changed, a new table would be created.
TableName pulumi.StringOutput `pulumi:"tableName"`
// The tunnel id of the OTS which could not be changed.
TunnelId pulumi.StringOutput `pulumi:"tunnelId"`
// The name of the OTS tunnel. If changed, a new tunnel would be created.
TunnelName pulumi.StringOutput `pulumi:"tunnelName"`
// The latest consumption time of the tunnel, unix time in nanosecond.
TunnelRpo pulumi.IntOutput `pulumi:"tunnelRpo"`
// The stage of OTS tunnel, valid values: `InitBaseDataAndStreamShard`, `ProcessBaseData`, `ProcessStream`.
TunnelStage pulumi.StringOutput `pulumi:"tunnelStage"`
// The type of the OTS tunnel. Only `BaseAndStream`, `BaseData` or `Stream` is allowed.
TunnelType pulumi.StringOutput `pulumi:"tunnelType"`
}
// NewTunnel registers a new resource with the given unique name, arguments, and options.
func NewTunnel(ctx *pulumi.Context,
name string, args *TunnelArgs, opts ...pulumi.ResourceOption) (*Tunnel, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.InstanceName == nil {
return nil, errors.New("invalid value for required argument 'InstanceName'")
}
if args.TableName == nil {
return nil, errors.New("invalid value for required argument 'TableName'")
}
if args.TunnelName == nil {
return nil, errors.New("invalid value for required argument 'TunnelName'")
}
if args.TunnelType == nil {
return nil, errors.New("invalid value for required argument 'TunnelType'")
}
opts = pkgResourceDefaultOpts(opts)
var resource Tunnel
err := ctx.RegisterResource("alicloud:ots/tunnel:Tunnel", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetTunnel gets an existing Tunnel 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 GetTunnel(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *TunnelState, opts ...pulumi.ResourceOption) (*Tunnel, error) {
var resource Tunnel
err := ctx.ReadResource("alicloud:ots/tunnel:Tunnel", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Tunnel resources.
type tunnelState struct {
// The channels of OTS tunnel. Each element contains the following attributes:
Channels []TunnelChannel `pulumi:"channels"`
// The creation time of the Tunnel.
CreateTime *int `pulumi:"createTime"`
// Whether the tunnel has expired.
Expired *bool `pulumi:"expired"`
// The name of the OTS instance in which table will located.
InstanceName *string `pulumi:"instanceName"`
// The name of the OTS table. If changed, a new table would be created.
TableName *string `pulumi:"tableName"`
// The tunnel id of the OTS which could not be changed.
TunnelId *string `pulumi:"tunnelId"`
// The name of the OTS tunnel. If changed, a new tunnel would be created.
TunnelName *string `pulumi:"tunnelName"`
// The latest consumption time of the tunnel, unix time in nanosecond.
TunnelRpo *int `pulumi:"tunnelRpo"`
// The stage of OTS tunnel, valid values: `InitBaseDataAndStreamShard`, `ProcessBaseData`, `ProcessStream`.
TunnelStage *string `pulumi:"tunnelStage"`
// The type of the OTS tunnel. Only `BaseAndStream`, `BaseData` or `Stream` is allowed.
TunnelType *string `pulumi:"tunnelType"`
}
type TunnelState struct {
// The channels of OTS tunnel. Each element contains the following attributes:
Channels TunnelChannelArrayInput
// The creation time of the Tunnel.
CreateTime pulumi.IntPtrInput
// Whether the tunnel has expired.
Expired pulumi.BoolPtrInput
// The name of the OTS instance in which table will located.
InstanceName pulumi.StringPtrInput
// The name of the OTS table. If changed, a new table would be created.
TableName pulumi.StringPtrInput
// The tunnel id of the OTS which could not be changed.
TunnelId pulumi.StringPtrInput
// The name of the OTS tunnel. If changed, a new tunnel would be created.
TunnelName pulumi.StringPtrInput
// The latest consumption time of the tunnel, unix time in nanosecond.
TunnelRpo pulumi.IntPtrInput
// The stage of OTS tunnel, valid values: `InitBaseDataAndStreamShard`, `ProcessBaseData`, `ProcessStream`.
TunnelStage pulumi.StringPtrInput
// The type of the OTS tunnel. Only `BaseAndStream`, `BaseData` or `Stream` is allowed.
TunnelType pulumi.StringPtrInput
}
func (TunnelState) ElementType() reflect.Type {
return reflect.TypeOf((*tunnelState)(nil)).Elem()
}
type tunnelArgs struct {
// The name of the OTS instance in which table will located.
InstanceName string `pulumi:"instanceName"`
// The name of the OTS table. If changed, a new table would be created.
TableName string `pulumi:"tableName"`
// The name of the OTS tunnel. If changed, a new tunnel would be created.
TunnelName string `pulumi:"tunnelName"`
// The type of the OTS tunnel. Only `BaseAndStream`, `BaseData` or `Stream` is allowed.
TunnelType string `pulumi:"tunnelType"`
}
// The set of arguments for constructing a Tunnel resource.
type TunnelArgs struct {
// The name of the OTS instance in which table will located.
InstanceName pulumi.StringInput
// The name of the OTS table. If changed, a new table would be created.
TableName pulumi.StringInput
// The name of the OTS tunnel. If changed, a new tunnel would be created.
TunnelName pulumi.StringInput
// The type of the OTS tunnel. Only `BaseAndStream`, `BaseData` or `Stream` is allowed.
TunnelType pulumi.StringInput
}
func (TunnelArgs) ElementType() reflect.Type {
return reflect.TypeOf((*tunnelArgs)(nil)).Elem()
}
type TunnelInput interface {
pulumi.Input
ToTunnelOutput() TunnelOutput
ToTunnelOutputWithContext(ctx context.Context) TunnelOutput
}
func (*Tunnel) ElementType() reflect.Type {
return reflect.TypeOf((**Tunnel)(nil)).Elem()
}
func (i *Tunnel) ToTunnelOutput() TunnelOutput {
return i.ToTunnelOutputWithContext(context.Background())
}
func (i *Tunnel) ToTunnelOutputWithContext(ctx context.Context) TunnelOutput {
return pulumi.ToOutputWithContext(ctx, i).(TunnelOutput)
}
// TunnelArrayInput is an input type that accepts TunnelArray and TunnelArrayOutput values.
// You can construct a concrete instance of `TunnelArrayInput` via:
//
// TunnelArray{ TunnelArgs{...} }
type TunnelArrayInput interface {
pulumi.Input
ToTunnelArrayOutput() TunnelArrayOutput
ToTunnelArrayOutputWithContext(context.Context) TunnelArrayOutput
}
type TunnelArray []TunnelInput
func (TunnelArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Tunnel)(nil)).Elem()
}
func (i TunnelArray) ToTunnelArrayOutput() TunnelArrayOutput {
return i.ToTunnelArrayOutputWithContext(context.Background())
}
func (i TunnelArray) ToTunnelArrayOutputWithContext(ctx context.Context) TunnelArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(TunnelArrayOutput)
}
// TunnelMapInput is an input type that accepts TunnelMap and TunnelMapOutput values.
// You can construct a concrete instance of `TunnelMapInput` via:
//
// TunnelMap{ "key": TunnelArgs{...} }
type TunnelMapInput interface {
pulumi.Input
ToTunnelMapOutput() TunnelMapOutput
ToTunnelMapOutputWithContext(context.Context) TunnelMapOutput
}
type TunnelMap map[string]TunnelInput
func (TunnelMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Tunnel)(nil)).Elem()
}
func (i TunnelMap) ToTunnelMapOutput() TunnelMapOutput {
return i.ToTunnelMapOutputWithContext(context.Background())
}
func (i TunnelMap) ToTunnelMapOutputWithContext(ctx context.Context) TunnelMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(TunnelMapOutput)
}
type TunnelOutput struct{ *pulumi.OutputState }
func (TunnelOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Tunnel)(nil)).Elem()
}
func (o TunnelOutput) ToTunnelOutput() TunnelOutput {
return o
}
func (o TunnelOutput) ToTunnelOutputWithContext(ctx context.Context) TunnelOutput {
return o
}
// The channels of OTS tunnel. Each element contains the following attributes:
func (o TunnelOutput) Channels() TunnelChannelArrayOutput {
return o.ApplyT(func(v *Tunnel) TunnelChannelArrayOutput { return v.Channels }).(TunnelChannelArrayOutput)
}
// The creation time of the Tunnel.
func (o TunnelOutput) CreateTime() pulumi.IntOutput {
return o.ApplyT(func(v *Tunnel) pulumi.IntOutput { return v.CreateTime }).(pulumi.IntOutput)
}
// Whether the tunnel has expired.
func (o TunnelOutput) Expired() pulumi.BoolOutput {
return o.ApplyT(func(v *Tunnel) pulumi.BoolOutput { return v.Expired }).(pulumi.BoolOutput)
}
// The name of the OTS instance in which table will located.
func (o TunnelOutput) InstanceName() pulumi.StringOutput {
return o.ApplyT(func(v *Tunnel) pulumi.StringOutput { return v.InstanceName }).(pulumi.StringOutput)
}
// The name of the OTS table. If changed, a new table would be created.
func (o TunnelOutput) TableName() pulumi.StringOutput {
return o.ApplyT(func(v *Tunnel) pulumi.StringOutput { return v.TableName }).(pulumi.StringOutput)
}
// The tunnel id of the OTS which could not be changed.
func (o TunnelOutput) TunnelId() pulumi.StringOutput {
return o.ApplyT(func(v *Tunnel) pulumi.StringOutput { return v.TunnelId }).(pulumi.StringOutput)
}
// The name of the OTS tunnel. If changed, a new tunnel would be created.
func (o TunnelOutput) TunnelName() pulumi.StringOutput {
return o.ApplyT(func(v *Tunnel) pulumi.StringOutput { return v.TunnelName }).(pulumi.StringOutput)
}
// The latest consumption time of the tunnel, unix time in nanosecond.
func (o TunnelOutput) TunnelRpo() pulumi.IntOutput {
return o.ApplyT(func(v *Tunnel) pulumi.IntOutput { return v.TunnelRpo }).(pulumi.IntOutput)
}
// The stage of OTS tunnel, valid values: `InitBaseDataAndStreamShard`, `ProcessBaseData`, `ProcessStream`.
func (o TunnelOutput) TunnelStage() pulumi.StringOutput {
return o.ApplyT(func(v *Tunnel) pulumi.StringOutput { return v.TunnelStage }).(pulumi.StringOutput)
}
// The type of the OTS tunnel. Only `BaseAndStream`, `BaseData` or `Stream` is allowed.
func (o TunnelOutput) TunnelType() pulumi.StringOutput {
return o.ApplyT(func(v *Tunnel) pulumi.StringOutput { return v.TunnelType }).(pulumi.StringOutput)
}
type TunnelArrayOutput struct{ *pulumi.OutputState }
func (TunnelArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Tunnel)(nil)).Elem()
}
func (o TunnelArrayOutput) ToTunnelArrayOutput() TunnelArrayOutput {
return o
}
func (o TunnelArrayOutput) ToTunnelArrayOutputWithContext(ctx context.Context) TunnelArrayOutput {
return o
}
func (o TunnelArrayOutput) Index(i pulumi.IntInput) TunnelOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Tunnel {
return vs[0].([]*Tunnel)[vs[1].(int)]
}).(TunnelOutput)
}
type TunnelMapOutput struct{ *pulumi.OutputState }
func (TunnelMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Tunnel)(nil)).Elem()
}
func (o TunnelMapOutput) ToTunnelMapOutput() TunnelMapOutput {
return o
}
func (o TunnelMapOutput) ToTunnelMapOutputWithContext(ctx context.Context) TunnelMapOutput {
return o
}
func (o TunnelMapOutput) MapIndex(k pulumi.StringInput) TunnelOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Tunnel {
return vs[0].(map[string]*Tunnel)[vs[1].(string)]
}).(TunnelOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*TunnelInput)(nil)).Elem(), &Tunnel{})
pulumi.RegisterInputType(reflect.TypeOf((*TunnelArrayInput)(nil)).Elem(), TunnelArray{})
pulumi.RegisterInputType(reflect.TypeOf((*TunnelMapInput)(nil)).Elem(), TunnelMap{})
pulumi.RegisterOutputType(TunnelOutput{})
pulumi.RegisterOutputType(TunnelArrayOutput{})
pulumi.RegisterOutputType(TunnelMapOutput{})
}