/
workflow.go
436 lines (375 loc) · 16.7 KB
/
workflow.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
424
425
426
427
428
429
430
431
432
433
434
435
436
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package workflows
import (
"context"
"reflect"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Workflow program to be executed by Workflows.
//
// To get more information about Workflow, see:
//
// * [API documentation](https://cloud.google.com/workflows/docs/reference/rest/v1/projects.locations.workflows)
// * How-to Guides
// * [Managing Workflows](https://cloud.google.com/workflows/docs/creating-updating-workflow)
//
// ## Example Usage
// ### Workflow Basic
//
// ```go
// package main
//
// import (
// "fmt"
//
// "github.com/pulumi/pulumi-gcp/sdk/v5/go/gcp/serviceAccount"
// "github.com/pulumi/pulumi-gcp/sdk/v5/go/gcp/workflows"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// testAccount, err := serviceAccount.NewAccount(ctx, "testAccount", &serviceAccount.AccountArgs{
// AccountId: pulumi.String("my-account"),
// DisplayName: pulumi.String("Test Service Account"),
// })
// if err != nil {
// return err
// }
// _, err = workflows.NewWorkflow(ctx, "example", &workflows.WorkflowArgs{
// Region: pulumi.String("us-central1"),
// Description: pulumi.String("Magic"),
// ServiceAccount: testAccount.ID(),
// SourceContents: pulumi.String(fmt.Sprintf("%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v", "# This is a sample workflow, feel free to replace it with your source code\n", "#\n", "# This workflow does the following:\n", "# - reads current time and date information from an external API and stores\n", "# the response in CurrentDateTime variable\n", "# - retrieves a list of Wikipedia articles related to the day of the week\n", "# from CurrentDateTime\n", "# - returns the list of articles as an output of the workflow\n", "# FYI, In terraform you need to escape the ", "$", "$", " or it will cause errors.\n", "\n", "- getCurrentTime:\n", " call: http.get\n", " args:\n", " url: https://us-central1-workflowsample.cloudfunctions.net/datetime\n", " result: CurrentDateTime\n", "- readWikipedia:\n", " call: http.get\n", " args:\n", " url: https://en.wikipedia.org/w/api.php\n", " query:\n", " action: opensearch\n", " search: ", CurrentDateTime.Body.DayOfTheWeek, "\n", " result: WikiResult\n", "- returnOutput:\n", " return: ", WikiResult.Body[1], "\n")),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// This resource does not support import.
type Workflow struct {
pulumi.CustomResourceState
// The timestamp of when the workflow was created in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine
// fractional digits.
CreateTime pulumi.StringOutput `pulumi:"createTime"`
// Description of the workflow provided by the user. Must be at most 1000 unicode characters long.
Description pulumi.StringOutput `pulumi:"description"`
// A set of key/value label pairs to assign to this Workflow.
Labels pulumi.StringMapOutput `pulumi:"labels"`
// Name of the Workflow.
Name pulumi.StringOutput `pulumi:"name"`
// Creates a unique name beginning with the
// specified prefix. If this and name are unspecified, a random value is chosen for the name.
NamePrefix pulumi.StringOutput `pulumi:"namePrefix"`
// The ID of the project in which the resource belongs.
// If it is not provided, the provider project is used.
Project pulumi.StringOutput `pulumi:"project"`
// The region of the workflow.
Region pulumi.StringPtrOutput `pulumi:"region"`
// The revision of the workflow. A new one is generated if the service account or source contents is changed.
RevisionId pulumi.StringOutput `pulumi:"revisionId"`
// Name of the service account associated with the latest workflow version. This service
// account represents the identity of the workflow and determines what permissions the workflow has.
// Format: projects/{project}/serviceAccounts/{account}.
ServiceAccount pulumi.StringOutput `pulumi:"serviceAccount"`
// Workflow code to be executed. The size limit is 32KB.
SourceContents pulumi.StringPtrOutput `pulumi:"sourceContents"`
// State of the workflow deployment.
State pulumi.StringOutput `pulumi:"state"`
// The timestamp of when the workflow was last updated in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to
// nine fractional digits.
UpdateTime pulumi.StringOutput `pulumi:"updateTime"`
}
// NewWorkflow registers a new resource with the given unique name, arguments, and options.
func NewWorkflow(ctx *pulumi.Context,
name string, args *WorkflowArgs, opts ...pulumi.ResourceOption) (*Workflow, error) {
if args == nil {
args = &WorkflowArgs{}
}
var resource Workflow
err := ctx.RegisterResource("gcp:workflows/workflow:Workflow", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetWorkflow gets an existing Workflow 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 GetWorkflow(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *WorkflowState, opts ...pulumi.ResourceOption) (*Workflow, error) {
var resource Workflow
err := ctx.ReadResource("gcp:workflows/workflow:Workflow", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Workflow resources.
type workflowState struct {
// The timestamp of when the workflow was created in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine
// fractional digits.
CreateTime *string `pulumi:"createTime"`
// Description of the workflow provided by the user. Must be at most 1000 unicode characters long.
Description *string `pulumi:"description"`
// A set of key/value label pairs to assign to this Workflow.
Labels map[string]string `pulumi:"labels"`
// Name of the Workflow.
Name *string `pulumi:"name"`
// Creates a unique name beginning with the
// specified prefix. If this and name are unspecified, a random value is chosen for the name.
NamePrefix *string `pulumi:"namePrefix"`
// The ID of the project in which the resource belongs.
// If it is not provided, the provider project is used.
Project *string `pulumi:"project"`
// The region of the workflow.
Region *string `pulumi:"region"`
// The revision of the workflow. A new one is generated if the service account or source contents is changed.
RevisionId *string `pulumi:"revisionId"`
// Name of the service account associated with the latest workflow version. This service
// account represents the identity of the workflow and determines what permissions the workflow has.
// Format: projects/{project}/serviceAccounts/{account}.
ServiceAccount *string `pulumi:"serviceAccount"`
// Workflow code to be executed. The size limit is 32KB.
SourceContents *string `pulumi:"sourceContents"`
// State of the workflow deployment.
State *string `pulumi:"state"`
// The timestamp of when the workflow was last updated in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to
// nine fractional digits.
UpdateTime *string `pulumi:"updateTime"`
}
type WorkflowState struct {
// The timestamp of when the workflow was created in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine
// fractional digits.
CreateTime pulumi.StringPtrInput
// Description of the workflow provided by the user. Must be at most 1000 unicode characters long.
Description pulumi.StringPtrInput
// A set of key/value label pairs to assign to this Workflow.
Labels pulumi.StringMapInput
// Name of the Workflow.
Name pulumi.StringPtrInput
// Creates a unique name beginning with the
// specified prefix. If this and name are unspecified, a random value is chosen for the name.
NamePrefix pulumi.StringPtrInput
// The ID of the project in which the resource belongs.
// If it is not provided, the provider project is used.
Project pulumi.StringPtrInput
// The region of the workflow.
Region pulumi.StringPtrInput
// The revision of the workflow. A new one is generated if the service account or source contents is changed.
RevisionId pulumi.StringPtrInput
// Name of the service account associated with the latest workflow version. This service
// account represents the identity of the workflow and determines what permissions the workflow has.
// Format: projects/{project}/serviceAccounts/{account}.
ServiceAccount pulumi.StringPtrInput
// Workflow code to be executed. The size limit is 32KB.
SourceContents pulumi.StringPtrInput
// State of the workflow deployment.
State pulumi.StringPtrInput
// The timestamp of when the workflow was last updated in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to
// nine fractional digits.
UpdateTime pulumi.StringPtrInput
}
func (WorkflowState) ElementType() reflect.Type {
return reflect.TypeOf((*workflowState)(nil)).Elem()
}
type workflowArgs struct {
// Description of the workflow provided by the user. Must be at most 1000 unicode characters long.
Description *string `pulumi:"description"`
// A set of key/value label pairs to assign to this Workflow.
Labels map[string]string `pulumi:"labels"`
// Name of the Workflow.
Name *string `pulumi:"name"`
// Creates a unique name beginning with the
// specified prefix. If this and name are unspecified, a random value is chosen for the name.
NamePrefix *string `pulumi:"namePrefix"`
// The ID of the project in which the resource belongs.
// If it is not provided, the provider project is used.
Project *string `pulumi:"project"`
// The region of the workflow.
Region *string `pulumi:"region"`
// Name of the service account associated with the latest workflow version. This service
// account represents the identity of the workflow and determines what permissions the workflow has.
// Format: projects/{project}/serviceAccounts/{account}.
ServiceAccount *string `pulumi:"serviceAccount"`
// Workflow code to be executed. The size limit is 32KB.
SourceContents *string `pulumi:"sourceContents"`
}
// The set of arguments for constructing a Workflow resource.
type WorkflowArgs struct {
// Description of the workflow provided by the user. Must be at most 1000 unicode characters long.
Description pulumi.StringPtrInput
// A set of key/value label pairs to assign to this Workflow.
Labels pulumi.StringMapInput
// Name of the Workflow.
Name pulumi.StringPtrInput
// Creates a unique name beginning with the
// specified prefix. If this and name are unspecified, a random value is chosen for the name.
NamePrefix pulumi.StringPtrInput
// The ID of the project in which the resource belongs.
// If it is not provided, the provider project is used.
Project pulumi.StringPtrInput
// The region of the workflow.
Region pulumi.StringPtrInput
// Name of the service account associated with the latest workflow version. This service
// account represents the identity of the workflow and determines what permissions the workflow has.
// Format: projects/{project}/serviceAccounts/{account}.
ServiceAccount pulumi.StringPtrInput
// Workflow code to be executed. The size limit is 32KB.
SourceContents pulumi.StringPtrInput
}
func (WorkflowArgs) ElementType() reflect.Type {
return reflect.TypeOf((*workflowArgs)(nil)).Elem()
}
type WorkflowInput interface {
pulumi.Input
ToWorkflowOutput() WorkflowOutput
ToWorkflowOutputWithContext(ctx context.Context) WorkflowOutput
}
func (*Workflow) ElementType() reflect.Type {
return reflect.TypeOf((*Workflow)(nil))
}
func (i *Workflow) ToWorkflowOutput() WorkflowOutput {
return i.ToWorkflowOutputWithContext(context.Background())
}
func (i *Workflow) ToWorkflowOutputWithContext(ctx context.Context) WorkflowOutput {
return pulumi.ToOutputWithContext(ctx, i).(WorkflowOutput)
}
func (i *Workflow) ToWorkflowPtrOutput() WorkflowPtrOutput {
return i.ToWorkflowPtrOutputWithContext(context.Background())
}
func (i *Workflow) ToWorkflowPtrOutputWithContext(ctx context.Context) WorkflowPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(WorkflowPtrOutput)
}
type WorkflowPtrInput interface {
pulumi.Input
ToWorkflowPtrOutput() WorkflowPtrOutput
ToWorkflowPtrOutputWithContext(ctx context.Context) WorkflowPtrOutput
}
type workflowPtrType WorkflowArgs
func (*workflowPtrType) ElementType() reflect.Type {
return reflect.TypeOf((**Workflow)(nil))
}
func (i *workflowPtrType) ToWorkflowPtrOutput() WorkflowPtrOutput {
return i.ToWorkflowPtrOutputWithContext(context.Background())
}
func (i *workflowPtrType) ToWorkflowPtrOutputWithContext(ctx context.Context) WorkflowPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(WorkflowPtrOutput)
}
// WorkflowArrayInput is an input type that accepts WorkflowArray and WorkflowArrayOutput values.
// You can construct a concrete instance of `WorkflowArrayInput` via:
//
// WorkflowArray{ WorkflowArgs{...} }
type WorkflowArrayInput interface {
pulumi.Input
ToWorkflowArrayOutput() WorkflowArrayOutput
ToWorkflowArrayOutputWithContext(context.Context) WorkflowArrayOutput
}
type WorkflowArray []WorkflowInput
func (WorkflowArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Workflow)(nil)).Elem()
}
func (i WorkflowArray) ToWorkflowArrayOutput() WorkflowArrayOutput {
return i.ToWorkflowArrayOutputWithContext(context.Background())
}
func (i WorkflowArray) ToWorkflowArrayOutputWithContext(ctx context.Context) WorkflowArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(WorkflowArrayOutput)
}
// WorkflowMapInput is an input type that accepts WorkflowMap and WorkflowMapOutput values.
// You can construct a concrete instance of `WorkflowMapInput` via:
//
// WorkflowMap{ "key": WorkflowArgs{...} }
type WorkflowMapInput interface {
pulumi.Input
ToWorkflowMapOutput() WorkflowMapOutput
ToWorkflowMapOutputWithContext(context.Context) WorkflowMapOutput
}
type WorkflowMap map[string]WorkflowInput
func (WorkflowMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Workflow)(nil)).Elem()
}
func (i WorkflowMap) ToWorkflowMapOutput() WorkflowMapOutput {
return i.ToWorkflowMapOutputWithContext(context.Background())
}
func (i WorkflowMap) ToWorkflowMapOutputWithContext(ctx context.Context) WorkflowMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(WorkflowMapOutput)
}
type WorkflowOutput struct{ *pulumi.OutputState }
func (WorkflowOutput) ElementType() reflect.Type {
return reflect.TypeOf((*Workflow)(nil))
}
func (o WorkflowOutput) ToWorkflowOutput() WorkflowOutput {
return o
}
func (o WorkflowOutput) ToWorkflowOutputWithContext(ctx context.Context) WorkflowOutput {
return o
}
func (o WorkflowOutput) ToWorkflowPtrOutput() WorkflowPtrOutput {
return o.ToWorkflowPtrOutputWithContext(context.Background())
}
func (o WorkflowOutput) ToWorkflowPtrOutputWithContext(ctx context.Context) WorkflowPtrOutput {
return o.ApplyTWithContext(ctx, func(_ context.Context, v Workflow) *Workflow {
return &v
}).(WorkflowPtrOutput)
}
type WorkflowPtrOutput struct{ *pulumi.OutputState }
func (WorkflowPtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Workflow)(nil))
}
func (o WorkflowPtrOutput) ToWorkflowPtrOutput() WorkflowPtrOutput {
return o
}
func (o WorkflowPtrOutput) ToWorkflowPtrOutputWithContext(ctx context.Context) WorkflowPtrOutput {
return o
}
func (o WorkflowPtrOutput) Elem() WorkflowOutput {
return o.ApplyT(func(v *Workflow) Workflow {
if v != nil {
return *v
}
var ret Workflow
return ret
}).(WorkflowOutput)
}
type WorkflowArrayOutput struct{ *pulumi.OutputState }
func (WorkflowArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]Workflow)(nil))
}
func (o WorkflowArrayOutput) ToWorkflowArrayOutput() WorkflowArrayOutput {
return o
}
func (o WorkflowArrayOutput) ToWorkflowArrayOutputWithContext(ctx context.Context) WorkflowArrayOutput {
return o
}
func (o WorkflowArrayOutput) Index(i pulumi.IntInput) WorkflowOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) Workflow {
return vs[0].([]Workflow)[vs[1].(int)]
}).(WorkflowOutput)
}
type WorkflowMapOutput struct{ *pulumi.OutputState }
func (WorkflowMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]Workflow)(nil))
}
func (o WorkflowMapOutput) ToWorkflowMapOutput() WorkflowMapOutput {
return o
}
func (o WorkflowMapOutput) ToWorkflowMapOutputWithContext(ctx context.Context) WorkflowMapOutput {
return o
}
func (o WorkflowMapOutput) MapIndex(k pulumi.StringInput) WorkflowOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) Workflow {
return vs[0].(map[string]Workflow)[vs[1].(string)]
}).(WorkflowOutput)
}
func init() {
pulumi.RegisterOutputType(WorkflowOutput{})
pulumi.RegisterOutputType(WorkflowPtrOutput{})
pulumi.RegisterOutputType(WorkflowArrayOutput{})
pulumi.RegisterOutputType(WorkflowMapOutput{})
}