/
binding.go
404 lines (350 loc) · 12.7 KB
/
binding.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
// 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 rabbitmq
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-rabbitmq/sdk/v3/go/rabbitmq/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// The “Binding“ resource creates and manages a binding relationship
// between a queue an exchange.
//
// ## Example Usage
//
// <!--Start PulumiCodeChooser -->
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-rabbitmq/sdk/v3/go/rabbitmq"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// testVHost, err := rabbitmq.NewVHost(ctx, "testVHost", nil)
// if err != nil {
// return err
// }
// guest, err := rabbitmq.NewPermissions(ctx, "guest", &rabbitmq.PermissionsArgs{
// Permissions: &rabbitmq.PermissionsPermissionsArgs{
// Configure: pulumi.String(".*"),
// Read: pulumi.String(".*"),
// Write: pulumi.String(".*"),
// },
// User: pulumi.String("guest"),
// Vhost: testVHost.Name,
// })
// if err != nil {
// return err
// }
// testExchange, err := rabbitmq.NewExchange(ctx, "testExchange", &rabbitmq.ExchangeArgs{
// Settings: &rabbitmq.ExchangeSettingsArgs{
// AutoDelete: pulumi.Bool(true),
// Durable: pulumi.Bool(false),
// Type: pulumi.String("fanout"),
// },
// Vhost: guest.Vhost,
// })
// if err != nil {
// return err
// }
// testQueue, err := rabbitmq.NewQueue(ctx, "testQueue", &rabbitmq.QueueArgs{
// Settings: &rabbitmq.QueueSettingsArgs{
// AutoDelete: pulumi.Bool(false),
// Durable: pulumi.Bool(true),
// },
// Vhost: guest.Vhost,
// })
// if err != nil {
// return err
// }
// _, err = rabbitmq.NewBinding(ctx, "testBinding", &rabbitmq.BindingArgs{
// Destination: testQueue.Name,
// DestinationType: pulumi.String("queue"),
// RoutingKey: pulumi.String("#"),
// Source: testExchange.Name,
// Vhost: testVHost.Name,
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
//
// ## Import
//
// Bindings can be imported using the `id` which is composed of
//
// `vhost/source/destination/destination_type/properties_key`. E.g.
//
// ```sh
// $ pulumi import rabbitmq:index/binding:Binding test test/test/test/queue/%!
// (MISSING)```
// ```
type Binding struct {
pulumi.CustomResourceState
// Additional key/value arguments for the binding.
Arguments pulumi.MapOutput `pulumi:"arguments"`
ArgumentsJson pulumi.StringPtrOutput `pulumi:"argumentsJson"`
// The destination queue or exchange.
Destination pulumi.StringOutput `pulumi:"destination"`
// The type of destination (queue or exchange).
DestinationType pulumi.StringOutput `pulumi:"destinationType"`
// A unique key to refer to the binding.
PropertiesKey pulumi.StringOutput `pulumi:"propertiesKey"`
// A routing key for the binding.
RoutingKey pulumi.StringPtrOutput `pulumi:"routingKey"`
// The source exchange.
Source pulumi.StringOutput `pulumi:"source"`
// The vhost to create the resource in.
Vhost pulumi.StringOutput `pulumi:"vhost"`
}
// NewBinding registers a new resource with the given unique name, arguments, and options.
func NewBinding(ctx *pulumi.Context,
name string, args *BindingArgs, opts ...pulumi.ResourceOption) (*Binding, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Destination == nil {
return nil, errors.New("invalid value for required argument 'Destination'")
}
if args.DestinationType == nil {
return nil, errors.New("invalid value for required argument 'DestinationType'")
}
if args.Source == nil {
return nil, errors.New("invalid value for required argument 'Source'")
}
if args.Vhost == nil {
return nil, errors.New("invalid value for required argument 'Vhost'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource Binding
err := ctx.RegisterResource("rabbitmq:index/binding:Binding", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetBinding gets an existing Binding 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 GetBinding(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *BindingState, opts ...pulumi.ResourceOption) (*Binding, error) {
var resource Binding
err := ctx.ReadResource("rabbitmq:index/binding:Binding", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Binding resources.
type bindingState struct {
// Additional key/value arguments for the binding.
Arguments map[string]interface{} `pulumi:"arguments"`
ArgumentsJson *string `pulumi:"argumentsJson"`
// The destination queue or exchange.
Destination *string `pulumi:"destination"`
// The type of destination (queue or exchange).
DestinationType *string `pulumi:"destinationType"`
// A unique key to refer to the binding.
PropertiesKey *string `pulumi:"propertiesKey"`
// A routing key for the binding.
RoutingKey *string `pulumi:"routingKey"`
// The source exchange.
Source *string `pulumi:"source"`
// The vhost to create the resource in.
Vhost *string `pulumi:"vhost"`
}
type BindingState struct {
// Additional key/value arguments for the binding.
Arguments pulumi.MapInput
ArgumentsJson pulumi.StringPtrInput
// The destination queue or exchange.
Destination pulumi.StringPtrInput
// The type of destination (queue or exchange).
DestinationType pulumi.StringPtrInput
// A unique key to refer to the binding.
PropertiesKey pulumi.StringPtrInput
// A routing key for the binding.
RoutingKey pulumi.StringPtrInput
// The source exchange.
Source pulumi.StringPtrInput
// The vhost to create the resource in.
Vhost pulumi.StringPtrInput
}
func (BindingState) ElementType() reflect.Type {
return reflect.TypeOf((*bindingState)(nil)).Elem()
}
type bindingArgs struct {
// Additional key/value arguments for the binding.
Arguments map[string]interface{} `pulumi:"arguments"`
ArgumentsJson *string `pulumi:"argumentsJson"`
// The destination queue or exchange.
Destination string `pulumi:"destination"`
// The type of destination (queue or exchange).
DestinationType string `pulumi:"destinationType"`
// A routing key for the binding.
RoutingKey *string `pulumi:"routingKey"`
// The source exchange.
Source string `pulumi:"source"`
// The vhost to create the resource in.
Vhost string `pulumi:"vhost"`
}
// The set of arguments for constructing a Binding resource.
type BindingArgs struct {
// Additional key/value arguments for the binding.
Arguments pulumi.MapInput
ArgumentsJson pulumi.StringPtrInput
// The destination queue or exchange.
Destination pulumi.StringInput
// The type of destination (queue or exchange).
DestinationType pulumi.StringInput
// A routing key for the binding.
RoutingKey pulumi.StringPtrInput
// The source exchange.
Source pulumi.StringInput
// The vhost to create the resource in.
Vhost pulumi.StringInput
}
func (BindingArgs) ElementType() reflect.Type {
return reflect.TypeOf((*bindingArgs)(nil)).Elem()
}
type BindingInput interface {
pulumi.Input
ToBindingOutput() BindingOutput
ToBindingOutputWithContext(ctx context.Context) BindingOutput
}
func (*Binding) ElementType() reflect.Type {
return reflect.TypeOf((**Binding)(nil)).Elem()
}
func (i *Binding) ToBindingOutput() BindingOutput {
return i.ToBindingOutputWithContext(context.Background())
}
func (i *Binding) ToBindingOutputWithContext(ctx context.Context) BindingOutput {
return pulumi.ToOutputWithContext(ctx, i).(BindingOutput)
}
// BindingArrayInput is an input type that accepts BindingArray and BindingArrayOutput values.
// You can construct a concrete instance of `BindingArrayInput` via:
//
// BindingArray{ BindingArgs{...} }
type BindingArrayInput interface {
pulumi.Input
ToBindingArrayOutput() BindingArrayOutput
ToBindingArrayOutputWithContext(context.Context) BindingArrayOutput
}
type BindingArray []BindingInput
func (BindingArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Binding)(nil)).Elem()
}
func (i BindingArray) ToBindingArrayOutput() BindingArrayOutput {
return i.ToBindingArrayOutputWithContext(context.Background())
}
func (i BindingArray) ToBindingArrayOutputWithContext(ctx context.Context) BindingArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(BindingArrayOutput)
}
// BindingMapInput is an input type that accepts BindingMap and BindingMapOutput values.
// You can construct a concrete instance of `BindingMapInput` via:
//
// BindingMap{ "key": BindingArgs{...} }
type BindingMapInput interface {
pulumi.Input
ToBindingMapOutput() BindingMapOutput
ToBindingMapOutputWithContext(context.Context) BindingMapOutput
}
type BindingMap map[string]BindingInput
func (BindingMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Binding)(nil)).Elem()
}
func (i BindingMap) ToBindingMapOutput() BindingMapOutput {
return i.ToBindingMapOutputWithContext(context.Background())
}
func (i BindingMap) ToBindingMapOutputWithContext(ctx context.Context) BindingMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(BindingMapOutput)
}
type BindingOutput struct{ *pulumi.OutputState }
func (BindingOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Binding)(nil)).Elem()
}
func (o BindingOutput) ToBindingOutput() BindingOutput {
return o
}
func (o BindingOutput) ToBindingOutputWithContext(ctx context.Context) BindingOutput {
return o
}
// Additional key/value arguments for the binding.
func (o BindingOutput) Arguments() pulumi.MapOutput {
return o.ApplyT(func(v *Binding) pulumi.MapOutput { return v.Arguments }).(pulumi.MapOutput)
}
func (o BindingOutput) ArgumentsJson() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Binding) pulumi.StringPtrOutput { return v.ArgumentsJson }).(pulumi.StringPtrOutput)
}
// The destination queue or exchange.
func (o BindingOutput) Destination() pulumi.StringOutput {
return o.ApplyT(func(v *Binding) pulumi.StringOutput { return v.Destination }).(pulumi.StringOutput)
}
// The type of destination (queue or exchange).
func (o BindingOutput) DestinationType() pulumi.StringOutput {
return o.ApplyT(func(v *Binding) pulumi.StringOutput { return v.DestinationType }).(pulumi.StringOutput)
}
// A unique key to refer to the binding.
func (o BindingOutput) PropertiesKey() pulumi.StringOutput {
return o.ApplyT(func(v *Binding) pulumi.StringOutput { return v.PropertiesKey }).(pulumi.StringOutput)
}
// A routing key for the binding.
func (o BindingOutput) RoutingKey() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Binding) pulumi.StringPtrOutput { return v.RoutingKey }).(pulumi.StringPtrOutput)
}
// The source exchange.
func (o BindingOutput) Source() pulumi.StringOutput {
return o.ApplyT(func(v *Binding) pulumi.StringOutput { return v.Source }).(pulumi.StringOutput)
}
// The vhost to create the resource in.
func (o BindingOutput) Vhost() pulumi.StringOutput {
return o.ApplyT(func(v *Binding) pulumi.StringOutput { return v.Vhost }).(pulumi.StringOutput)
}
type BindingArrayOutput struct{ *pulumi.OutputState }
func (BindingArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Binding)(nil)).Elem()
}
func (o BindingArrayOutput) ToBindingArrayOutput() BindingArrayOutput {
return o
}
func (o BindingArrayOutput) ToBindingArrayOutputWithContext(ctx context.Context) BindingArrayOutput {
return o
}
func (o BindingArrayOutput) Index(i pulumi.IntInput) BindingOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Binding {
return vs[0].([]*Binding)[vs[1].(int)]
}).(BindingOutput)
}
type BindingMapOutput struct{ *pulumi.OutputState }
func (BindingMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Binding)(nil)).Elem()
}
func (o BindingMapOutput) ToBindingMapOutput() BindingMapOutput {
return o
}
func (o BindingMapOutput) ToBindingMapOutputWithContext(ctx context.Context) BindingMapOutput {
return o
}
func (o BindingMapOutput) MapIndex(k pulumi.StringInput) BindingOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Binding {
return vs[0].(map[string]*Binding)[vs[1].(string)]
}).(BindingOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*BindingInput)(nil)).Elem(), &Binding{})
pulumi.RegisterInputType(reflect.TypeOf((*BindingArrayInput)(nil)).Elem(), BindingArray{})
pulumi.RegisterInputType(reflect.TypeOf((*BindingMapInput)(nil)).Elem(), BindingMap{})
pulumi.RegisterOutputType(BindingOutput{})
pulumi.RegisterOutputType(BindingArrayOutput{})
pulumi.RegisterOutputType(BindingMapOutput{})
}