/
mongoCollection.go
422 lines (365 loc) · 20.7 KB
/
mongoCollection.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
// 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 cosmosdb
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Manages a Mongo Collection within a Cosmos DB Account.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/cosmosdb"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// example, err := cosmosdb.LookupAccount(ctx, &cosmosdb.LookupAccountArgs{
// Name: "tfex-cosmosdb-account",
// ResourceGroupName: "tfex-cosmosdb-account-rg",
// }, nil)
// if err != nil {
// return err
// }
// exampleMongoDatabase, err := cosmosdb.NewMongoDatabase(ctx, "example", &cosmosdb.MongoDatabaseArgs{
// Name: pulumi.String("tfex-cosmos-mongo-db"),
// ResourceGroupName: pulumi.String(example.ResourceGroupName),
// AccountName: pulumi.String(example.Name),
// })
// if err != nil {
// return err
// }
// _, err = cosmosdb.NewMongoCollection(ctx, "example", &cosmosdb.MongoCollectionArgs{
// Name: pulumi.String("tfex-cosmos-mongo-db"),
// ResourceGroupName: pulumi.String(example.ResourceGroupName),
// AccountName: pulumi.String(example.Name),
// DatabaseName: exampleMongoDatabase.Name,
// DefaultTtlSeconds: pulumi.Int(777),
// ShardKey: pulumi.String("uniqueKey"),
// Throughput: pulumi.Int(400),
// Indices: cosmosdb.MongoCollectionIndexArray{
// &cosmosdb.MongoCollectionIndexArgs{
// Keys: pulumi.StringArray{
// pulumi.String("_id"),
// },
// Unique: pulumi.Bool(true),
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// CosmosDB Mongo Collection can be imported using the `resource id`, e.g.
//
// ```sh
// $ pulumi import azure:cosmosdb/mongoCollection:MongoCollection collection1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/account1/mongodbDatabases/db1/collections/collection1
// ```
type MongoCollection struct {
pulumi.CustomResourceState
// The name of the Cosmos DB Account in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.
AccountName pulumi.StringOutput `pulumi:"accountName"`
// The default time to live of Analytical Storage for this Mongo Collection. If present and the value is set to `-1`, it is equal to infinity, and items don’t expire by default. If present and the value is set to some number `n` – items will expire `n` seconds after their last modified time.
AnalyticalStorageTtl pulumi.IntPtrOutput `pulumi:"analyticalStorageTtl"`
AutoscaleSettings MongoCollectionAutoscaleSettingsPtrOutput `pulumi:"autoscaleSettings"`
// The name of the Cosmos DB Mongo Database in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.
DatabaseName pulumi.StringOutput `pulumi:"databaseName"`
// The default Time To Live in seconds. If the value is `-1`, items are not automatically expired.
DefaultTtlSeconds pulumi.IntPtrOutput `pulumi:"defaultTtlSeconds"`
// One or more `index` blocks as defined below.
Indices MongoCollectionIndexArrayOutput `pulumi:"indices"`
// Specifies the name of the Cosmos DB Mongo Collection. Changing this forces a new resource to be created.
Name pulumi.StringOutput `pulumi:"name"`
// The name of the resource group in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.
ResourceGroupName pulumi.StringOutput `pulumi:"resourceGroupName"`
// The name of the key to partition on for sharding. There must not be any other unique index keys. Changing this forces a new resource to be created.
ShardKey pulumi.StringPtrOutput `pulumi:"shardKey"`
// One or more `systemIndexes` blocks as defined below.
SystemIndexes MongoCollectionSystemIndexArrayOutput `pulumi:"systemIndexes"`
Throughput pulumi.IntOutput `pulumi:"throughput"`
}
// NewMongoCollection registers a new resource with the given unique name, arguments, and options.
func NewMongoCollection(ctx *pulumi.Context,
name string, args *MongoCollectionArgs, opts ...pulumi.ResourceOption) (*MongoCollection, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.AccountName == nil {
return nil, errors.New("invalid value for required argument 'AccountName'")
}
if args.DatabaseName == nil {
return nil, errors.New("invalid value for required argument 'DatabaseName'")
}
if args.ResourceGroupName == nil {
return nil, errors.New("invalid value for required argument 'ResourceGroupName'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource MongoCollection
err := ctx.RegisterResource("azure:cosmosdb/mongoCollection:MongoCollection", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetMongoCollection gets an existing MongoCollection 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 GetMongoCollection(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *MongoCollectionState, opts ...pulumi.ResourceOption) (*MongoCollection, error) {
var resource MongoCollection
err := ctx.ReadResource("azure:cosmosdb/mongoCollection:MongoCollection", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering MongoCollection resources.
type mongoCollectionState struct {
// The name of the Cosmos DB Account in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.
AccountName *string `pulumi:"accountName"`
// The default time to live of Analytical Storage for this Mongo Collection. If present and the value is set to `-1`, it is equal to infinity, and items don’t expire by default. If present and the value is set to some number `n` – items will expire `n` seconds after their last modified time.
AnalyticalStorageTtl *int `pulumi:"analyticalStorageTtl"`
AutoscaleSettings *MongoCollectionAutoscaleSettings `pulumi:"autoscaleSettings"`
// The name of the Cosmos DB Mongo Database in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.
DatabaseName *string `pulumi:"databaseName"`
// The default Time To Live in seconds. If the value is `-1`, items are not automatically expired.
DefaultTtlSeconds *int `pulumi:"defaultTtlSeconds"`
// One or more `index` blocks as defined below.
Indices []MongoCollectionIndex `pulumi:"indices"`
// Specifies the name of the Cosmos DB Mongo Collection. Changing this forces a new resource to be created.
Name *string `pulumi:"name"`
// The name of the resource group in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.
ResourceGroupName *string `pulumi:"resourceGroupName"`
// The name of the key to partition on for sharding. There must not be any other unique index keys. Changing this forces a new resource to be created.
ShardKey *string `pulumi:"shardKey"`
// One or more `systemIndexes` blocks as defined below.
SystemIndexes []MongoCollectionSystemIndex `pulumi:"systemIndexes"`
Throughput *int `pulumi:"throughput"`
}
type MongoCollectionState struct {
// The name of the Cosmos DB Account in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.
AccountName pulumi.StringPtrInput
// The default time to live of Analytical Storage for this Mongo Collection. If present and the value is set to `-1`, it is equal to infinity, and items don’t expire by default. If present and the value is set to some number `n` – items will expire `n` seconds after their last modified time.
AnalyticalStorageTtl pulumi.IntPtrInput
AutoscaleSettings MongoCollectionAutoscaleSettingsPtrInput
// The name of the Cosmos DB Mongo Database in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.
DatabaseName pulumi.StringPtrInput
// The default Time To Live in seconds. If the value is `-1`, items are not automatically expired.
DefaultTtlSeconds pulumi.IntPtrInput
// One or more `index` blocks as defined below.
Indices MongoCollectionIndexArrayInput
// Specifies the name of the Cosmos DB Mongo Collection. Changing this forces a new resource to be created.
Name pulumi.StringPtrInput
// The name of the resource group in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.
ResourceGroupName pulumi.StringPtrInput
// The name of the key to partition on for sharding. There must not be any other unique index keys. Changing this forces a new resource to be created.
ShardKey pulumi.StringPtrInput
// One or more `systemIndexes` blocks as defined below.
SystemIndexes MongoCollectionSystemIndexArrayInput
Throughput pulumi.IntPtrInput
}
func (MongoCollectionState) ElementType() reflect.Type {
return reflect.TypeOf((*mongoCollectionState)(nil)).Elem()
}
type mongoCollectionArgs struct {
// The name of the Cosmos DB Account in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.
AccountName string `pulumi:"accountName"`
// The default time to live of Analytical Storage for this Mongo Collection. If present and the value is set to `-1`, it is equal to infinity, and items don’t expire by default. If present and the value is set to some number `n` – items will expire `n` seconds after their last modified time.
AnalyticalStorageTtl *int `pulumi:"analyticalStorageTtl"`
AutoscaleSettings *MongoCollectionAutoscaleSettings `pulumi:"autoscaleSettings"`
// The name of the Cosmos DB Mongo Database in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.
DatabaseName string `pulumi:"databaseName"`
// The default Time To Live in seconds. If the value is `-1`, items are not automatically expired.
DefaultTtlSeconds *int `pulumi:"defaultTtlSeconds"`
// One or more `index` blocks as defined below.
Indices []MongoCollectionIndex `pulumi:"indices"`
// Specifies the name of the Cosmos DB Mongo Collection. Changing this forces a new resource to be created.
Name *string `pulumi:"name"`
// The name of the resource group in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.
ResourceGroupName string `pulumi:"resourceGroupName"`
// The name of the key to partition on for sharding. There must not be any other unique index keys. Changing this forces a new resource to be created.
ShardKey *string `pulumi:"shardKey"`
Throughput *int `pulumi:"throughput"`
}
// The set of arguments for constructing a MongoCollection resource.
type MongoCollectionArgs struct {
// The name of the Cosmos DB Account in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.
AccountName pulumi.StringInput
// The default time to live of Analytical Storage for this Mongo Collection. If present and the value is set to `-1`, it is equal to infinity, and items don’t expire by default. If present and the value is set to some number `n` – items will expire `n` seconds after their last modified time.
AnalyticalStorageTtl pulumi.IntPtrInput
AutoscaleSettings MongoCollectionAutoscaleSettingsPtrInput
// The name of the Cosmos DB Mongo Database in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.
DatabaseName pulumi.StringInput
// The default Time To Live in seconds. If the value is `-1`, items are not automatically expired.
DefaultTtlSeconds pulumi.IntPtrInput
// One or more `index` blocks as defined below.
Indices MongoCollectionIndexArrayInput
// Specifies the name of the Cosmos DB Mongo Collection. Changing this forces a new resource to be created.
Name pulumi.StringPtrInput
// The name of the resource group in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.
ResourceGroupName pulumi.StringInput
// The name of the key to partition on for sharding. There must not be any other unique index keys. Changing this forces a new resource to be created.
ShardKey pulumi.StringPtrInput
Throughput pulumi.IntPtrInput
}
func (MongoCollectionArgs) ElementType() reflect.Type {
return reflect.TypeOf((*mongoCollectionArgs)(nil)).Elem()
}
type MongoCollectionInput interface {
pulumi.Input
ToMongoCollectionOutput() MongoCollectionOutput
ToMongoCollectionOutputWithContext(ctx context.Context) MongoCollectionOutput
}
func (*MongoCollection) ElementType() reflect.Type {
return reflect.TypeOf((**MongoCollection)(nil)).Elem()
}
func (i *MongoCollection) ToMongoCollectionOutput() MongoCollectionOutput {
return i.ToMongoCollectionOutputWithContext(context.Background())
}
func (i *MongoCollection) ToMongoCollectionOutputWithContext(ctx context.Context) MongoCollectionOutput {
return pulumi.ToOutputWithContext(ctx, i).(MongoCollectionOutput)
}
// MongoCollectionArrayInput is an input type that accepts MongoCollectionArray and MongoCollectionArrayOutput values.
// You can construct a concrete instance of `MongoCollectionArrayInput` via:
//
// MongoCollectionArray{ MongoCollectionArgs{...} }
type MongoCollectionArrayInput interface {
pulumi.Input
ToMongoCollectionArrayOutput() MongoCollectionArrayOutput
ToMongoCollectionArrayOutputWithContext(context.Context) MongoCollectionArrayOutput
}
type MongoCollectionArray []MongoCollectionInput
func (MongoCollectionArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*MongoCollection)(nil)).Elem()
}
func (i MongoCollectionArray) ToMongoCollectionArrayOutput() MongoCollectionArrayOutput {
return i.ToMongoCollectionArrayOutputWithContext(context.Background())
}
func (i MongoCollectionArray) ToMongoCollectionArrayOutputWithContext(ctx context.Context) MongoCollectionArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(MongoCollectionArrayOutput)
}
// MongoCollectionMapInput is an input type that accepts MongoCollectionMap and MongoCollectionMapOutput values.
// You can construct a concrete instance of `MongoCollectionMapInput` via:
//
// MongoCollectionMap{ "key": MongoCollectionArgs{...} }
type MongoCollectionMapInput interface {
pulumi.Input
ToMongoCollectionMapOutput() MongoCollectionMapOutput
ToMongoCollectionMapOutputWithContext(context.Context) MongoCollectionMapOutput
}
type MongoCollectionMap map[string]MongoCollectionInput
func (MongoCollectionMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*MongoCollection)(nil)).Elem()
}
func (i MongoCollectionMap) ToMongoCollectionMapOutput() MongoCollectionMapOutput {
return i.ToMongoCollectionMapOutputWithContext(context.Background())
}
func (i MongoCollectionMap) ToMongoCollectionMapOutputWithContext(ctx context.Context) MongoCollectionMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(MongoCollectionMapOutput)
}
type MongoCollectionOutput struct{ *pulumi.OutputState }
func (MongoCollectionOutput) ElementType() reflect.Type {
return reflect.TypeOf((**MongoCollection)(nil)).Elem()
}
func (o MongoCollectionOutput) ToMongoCollectionOutput() MongoCollectionOutput {
return o
}
func (o MongoCollectionOutput) ToMongoCollectionOutputWithContext(ctx context.Context) MongoCollectionOutput {
return o
}
// The name of the Cosmos DB Account in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.
func (o MongoCollectionOutput) AccountName() pulumi.StringOutput {
return o.ApplyT(func(v *MongoCollection) pulumi.StringOutput { return v.AccountName }).(pulumi.StringOutput)
}
// The default time to live of Analytical Storage for this Mongo Collection. If present and the value is set to `-1`, it is equal to infinity, and items don’t expire by default. If present and the value is set to some number `n` – items will expire `n` seconds after their last modified time.
func (o MongoCollectionOutput) AnalyticalStorageTtl() pulumi.IntPtrOutput {
return o.ApplyT(func(v *MongoCollection) pulumi.IntPtrOutput { return v.AnalyticalStorageTtl }).(pulumi.IntPtrOutput)
}
func (o MongoCollectionOutput) AutoscaleSettings() MongoCollectionAutoscaleSettingsPtrOutput {
return o.ApplyT(func(v *MongoCollection) MongoCollectionAutoscaleSettingsPtrOutput { return v.AutoscaleSettings }).(MongoCollectionAutoscaleSettingsPtrOutput)
}
// The name of the Cosmos DB Mongo Database in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.
func (o MongoCollectionOutput) DatabaseName() pulumi.StringOutput {
return o.ApplyT(func(v *MongoCollection) pulumi.StringOutput { return v.DatabaseName }).(pulumi.StringOutput)
}
// The default Time To Live in seconds. If the value is `-1`, items are not automatically expired.
func (o MongoCollectionOutput) DefaultTtlSeconds() pulumi.IntPtrOutput {
return o.ApplyT(func(v *MongoCollection) pulumi.IntPtrOutput { return v.DefaultTtlSeconds }).(pulumi.IntPtrOutput)
}
// One or more `index` blocks as defined below.
func (o MongoCollectionOutput) Indices() MongoCollectionIndexArrayOutput {
return o.ApplyT(func(v *MongoCollection) MongoCollectionIndexArrayOutput { return v.Indices }).(MongoCollectionIndexArrayOutput)
}
// Specifies the name of the Cosmos DB Mongo Collection. Changing this forces a new resource to be created.
func (o MongoCollectionOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *MongoCollection) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// The name of the resource group in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.
func (o MongoCollectionOutput) ResourceGroupName() pulumi.StringOutput {
return o.ApplyT(func(v *MongoCollection) pulumi.StringOutput { return v.ResourceGroupName }).(pulumi.StringOutput)
}
// The name of the key to partition on for sharding. There must not be any other unique index keys. Changing this forces a new resource to be created.
func (o MongoCollectionOutput) ShardKey() pulumi.StringPtrOutput {
return o.ApplyT(func(v *MongoCollection) pulumi.StringPtrOutput { return v.ShardKey }).(pulumi.StringPtrOutput)
}
// One or more `systemIndexes` blocks as defined below.
func (o MongoCollectionOutput) SystemIndexes() MongoCollectionSystemIndexArrayOutput {
return o.ApplyT(func(v *MongoCollection) MongoCollectionSystemIndexArrayOutput { return v.SystemIndexes }).(MongoCollectionSystemIndexArrayOutput)
}
func (o MongoCollectionOutput) Throughput() pulumi.IntOutput {
return o.ApplyT(func(v *MongoCollection) pulumi.IntOutput { return v.Throughput }).(pulumi.IntOutput)
}
type MongoCollectionArrayOutput struct{ *pulumi.OutputState }
func (MongoCollectionArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*MongoCollection)(nil)).Elem()
}
func (o MongoCollectionArrayOutput) ToMongoCollectionArrayOutput() MongoCollectionArrayOutput {
return o
}
func (o MongoCollectionArrayOutput) ToMongoCollectionArrayOutputWithContext(ctx context.Context) MongoCollectionArrayOutput {
return o
}
func (o MongoCollectionArrayOutput) Index(i pulumi.IntInput) MongoCollectionOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *MongoCollection {
return vs[0].([]*MongoCollection)[vs[1].(int)]
}).(MongoCollectionOutput)
}
type MongoCollectionMapOutput struct{ *pulumi.OutputState }
func (MongoCollectionMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*MongoCollection)(nil)).Elem()
}
func (o MongoCollectionMapOutput) ToMongoCollectionMapOutput() MongoCollectionMapOutput {
return o
}
func (o MongoCollectionMapOutput) ToMongoCollectionMapOutputWithContext(ctx context.Context) MongoCollectionMapOutput {
return o
}
func (o MongoCollectionMapOutput) MapIndex(k pulumi.StringInput) MongoCollectionOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *MongoCollection {
return vs[0].(map[string]*MongoCollection)[vs[1].(string)]
}).(MongoCollectionOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*MongoCollectionInput)(nil)).Elem(), &MongoCollection{})
pulumi.RegisterInputType(reflect.TypeOf((*MongoCollectionArrayInput)(nil)).Elem(), MongoCollectionArray{})
pulumi.RegisterInputType(reflect.TypeOf((*MongoCollectionMapInput)(nil)).Elem(), MongoCollectionMap{})
pulumi.RegisterOutputType(MongoCollectionOutput{})
pulumi.RegisterOutputType(MongoCollectionArrayOutput{})
pulumi.RegisterOutputType(MongoCollectionMapOutput{})
}