generated from pulumi/pulumi-tf-provider-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
workPool.go
430 lines (373 loc) · 15 KB
/
workPool.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
// 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 prefect
import (
"context"
"reflect"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/ru5j4r0/pulumi-prefect/sdk/go/prefect/internal"
)
// The resource `workPool` represents a Prefect Cloud Work Pool. Work Pools represent infrastructure configurations for jobs across several common environments.
//
// Work Pools can be set up with default base job configurations, based on which type. Use this in conjunction with the `getWorkerMetadata` data source to bootstrap new Work Pools quickly.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "os"
//
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// "github.com/ru5j4r0/pulumi-prefect/sdk/go/prefect"
//
// )
//
// func readFileOrPanic(path string) pulumi.StringPtrInput {
// data, err := os.ReadFile(path)
// if err != nil {
// panic(err.Error())
// }
// return pulumi.String(string(data))
// }
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := prefect.NewWorkPool(ctx, "exampleWorkPool", &prefect.WorkPoolArgs{
// Type: pulumi.String("kubernetes"),
// Paused: pulumi.Bool(false),
// WorkspaceId: pulumi.String("my-workspace-id"),
// })
// if err != nil {
// return err
// }
// // Use a JSON file to load a base job configuration
// _, err = prefect.NewWorkPool(ctx, "exampleIndex/workPoolWorkPool", &prefect.WorkPoolArgs{
// Type: pulumi.String("kubernetes"),
// WorkspaceId: pulumi.Any(data.Prefect_workspace.Prd.Id),
// Paused: pulumi.Bool(false),
// BaseJobTemplate: readFileOrPanic("./base-job-template.json"),
// })
// if err != nil {
// return err
// }
// workerMetadata, err := prefect.GetWorkerMetadata(ctx, nil, nil)
// if err != nil {
// return err
// }
// _, err = prefect.NewWorkPool(ctx, "examplePrefectIndex/workPoolWorkPool", &prefect.WorkPoolArgs{
// Type: pulumi.String("kubernetes"),
// WorkspaceId: pulumi.Any(data.Prefect_workspace.Prd.Id),
// Paused: pulumi.Bool(false),
// BaseJobTemplate: pulumi.String(workerMetadata.BaseJobConfigs.Kubernetes),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// Prefect Work Pools can be imported using the format `workspace_id,name`
//
// ```sh
// $ pulumi import prefect:index/workPool:WorkPool example 00000000-0000-0000-0000-000000000000,kubernetes-work-pool
// ```
//
// You can also import by name only if you have a workspace_id set in your provider
//
// ```sh
// $ pulumi import prefect:index/workPool:WorkPool example kubernetes-work-pool
// ```
type WorkPool struct {
pulumi.CustomResourceState
// Account ID (UUID), defaults to the account set in the provider
AccountId pulumi.StringPtrOutput `pulumi:"accountId"`
// The base job template for the work pool, as a JSON string
BaseJobTemplate pulumi.StringOutput `pulumi:"baseJobTemplate"`
// The concurrency limit applied to this work pool
ConcurrencyLimit pulumi.IntPtrOutput `pulumi:"concurrencyLimit"`
// Timestamp of when the resource was created (RFC3339)
Created pulumi.StringOutput `pulumi:"created"`
// The ID (UUID) of the default queue associated with this work pool
DefaultQueueId pulumi.StringOutput `pulumi:"defaultQueueId"`
// Description of the work pool
Description pulumi.StringPtrOutput `pulumi:"description"`
// Name of the work pool
Name pulumi.StringOutput `pulumi:"name"`
// Whether this work pool is paused
Paused pulumi.BoolOutput `pulumi:"paused"`
// Type of the work pool, eg. kubernetes, ecs, process, etc.
Type pulumi.StringOutput `pulumi:"type"`
// Timestamp of when the resource was updated (RFC3339)
Updated pulumi.StringOutput `pulumi:"updated"`
// Workspace ID (UUID), defaults to the workspace set in the provider
WorkspaceId pulumi.StringPtrOutput `pulumi:"workspaceId"`
}
// NewWorkPool registers a new resource with the given unique name, arguments, and options.
func NewWorkPool(ctx *pulumi.Context,
name string, args *WorkPoolArgs, opts ...pulumi.ResourceOption) (*WorkPool, error) {
if args == nil {
args = &WorkPoolArgs{}
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource WorkPool
err := ctx.RegisterResource("prefect:index/workPool:WorkPool", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetWorkPool gets an existing WorkPool 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 GetWorkPool(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *WorkPoolState, opts ...pulumi.ResourceOption) (*WorkPool, error) {
var resource WorkPool
err := ctx.ReadResource("prefect:index/workPool:WorkPool", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering WorkPool resources.
type workPoolState struct {
// Account ID (UUID), defaults to the account set in the provider
AccountId *string `pulumi:"accountId"`
// The base job template for the work pool, as a JSON string
BaseJobTemplate *string `pulumi:"baseJobTemplate"`
// The concurrency limit applied to this work pool
ConcurrencyLimit *int `pulumi:"concurrencyLimit"`
// Timestamp of when the resource was created (RFC3339)
Created *string `pulumi:"created"`
// The ID (UUID) of the default queue associated with this work pool
DefaultQueueId *string `pulumi:"defaultQueueId"`
// Description of the work pool
Description *string `pulumi:"description"`
// Name of the work pool
Name *string `pulumi:"name"`
// Whether this work pool is paused
Paused *bool `pulumi:"paused"`
// Type of the work pool, eg. kubernetes, ecs, process, etc.
Type *string `pulumi:"type"`
// Timestamp of when the resource was updated (RFC3339)
Updated *string `pulumi:"updated"`
// Workspace ID (UUID), defaults to the workspace set in the provider
WorkspaceId *string `pulumi:"workspaceId"`
}
type WorkPoolState struct {
// Account ID (UUID), defaults to the account set in the provider
AccountId pulumi.StringPtrInput
// The base job template for the work pool, as a JSON string
BaseJobTemplate pulumi.StringPtrInput
// The concurrency limit applied to this work pool
ConcurrencyLimit pulumi.IntPtrInput
// Timestamp of when the resource was created (RFC3339)
Created pulumi.StringPtrInput
// The ID (UUID) of the default queue associated with this work pool
DefaultQueueId pulumi.StringPtrInput
// Description of the work pool
Description pulumi.StringPtrInput
// Name of the work pool
Name pulumi.StringPtrInput
// Whether this work pool is paused
Paused pulumi.BoolPtrInput
// Type of the work pool, eg. kubernetes, ecs, process, etc.
Type pulumi.StringPtrInput
// Timestamp of when the resource was updated (RFC3339)
Updated pulumi.StringPtrInput
// Workspace ID (UUID), defaults to the workspace set in the provider
WorkspaceId pulumi.StringPtrInput
}
func (WorkPoolState) ElementType() reflect.Type {
return reflect.TypeOf((*workPoolState)(nil)).Elem()
}
type workPoolArgs struct {
// Account ID (UUID), defaults to the account set in the provider
AccountId *string `pulumi:"accountId"`
// The base job template for the work pool, as a JSON string
BaseJobTemplate *string `pulumi:"baseJobTemplate"`
// The concurrency limit applied to this work pool
ConcurrencyLimit *int `pulumi:"concurrencyLimit"`
// Description of the work pool
Description *string `pulumi:"description"`
// Name of the work pool
Name *string `pulumi:"name"`
// Whether this work pool is paused
Paused *bool `pulumi:"paused"`
// Type of the work pool, eg. kubernetes, ecs, process, etc.
Type *string `pulumi:"type"`
// Workspace ID (UUID), defaults to the workspace set in the provider
WorkspaceId *string `pulumi:"workspaceId"`
}
// The set of arguments for constructing a WorkPool resource.
type WorkPoolArgs struct {
// Account ID (UUID), defaults to the account set in the provider
AccountId pulumi.StringPtrInput
// The base job template for the work pool, as a JSON string
BaseJobTemplate pulumi.StringPtrInput
// The concurrency limit applied to this work pool
ConcurrencyLimit pulumi.IntPtrInput
// Description of the work pool
Description pulumi.StringPtrInput
// Name of the work pool
Name pulumi.StringPtrInput
// Whether this work pool is paused
Paused pulumi.BoolPtrInput
// Type of the work pool, eg. kubernetes, ecs, process, etc.
Type pulumi.StringPtrInput
// Workspace ID (UUID), defaults to the workspace set in the provider
WorkspaceId pulumi.StringPtrInput
}
func (WorkPoolArgs) ElementType() reflect.Type {
return reflect.TypeOf((*workPoolArgs)(nil)).Elem()
}
type WorkPoolInput interface {
pulumi.Input
ToWorkPoolOutput() WorkPoolOutput
ToWorkPoolOutputWithContext(ctx context.Context) WorkPoolOutput
}
func (*WorkPool) ElementType() reflect.Type {
return reflect.TypeOf((**WorkPool)(nil)).Elem()
}
func (i *WorkPool) ToWorkPoolOutput() WorkPoolOutput {
return i.ToWorkPoolOutputWithContext(context.Background())
}
func (i *WorkPool) ToWorkPoolOutputWithContext(ctx context.Context) WorkPoolOutput {
return pulumi.ToOutputWithContext(ctx, i).(WorkPoolOutput)
}
// WorkPoolArrayInput is an input type that accepts WorkPoolArray and WorkPoolArrayOutput values.
// You can construct a concrete instance of `WorkPoolArrayInput` via:
//
// WorkPoolArray{ WorkPoolArgs{...} }
type WorkPoolArrayInput interface {
pulumi.Input
ToWorkPoolArrayOutput() WorkPoolArrayOutput
ToWorkPoolArrayOutputWithContext(context.Context) WorkPoolArrayOutput
}
type WorkPoolArray []WorkPoolInput
func (WorkPoolArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*WorkPool)(nil)).Elem()
}
func (i WorkPoolArray) ToWorkPoolArrayOutput() WorkPoolArrayOutput {
return i.ToWorkPoolArrayOutputWithContext(context.Background())
}
func (i WorkPoolArray) ToWorkPoolArrayOutputWithContext(ctx context.Context) WorkPoolArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(WorkPoolArrayOutput)
}
// WorkPoolMapInput is an input type that accepts WorkPoolMap and WorkPoolMapOutput values.
// You can construct a concrete instance of `WorkPoolMapInput` via:
//
// WorkPoolMap{ "key": WorkPoolArgs{...} }
type WorkPoolMapInput interface {
pulumi.Input
ToWorkPoolMapOutput() WorkPoolMapOutput
ToWorkPoolMapOutputWithContext(context.Context) WorkPoolMapOutput
}
type WorkPoolMap map[string]WorkPoolInput
func (WorkPoolMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*WorkPool)(nil)).Elem()
}
func (i WorkPoolMap) ToWorkPoolMapOutput() WorkPoolMapOutput {
return i.ToWorkPoolMapOutputWithContext(context.Background())
}
func (i WorkPoolMap) ToWorkPoolMapOutputWithContext(ctx context.Context) WorkPoolMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(WorkPoolMapOutput)
}
type WorkPoolOutput struct{ *pulumi.OutputState }
func (WorkPoolOutput) ElementType() reflect.Type {
return reflect.TypeOf((**WorkPool)(nil)).Elem()
}
func (o WorkPoolOutput) ToWorkPoolOutput() WorkPoolOutput {
return o
}
func (o WorkPoolOutput) ToWorkPoolOutputWithContext(ctx context.Context) WorkPoolOutput {
return o
}
// Account ID (UUID), defaults to the account set in the provider
func (o WorkPoolOutput) AccountId() pulumi.StringPtrOutput {
return o.ApplyT(func(v *WorkPool) pulumi.StringPtrOutput { return v.AccountId }).(pulumi.StringPtrOutput)
}
// The base job template for the work pool, as a JSON string
func (o WorkPoolOutput) BaseJobTemplate() pulumi.StringOutput {
return o.ApplyT(func(v *WorkPool) pulumi.StringOutput { return v.BaseJobTemplate }).(pulumi.StringOutput)
}
// The concurrency limit applied to this work pool
func (o WorkPoolOutput) ConcurrencyLimit() pulumi.IntPtrOutput {
return o.ApplyT(func(v *WorkPool) pulumi.IntPtrOutput { return v.ConcurrencyLimit }).(pulumi.IntPtrOutput)
}
// Timestamp of when the resource was created (RFC3339)
func (o WorkPoolOutput) Created() pulumi.StringOutput {
return o.ApplyT(func(v *WorkPool) pulumi.StringOutput { return v.Created }).(pulumi.StringOutput)
}
// The ID (UUID) of the default queue associated with this work pool
func (o WorkPoolOutput) DefaultQueueId() pulumi.StringOutput {
return o.ApplyT(func(v *WorkPool) pulumi.StringOutput { return v.DefaultQueueId }).(pulumi.StringOutput)
}
// Description of the work pool
func (o WorkPoolOutput) Description() pulumi.StringPtrOutput {
return o.ApplyT(func(v *WorkPool) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput)
}
// Name of the work pool
func (o WorkPoolOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *WorkPool) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// Whether this work pool is paused
func (o WorkPoolOutput) Paused() pulumi.BoolOutput {
return o.ApplyT(func(v *WorkPool) pulumi.BoolOutput { return v.Paused }).(pulumi.BoolOutput)
}
// Type of the work pool, eg. kubernetes, ecs, process, etc.
func (o WorkPoolOutput) Type() pulumi.StringOutput {
return o.ApplyT(func(v *WorkPool) pulumi.StringOutput { return v.Type }).(pulumi.StringOutput)
}
// Timestamp of when the resource was updated (RFC3339)
func (o WorkPoolOutput) Updated() pulumi.StringOutput {
return o.ApplyT(func(v *WorkPool) pulumi.StringOutput { return v.Updated }).(pulumi.StringOutput)
}
// Workspace ID (UUID), defaults to the workspace set in the provider
func (o WorkPoolOutput) WorkspaceId() pulumi.StringPtrOutput {
return o.ApplyT(func(v *WorkPool) pulumi.StringPtrOutput { return v.WorkspaceId }).(pulumi.StringPtrOutput)
}
type WorkPoolArrayOutput struct{ *pulumi.OutputState }
func (WorkPoolArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*WorkPool)(nil)).Elem()
}
func (o WorkPoolArrayOutput) ToWorkPoolArrayOutput() WorkPoolArrayOutput {
return o
}
func (o WorkPoolArrayOutput) ToWorkPoolArrayOutputWithContext(ctx context.Context) WorkPoolArrayOutput {
return o
}
func (o WorkPoolArrayOutput) Index(i pulumi.IntInput) WorkPoolOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *WorkPool {
return vs[0].([]*WorkPool)[vs[1].(int)]
}).(WorkPoolOutput)
}
type WorkPoolMapOutput struct{ *pulumi.OutputState }
func (WorkPoolMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*WorkPool)(nil)).Elem()
}
func (o WorkPoolMapOutput) ToWorkPoolMapOutput() WorkPoolMapOutput {
return o
}
func (o WorkPoolMapOutput) ToWorkPoolMapOutputWithContext(ctx context.Context) WorkPoolMapOutput {
return o
}
func (o WorkPoolMapOutput) MapIndex(k pulumi.StringInput) WorkPoolOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *WorkPool {
return vs[0].(map[string]*WorkPool)[vs[1].(string)]
}).(WorkPoolOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*WorkPoolInput)(nil)).Elem(), &WorkPool{})
pulumi.RegisterInputType(reflect.TypeOf((*WorkPoolArrayInput)(nil)).Elem(), WorkPoolArray{})
pulumi.RegisterInputType(reflect.TypeOf((*WorkPoolMapInput)(nil)).Elem(), WorkPoolMap{})
pulumi.RegisterOutputType(WorkPoolOutput{})
pulumi.RegisterOutputType(WorkPoolArrayOutput{})
pulumi.RegisterOutputType(WorkPoolMapOutput{})
}