generated from pulumi/pulumi-tf-provider-boilerplate
/
functionCron.go
397 lines (345 loc) · 13.2 KB
/
functionCron.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
// 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 serverless
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/raeumlich/pulumi-scaleway/sdk/go/scaleway/internal"
)
// Creates and manages Scaleway Function Triggers. For the moment, the feature is limited to CRON Schedule (time-based).
//
// For more details about the limitation
// check [functions-limitations](https://www.scaleway.com/en/docs/compute/functions/reference-content/functions-limitations/).
//
// You can check also
// our [functions cron api documentation](https://developers.scaleway.com/en/products/functions/api/#crons-942bf4).
//
// ## Example Usage
//
// <!--Start PulumiCodeChooser -->
// ```go
// package main
//
// import (
//
// "encoding/json"
//
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// "github.com/raeumlich/pulumi-scaleway/sdk/go/scaleway/serverless"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// mainFunctionNamespace, err := serverless.NewFunctionNamespace(ctx, "mainFunctionNamespace", nil)
// if err != nil {
// return err
// }
// mainFunction, err := serverless.NewFunction(ctx, "mainFunction", &serverless.FunctionArgs{
// NamespaceId: mainFunctionNamespace.ID(),
// Runtime: pulumi.String("node14"),
// Privacy: pulumi.String("private"),
// Handler: pulumi.String("handler.handle"),
// })
// if err != nil {
// return err
// }
// tmpJSON0, err := json.Marshal(map[string]interface{}{
// "test": "scw",
// })
// if err != nil {
// return err
// }
// json0 := string(tmpJSON0)
// _, err = serverless.NewFunctionCron(ctx, "mainFunctionCron", &serverless.FunctionCronArgs{
// FunctionId: mainFunction.ID(),
// Schedule: pulumi.String("0 0 * * *"),
// Args: pulumi.String(json0),
// })
// if err != nil {
// return err
// }
// tmpJSON1, err := json.Marshal(map[string]interface{}{
// "my_var": "terraform",
// })
// if err != nil {
// return err
// }
// json1 := string(tmpJSON1)
// _, err = serverless.NewFunctionCron(ctx, "func", &serverless.FunctionCronArgs{
// FunctionId: mainFunction.ID(),
// Schedule: pulumi.String("0 1 * * *"),
// Args: pulumi.String(json1),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
//
// ## Import
//
// Container Cron can be imported using the `{region}/{id}`, e.g.
//
// bash
//
// ```sh
// $ pulumi import scaleway:serverless/functionCron:FunctionCron main fr-par/11111111-1111-1111-1111-111111111111
// ```
type FunctionCron struct {
pulumi.CustomResourceState
// The key-value mapping to define arguments that will be passed to your function’s event object
// during
Args pulumi.StringOutput `pulumi:"args"`
// The function ID to link with your cron.
FunctionId pulumi.StringOutput `pulumi:"functionId"`
// The name of the cron. If not provided, the name is generated.
Name pulumi.StringOutput `pulumi:"name"`
// `region`) The region
// in where the job was created.
Region pulumi.StringOutput `pulumi:"region"`
// Cron format string, e.g. @hourly, as schedule time of its jobs to be created and
// executed.
Schedule pulumi.StringOutput `pulumi:"schedule"`
// The cron status.
Status pulumi.StringOutput `pulumi:"status"`
}
// NewFunctionCron registers a new resource with the given unique name, arguments, and options.
func NewFunctionCron(ctx *pulumi.Context,
name string, args *FunctionCronArgs, opts ...pulumi.ResourceOption) (*FunctionCron, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Args == nil {
return nil, errors.New("invalid value for required argument 'Args'")
}
if args.FunctionId == nil {
return nil, errors.New("invalid value for required argument 'FunctionId'")
}
if args.Schedule == nil {
return nil, errors.New("invalid value for required argument 'Schedule'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource FunctionCron
err := ctx.RegisterResource("scaleway:serverless/functionCron:FunctionCron", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetFunctionCron gets an existing FunctionCron 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 GetFunctionCron(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *FunctionCronState, opts ...pulumi.ResourceOption) (*FunctionCron, error) {
var resource FunctionCron
err := ctx.ReadResource("scaleway:serverless/functionCron:FunctionCron", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering FunctionCron resources.
type functionCronState struct {
// The key-value mapping to define arguments that will be passed to your function’s event object
// during
Args *string `pulumi:"args"`
// The function ID to link with your cron.
FunctionId *string `pulumi:"functionId"`
// The name of the cron. If not provided, the name is generated.
Name *string `pulumi:"name"`
// `region`) The region
// in where the job was created.
Region *string `pulumi:"region"`
// Cron format string, e.g. @hourly, as schedule time of its jobs to be created and
// executed.
Schedule *string `pulumi:"schedule"`
// The cron status.
Status *string `pulumi:"status"`
}
type FunctionCronState struct {
// The key-value mapping to define arguments that will be passed to your function’s event object
// during
Args pulumi.StringPtrInput
// The function ID to link with your cron.
FunctionId pulumi.StringPtrInput
// The name of the cron. If not provided, the name is generated.
Name pulumi.StringPtrInput
// `region`) The region
// in where the job was created.
Region pulumi.StringPtrInput
// Cron format string, e.g. @hourly, as schedule time of its jobs to be created and
// executed.
Schedule pulumi.StringPtrInput
// The cron status.
Status pulumi.StringPtrInput
}
func (FunctionCronState) ElementType() reflect.Type {
return reflect.TypeOf((*functionCronState)(nil)).Elem()
}
type functionCronArgs struct {
// The key-value mapping to define arguments that will be passed to your function’s event object
// during
Args string `pulumi:"args"`
// The function ID to link with your cron.
FunctionId string `pulumi:"functionId"`
// The name of the cron. If not provided, the name is generated.
Name *string `pulumi:"name"`
// `region`) The region
// in where the job was created.
Region *string `pulumi:"region"`
// Cron format string, e.g. @hourly, as schedule time of its jobs to be created and
// executed.
Schedule string `pulumi:"schedule"`
}
// The set of arguments for constructing a FunctionCron resource.
type FunctionCronArgs struct {
// The key-value mapping to define arguments that will be passed to your function’s event object
// during
Args pulumi.StringInput
// The function ID to link with your cron.
FunctionId pulumi.StringInput
// The name of the cron. If not provided, the name is generated.
Name pulumi.StringPtrInput
// `region`) The region
// in where the job was created.
Region pulumi.StringPtrInput
// Cron format string, e.g. @hourly, as schedule time of its jobs to be created and
// executed.
Schedule pulumi.StringInput
}
func (FunctionCronArgs) ElementType() reflect.Type {
return reflect.TypeOf((*functionCronArgs)(nil)).Elem()
}
type FunctionCronInput interface {
pulumi.Input
ToFunctionCronOutput() FunctionCronOutput
ToFunctionCronOutputWithContext(ctx context.Context) FunctionCronOutput
}
func (*FunctionCron) ElementType() reflect.Type {
return reflect.TypeOf((**FunctionCron)(nil)).Elem()
}
func (i *FunctionCron) ToFunctionCronOutput() FunctionCronOutput {
return i.ToFunctionCronOutputWithContext(context.Background())
}
func (i *FunctionCron) ToFunctionCronOutputWithContext(ctx context.Context) FunctionCronOutput {
return pulumi.ToOutputWithContext(ctx, i).(FunctionCronOutput)
}
// FunctionCronArrayInput is an input type that accepts FunctionCronArray and FunctionCronArrayOutput values.
// You can construct a concrete instance of `FunctionCronArrayInput` via:
//
// FunctionCronArray{ FunctionCronArgs{...} }
type FunctionCronArrayInput interface {
pulumi.Input
ToFunctionCronArrayOutput() FunctionCronArrayOutput
ToFunctionCronArrayOutputWithContext(context.Context) FunctionCronArrayOutput
}
type FunctionCronArray []FunctionCronInput
func (FunctionCronArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*FunctionCron)(nil)).Elem()
}
func (i FunctionCronArray) ToFunctionCronArrayOutput() FunctionCronArrayOutput {
return i.ToFunctionCronArrayOutputWithContext(context.Background())
}
func (i FunctionCronArray) ToFunctionCronArrayOutputWithContext(ctx context.Context) FunctionCronArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(FunctionCronArrayOutput)
}
// FunctionCronMapInput is an input type that accepts FunctionCronMap and FunctionCronMapOutput values.
// You can construct a concrete instance of `FunctionCronMapInput` via:
//
// FunctionCronMap{ "key": FunctionCronArgs{...} }
type FunctionCronMapInput interface {
pulumi.Input
ToFunctionCronMapOutput() FunctionCronMapOutput
ToFunctionCronMapOutputWithContext(context.Context) FunctionCronMapOutput
}
type FunctionCronMap map[string]FunctionCronInput
func (FunctionCronMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*FunctionCron)(nil)).Elem()
}
func (i FunctionCronMap) ToFunctionCronMapOutput() FunctionCronMapOutput {
return i.ToFunctionCronMapOutputWithContext(context.Background())
}
func (i FunctionCronMap) ToFunctionCronMapOutputWithContext(ctx context.Context) FunctionCronMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(FunctionCronMapOutput)
}
type FunctionCronOutput struct{ *pulumi.OutputState }
func (FunctionCronOutput) ElementType() reflect.Type {
return reflect.TypeOf((**FunctionCron)(nil)).Elem()
}
func (o FunctionCronOutput) ToFunctionCronOutput() FunctionCronOutput {
return o
}
func (o FunctionCronOutput) ToFunctionCronOutputWithContext(ctx context.Context) FunctionCronOutput {
return o
}
// The key-value mapping to define arguments that will be passed to your function’s event object
// during
func (o FunctionCronOutput) Args() pulumi.StringOutput {
return o.ApplyT(func(v *FunctionCron) pulumi.StringOutput { return v.Args }).(pulumi.StringOutput)
}
// The function ID to link with your cron.
func (o FunctionCronOutput) FunctionId() pulumi.StringOutput {
return o.ApplyT(func(v *FunctionCron) pulumi.StringOutput { return v.FunctionId }).(pulumi.StringOutput)
}
// The name of the cron. If not provided, the name is generated.
func (o FunctionCronOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *FunctionCron) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// `region`) The region
// in where the job was created.
func (o FunctionCronOutput) Region() pulumi.StringOutput {
return o.ApplyT(func(v *FunctionCron) pulumi.StringOutput { return v.Region }).(pulumi.StringOutput)
}
// Cron format string, e.g. @hourly, as schedule time of its jobs to be created and
// executed.
func (o FunctionCronOutput) Schedule() pulumi.StringOutput {
return o.ApplyT(func(v *FunctionCron) pulumi.StringOutput { return v.Schedule }).(pulumi.StringOutput)
}
// The cron status.
func (o FunctionCronOutput) Status() pulumi.StringOutput {
return o.ApplyT(func(v *FunctionCron) pulumi.StringOutput { return v.Status }).(pulumi.StringOutput)
}
type FunctionCronArrayOutput struct{ *pulumi.OutputState }
func (FunctionCronArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*FunctionCron)(nil)).Elem()
}
func (o FunctionCronArrayOutput) ToFunctionCronArrayOutput() FunctionCronArrayOutput {
return o
}
func (o FunctionCronArrayOutput) ToFunctionCronArrayOutputWithContext(ctx context.Context) FunctionCronArrayOutput {
return o
}
func (o FunctionCronArrayOutput) Index(i pulumi.IntInput) FunctionCronOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *FunctionCron {
return vs[0].([]*FunctionCron)[vs[1].(int)]
}).(FunctionCronOutput)
}
type FunctionCronMapOutput struct{ *pulumi.OutputState }
func (FunctionCronMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*FunctionCron)(nil)).Elem()
}
func (o FunctionCronMapOutput) ToFunctionCronMapOutput() FunctionCronMapOutput {
return o
}
func (o FunctionCronMapOutput) ToFunctionCronMapOutputWithContext(ctx context.Context) FunctionCronMapOutput {
return o
}
func (o FunctionCronMapOutput) MapIndex(k pulumi.StringInput) FunctionCronOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *FunctionCron {
return vs[0].(map[string]*FunctionCron)[vs[1].(string)]
}).(FunctionCronOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*FunctionCronInput)(nil)).Elem(), &FunctionCron{})
pulumi.RegisterInputType(reflect.TypeOf((*FunctionCronArrayInput)(nil)).Elem(), FunctionCronArray{})
pulumi.RegisterInputType(reflect.TypeOf((*FunctionCronMapInput)(nil)).Elem(), FunctionCronMap{})
pulumi.RegisterOutputType(FunctionCronOutput{})
pulumi.RegisterOutputType(FunctionCronArrayOutput{})
pulumi.RegisterOutputType(FunctionCronMapOutput{})
}