generated from pulumi/pulumi-tf-provider-boilerplate
/
db.go
377 lines (325 loc) · 13.2 KB
/
db.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
// 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 sqlserver
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Provides a SQL Server DB resource belongs to SQL Server instance.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-tencentcloud/sdk/go/tencentcloud/Availability"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// "github.com/tencentcloudstack/pulumi-tencentcloud/sdk/go/tencentcloud/Availability"
// "github.com/tencentcloudstack/pulumi-tencentcloud/sdk/go/tencentcloud/Security"
// "github.com/tencentcloudstack/pulumi-tencentcloud/sdk/go/tencentcloud/Sqlserver"
// "github.com/tencentcloudstack/pulumi-tencentcloud/sdk/go/tencentcloud/Subnet"
// "github.com/tencentcloudstack/pulumi-tencentcloud/sdk/go/tencentcloud/Vpc"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// zones, err := Availability.GetZonesByProduct(ctx, &availability.GetZonesByProductArgs{
// Product: "sqlserver",
// }, nil)
// if err != nil {
// return err
// }
// vpc, err := Vpc.NewInstance(ctx, "vpc", &Vpc.InstanceArgs{
// CidrBlock: pulumi.String("10.0.0.0/16"),
// })
// if err != nil {
// return err
// }
// subnet, err := Subnet.NewInstance(ctx, "subnet", &Subnet.InstanceArgs{
// AvailabilityZone: pulumi.String(zones.Zones[4].Name),
// VpcId: vpc.ID(),
// CidrBlock: pulumi.String("10.0.0.0/16"),
// IsMulticast: pulumi.Bool(false),
// })
// if err != nil {
// return err
// }
// securityGroup, err := Security.NewGroup(ctx, "securityGroup", &Security.GroupArgs{
// Description: pulumi.String("desc."),
// })
// if err != nil {
// return err
// }
// exampleBasicInstance, err := Sqlserver.NewBasicInstance(ctx, "exampleBasicInstance", &Sqlserver.BasicInstanceArgs{
// AvailabilityZone: pulumi.String(zones.Zones[4].Name),
// ChargeType: pulumi.String("POSTPAID_BY_HOUR"),
// VpcId: vpc.ID(),
// SubnetId: subnet.ID(),
// ProjectId: pulumi.Int(0),
// Memory: pulumi.Int(4),
// Storage: pulumi.Int(100),
// Cpu: pulumi.Int(2),
// MachineType: pulumi.String("CLOUD_PREMIUM"),
// MaintenanceWeekSets: pulumi.IntArray{
// pulumi.Int(1),
// pulumi.Int(2),
// pulumi.Int(3),
// },
// MaintenanceStartTime: pulumi.String("09:00"),
// MaintenanceTimeSpan: pulumi.Int(3),
// SecurityGroups: pulumi.StringArray{
// securityGroup.ID(),
// },
// Tags: pulumi.AnyMap{
// "test": pulumi.Any("test"),
// },
// })
// if err != nil {
// return err
// }
// _, err = Sqlserver.NewDb(ctx, "exampleDb", &Sqlserver.DbArgs{
// InstanceId: exampleBasicInstance.ID(),
// Charset: pulumi.String("Chinese_PRC_BIN"),
// Remark: pulumi.String("test-remark"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// SQL Server DB can be imported using the id, e.g.
//
// ```sh
// $ pulumi import tencentcloud:Sqlserver/db:Db example mssql-3cdq7kx5#tf_example_db
// ```
type Db struct {
pulumi.CustomResourceState
// Character set DB uses. Valid values: `Chinese_PRC_CI_AS`, `Chinese_PRC_CS_AS`, `Chinese_PRC_BIN`, `Chinese_Taiwan_Stroke_CI_AS`, `SQL_Latin1_General_CP1_CI_AS`, and `SQL_Latin1_General_CP1_CS_AS`. Default value is `Chinese_PRC_CI_AS`.
Charset pulumi.StringPtrOutput `pulumi:"charset"`
// Database creation time.
CreateTime pulumi.StringOutput `pulumi:"createTime"`
// SQL Server instance ID which DB belongs to.
InstanceId pulumi.StringOutput `pulumi:"instanceId"`
// Name of SQL Server DB. The database name must be unique and must be composed of numbers, letters and underlines, and the first one can not be underline.
Name pulumi.StringOutput `pulumi:"name"`
// Remark of the DB.
Remark pulumi.StringPtrOutput `pulumi:"remark"`
// Database status, could be `creating`, `running`, `modifying` which means changing the remark, and `deleting`.
Status pulumi.StringOutput `pulumi:"status"`
}
// NewDb registers a new resource with the given unique name, arguments, and options.
func NewDb(ctx *pulumi.Context,
name string, args *DbArgs, opts ...pulumi.ResourceOption) (*Db, 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 Db
err := ctx.RegisterResource("tencentcloud:Sqlserver/db:Db", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetDb gets an existing Db 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 GetDb(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *DbState, opts ...pulumi.ResourceOption) (*Db, error) {
var resource Db
err := ctx.ReadResource("tencentcloud:Sqlserver/db:Db", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Db resources.
type dbState struct {
// Character set DB uses. Valid values: `Chinese_PRC_CI_AS`, `Chinese_PRC_CS_AS`, `Chinese_PRC_BIN`, `Chinese_Taiwan_Stroke_CI_AS`, `SQL_Latin1_General_CP1_CI_AS`, and `SQL_Latin1_General_CP1_CS_AS`. Default value is `Chinese_PRC_CI_AS`.
Charset *string `pulumi:"charset"`
// Database creation time.
CreateTime *string `pulumi:"createTime"`
// SQL Server instance ID which DB belongs to.
InstanceId *string `pulumi:"instanceId"`
// Name of SQL Server DB. The database name must be unique and must be composed of numbers, letters and underlines, and the first one can not be underline.
Name *string `pulumi:"name"`
// Remark of the DB.
Remark *string `pulumi:"remark"`
// Database status, could be `creating`, `running`, `modifying` which means changing the remark, and `deleting`.
Status *string `pulumi:"status"`
}
type DbState struct {
// Character set DB uses. Valid values: `Chinese_PRC_CI_AS`, `Chinese_PRC_CS_AS`, `Chinese_PRC_BIN`, `Chinese_Taiwan_Stroke_CI_AS`, `SQL_Latin1_General_CP1_CI_AS`, and `SQL_Latin1_General_CP1_CS_AS`. Default value is `Chinese_PRC_CI_AS`.
Charset pulumi.StringPtrInput
// Database creation time.
CreateTime pulumi.StringPtrInput
// SQL Server instance ID which DB belongs to.
InstanceId pulumi.StringPtrInput
// Name of SQL Server DB. The database name must be unique and must be composed of numbers, letters and underlines, and the first one can not be underline.
Name pulumi.StringPtrInput
// Remark of the DB.
Remark pulumi.StringPtrInput
// Database status, could be `creating`, `running`, `modifying` which means changing the remark, and `deleting`.
Status pulumi.StringPtrInput
}
func (DbState) ElementType() reflect.Type {
return reflect.TypeOf((*dbState)(nil)).Elem()
}
type dbArgs struct {
// Character set DB uses. Valid values: `Chinese_PRC_CI_AS`, `Chinese_PRC_CS_AS`, `Chinese_PRC_BIN`, `Chinese_Taiwan_Stroke_CI_AS`, `SQL_Latin1_General_CP1_CI_AS`, and `SQL_Latin1_General_CP1_CS_AS`. Default value is `Chinese_PRC_CI_AS`.
Charset *string `pulumi:"charset"`
// SQL Server instance ID which DB belongs to.
InstanceId string `pulumi:"instanceId"`
// Name of SQL Server DB. The database name must be unique and must be composed of numbers, letters and underlines, and the first one can not be underline.
Name *string `pulumi:"name"`
// Remark of the DB.
Remark *string `pulumi:"remark"`
}
// The set of arguments for constructing a Db resource.
type DbArgs struct {
// Character set DB uses. Valid values: `Chinese_PRC_CI_AS`, `Chinese_PRC_CS_AS`, `Chinese_PRC_BIN`, `Chinese_Taiwan_Stroke_CI_AS`, `SQL_Latin1_General_CP1_CI_AS`, and `SQL_Latin1_General_CP1_CS_AS`. Default value is `Chinese_PRC_CI_AS`.
Charset pulumi.StringPtrInput
// SQL Server instance ID which DB belongs to.
InstanceId pulumi.StringInput
// Name of SQL Server DB. The database name must be unique and must be composed of numbers, letters and underlines, and the first one can not be underline.
Name pulumi.StringPtrInput
// Remark of the DB.
Remark pulumi.StringPtrInput
}
func (DbArgs) ElementType() reflect.Type {
return reflect.TypeOf((*dbArgs)(nil)).Elem()
}
type DbInput interface {
pulumi.Input
ToDbOutput() DbOutput
ToDbOutputWithContext(ctx context.Context) DbOutput
}
func (*Db) ElementType() reflect.Type {
return reflect.TypeOf((**Db)(nil)).Elem()
}
func (i *Db) ToDbOutput() DbOutput {
return i.ToDbOutputWithContext(context.Background())
}
func (i *Db) ToDbOutputWithContext(ctx context.Context) DbOutput {
return pulumi.ToOutputWithContext(ctx, i).(DbOutput)
}
// DbArrayInput is an input type that accepts DbArray and DbArrayOutput values.
// You can construct a concrete instance of `DbArrayInput` via:
//
// DbArray{ DbArgs{...} }
type DbArrayInput interface {
pulumi.Input
ToDbArrayOutput() DbArrayOutput
ToDbArrayOutputWithContext(context.Context) DbArrayOutput
}
type DbArray []DbInput
func (DbArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Db)(nil)).Elem()
}
func (i DbArray) ToDbArrayOutput() DbArrayOutput {
return i.ToDbArrayOutputWithContext(context.Background())
}
func (i DbArray) ToDbArrayOutputWithContext(ctx context.Context) DbArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(DbArrayOutput)
}
// DbMapInput is an input type that accepts DbMap and DbMapOutput values.
// You can construct a concrete instance of `DbMapInput` via:
//
// DbMap{ "key": DbArgs{...} }
type DbMapInput interface {
pulumi.Input
ToDbMapOutput() DbMapOutput
ToDbMapOutputWithContext(context.Context) DbMapOutput
}
type DbMap map[string]DbInput
func (DbMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Db)(nil)).Elem()
}
func (i DbMap) ToDbMapOutput() DbMapOutput {
return i.ToDbMapOutputWithContext(context.Background())
}
func (i DbMap) ToDbMapOutputWithContext(ctx context.Context) DbMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(DbMapOutput)
}
type DbOutput struct{ *pulumi.OutputState }
func (DbOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Db)(nil)).Elem()
}
func (o DbOutput) ToDbOutput() DbOutput {
return o
}
func (o DbOutput) ToDbOutputWithContext(ctx context.Context) DbOutput {
return o
}
// Character set DB uses. Valid values: `Chinese_PRC_CI_AS`, `Chinese_PRC_CS_AS`, `Chinese_PRC_BIN`, `Chinese_Taiwan_Stroke_CI_AS`, `SQL_Latin1_General_CP1_CI_AS`, and `SQL_Latin1_General_CP1_CS_AS`. Default value is `Chinese_PRC_CI_AS`.
func (o DbOutput) Charset() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Db) pulumi.StringPtrOutput { return v.Charset }).(pulumi.StringPtrOutput)
}
// Database creation time.
func (o DbOutput) CreateTime() pulumi.StringOutput {
return o.ApplyT(func(v *Db) pulumi.StringOutput { return v.CreateTime }).(pulumi.StringOutput)
}
// SQL Server instance ID which DB belongs to.
func (o DbOutput) InstanceId() pulumi.StringOutput {
return o.ApplyT(func(v *Db) pulumi.StringOutput { return v.InstanceId }).(pulumi.StringOutput)
}
// Name of SQL Server DB. The database name must be unique and must be composed of numbers, letters and underlines, and the first one can not be underline.
func (o DbOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *Db) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// Remark of the DB.
func (o DbOutput) Remark() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Db) pulumi.StringPtrOutput { return v.Remark }).(pulumi.StringPtrOutput)
}
// Database status, could be `creating`, `running`, `modifying` which means changing the remark, and `deleting`.
func (o DbOutput) Status() pulumi.StringOutput {
return o.ApplyT(func(v *Db) pulumi.StringOutput { return v.Status }).(pulumi.StringOutput)
}
type DbArrayOutput struct{ *pulumi.OutputState }
func (DbArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Db)(nil)).Elem()
}
func (o DbArrayOutput) ToDbArrayOutput() DbArrayOutput {
return o
}
func (o DbArrayOutput) ToDbArrayOutputWithContext(ctx context.Context) DbArrayOutput {
return o
}
func (o DbArrayOutput) Index(i pulumi.IntInput) DbOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Db {
return vs[0].([]*Db)[vs[1].(int)]
}).(DbOutput)
}
type DbMapOutput struct{ *pulumi.OutputState }
func (DbMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Db)(nil)).Elem()
}
func (o DbMapOutput) ToDbMapOutput() DbMapOutput {
return o
}
func (o DbMapOutput) ToDbMapOutputWithContext(ctx context.Context) DbMapOutput {
return o
}
func (o DbMapOutput) MapIndex(k pulumi.StringInput) DbOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Db {
return vs[0].(map[string]*Db)[vs[1].(string)]
}).(DbOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*DbInput)(nil)).Elem(), &Db{})
pulumi.RegisterInputType(reflect.TypeOf((*DbArrayInput)(nil)).Elem(), DbArray{})
pulumi.RegisterInputType(reflect.TypeOf((*DbMapInput)(nil)).Elem(), DbMap{})
pulumi.RegisterOutputType(DbOutput{})
pulumi.RegisterOutputType(DbArrayOutput{})
pulumi.RegisterOutputType(DbMapOutput{})
}