/
fallbackRoute.go
365 lines (319 loc) · 15.9 KB
/
fallbackRoute.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
// *** 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 iot
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Manages an IotHub Fallback Route
//
// ## Disclaimers
//
// > **Note:** Fallback route can be defined either directly on the `iot.IoTHub` resource, or using the `iot.FallbackRoute` resource - but the two cannot be used together. If both are used against the same IoTHub, spurious changes will occur.
//
// > **Note:** Since this resource is provisioned by default, the Azure Provider will not check for the presence of an existing resource prior to attempting to create it.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-azure/sdk/v4/go/azure/core"
// "github.com/pulumi/pulumi-azure/sdk/v4/go/azure/iot"
// "github.com/pulumi/pulumi-azure/sdk/v4/go/azure/storage"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// exampleResourceGroup, err := core.NewResourceGroup(ctx, "exampleResourceGroup", &core.ResourceGroupArgs{
// Location: pulumi.String("West Europe"),
// })
// if err != nil {
// return err
// }
// exampleAccount, err := storage.NewAccount(ctx, "exampleAccount", &storage.AccountArgs{
// ResourceGroupName: exampleResourceGroup.Name,
// Location: exampleResourceGroup.Location,
// AccountTier: pulumi.String("Standard"),
// AccountReplicationType: pulumi.String("LRS"),
// })
// if err != nil {
// return err
// }
// exampleContainer, err := storage.NewContainer(ctx, "exampleContainer", &storage.ContainerArgs{
// StorageAccountName: exampleAccount.Name,
// ContainerAccessType: pulumi.String("private"),
// })
// if err != nil {
// return err
// }
// exampleIoTHub, err := iot.NewIoTHub(ctx, "exampleIoTHub", &iot.IoTHubArgs{
// ResourceGroupName: exampleResourceGroup.Name,
// Location: exampleResourceGroup.Location,
// Sku: &iot.IoTHubSkuArgs{
// Name: pulumi.String("S1"),
// Capacity: pulumi.Int(1),
// },
// Tags: pulumi.StringMap{
// "purpose": pulumi.String("testing"),
// },
// })
// if err != nil {
// return err
// }
// exampleEndpointStorageContainer, err := iot.NewEndpointStorageContainer(ctx, "exampleEndpointStorageContainer", &iot.EndpointStorageContainerArgs{
// ResourceGroupName: exampleResourceGroup.Name,
// IothubId: exampleIoTHub.ID(),
// ConnectionString: exampleAccount.PrimaryBlobConnectionString,
// BatchFrequencyInSeconds: pulumi.Int(60),
// MaxChunkSizeInBytes: pulumi.Int(10485760),
// ContainerName: exampleContainer.Name,
// Encoding: pulumi.String("Avro"),
// FileNameFormat: pulumi.String("{iothub}/{partition}_{YYYY}_{MM}_{DD}_{HH}_{mm}"),
// })
// if err != nil {
// return err
// }
// _, err = iot.NewFallbackRoute(ctx, "exampleFallbackRoute", &iot.FallbackRouteArgs{
// ResourceGroupName: exampleResourceGroup.Name,
// IothubName: exampleIoTHub.Name,
// Condition: pulumi.String("true"),
// EndpointNames: pulumi.String{
// exampleEndpointStorageContainer.Name,
// },
// Enabled: pulumi.Bool(true),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// IoTHub Fallback Route can be imported using the `resource id`, e.g.
//
// ```sh
// $ pulumi import azure:iot/fallbackRoute:FallbackRoute route1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Devices/IotHubs/hub1/FallbackRoute/default
// ```
type FallbackRoute struct {
pulumi.CustomResourceState
// The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to `true` by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language.
Condition pulumi.StringPtrOutput `pulumi:"condition"`
// Used to specify whether the fallback route is enabled.
Enabled pulumi.BoolOutput `pulumi:"enabled"`
// The endpoints to which messages that satisfy the condition are routed. Currently only 1 endpoint is allowed.
EndpointNames pulumi.StringOutput `pulumi:"endpointNames"`
// The name of the IoTHub to which this Fallback Route belongs. Changing this forces a new resource to be created.
IothubName pulumi.StringOutput `pulumi:"iothubName"`
// The name of the resource group under which the IotHub Storage Container Endpoint resource has to be created. Changing this forces a new resource to be created.
ResourceGroupName pulumi.StringOutput `pulumi:"resourceGroupName"`
// The source that the routing rule is to be applied to. Possible values include: `DeviceConnectionStateEvents`, `DeviceJobLifecycleEvents`, `DeviceLifecycleEvents`, `DeviceMessages`, `Invalid`, `TwinChangeEvents`.
Source pulumi.StringPtrOutput `pulumi:"source"`
}
// NewFallbackRoute registers a new resource with the given unique name, arguments, and options.
func NewFallbackRoute(ctx *pulumi.Context,
name string, args *FallbackRouteArgs, opts ...pulumi.ResourceOption) (*FallbackRoute, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Enabled == nil {
return nil, errors.New("invalid value for required argument 'Enabled'")
}
if args.EndpointNames == nil {
return nil, errors.New("invalid value for required argument 'EndpointNames'")
}
if args.IothubName == nil {
return nil, errors.New("invalid value for required argument 'IothubName'")
}
if args.ResourceGroupName == nil {
return nil, errors.New("invalid value for required argument 'ResourceGroupName'")
}
var resource FallbackRoute
err := ctx.RegisterResource("azure:iot/fallbackRoute:FallbackRoute", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetFallbackRoute gets an existing FallbackRoute 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 GetFallbackRoute(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *FallbackRouteState, opts ...pulumi.ResourceOption) (*FallbackRoute, error) {
var resource FallbackRoute
err := ctx.ReadResource("azure:iot/fallbackRoute:FallbackRoute", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering FallbackRoute resources.
type fallbackRouteState struct {
// The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to `true` by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language.
Condition *string `pulumi:"condition"`
// Used to specify whether the fallback route is enabled.
Enabled *bool `pulumi:"enabled"`
// The endpoints to which messages that satisfy the condition are routed. Currently only 1 endpoint is allowed.
EndpointNames *string `pulumi:"endpointNames"`
// The name of the IoTHub to which this Fallback Route belongs. Changing this forces a new resource to be created.
IothubName *string `pulumi:"iothubName"`
// The name of the resource group under which the IotHub Storage Container Endpoint resource has to be created. Changing this forces a new resource to be created.
ResourceGroupName *string `pulumi:"resourceGroupName"`
// The source that the routing rule is to be applied to. Possible values include: `DeviceConnectionStateEvents`, `DeviceJobLifecycleEvents`, `DeviceLifecycleEvents`, `DeviceMessages`, `Invalid`, `TwinChangeEvents`.
Source *string `pulumi:"source"`
}
type FallbackRouteState struct {
// The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to `true` by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language.
Condition pulumi.StringPtrInput
// Used to specify whether the fallback route is enabled.
Enabled pulumi.BoolPtrInput
// The endpoints to which messages that satisfy the condition are routed. Currently only 1 endpoint is allowed.
EndpointNames pulumi.StringPtrInput
// The name of the IoTHub to which this Fallback Route belongs. Changing this forces a new resource to be created.
IothubName pulumi.StringPtrInput
// The name of the resource group under which the IotHub Storage Container Endpoint resource has to be created. Changing this forces a new resource to be created.
ResourceGroupName pulumi.StringPtrInput
// The source that the routing rule is to be applied to. Possible values include: `DeviceConnectionStateEvents`, `DeviceJobLifecycleEvents`, `DeviceLifecycleEvents`, `DeviceMessages`, `Invalid`, `TwinChangeEvents`.
Source pulumi.StringPtrInput
}
func (FallbackRouteState) ElementType() reflect.Type {
return reflect.TypeOf((*fallbackRouteState)(nil)).Elem()
}
type fallbackRouteArgs struct {
// The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to `true` by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language.
Condition *string `pulumi:"condition"`
// Used to specify whether the fallback route is enabled.
Enabled bool `pulumi:"enabled"`
// The endpoints to which messages that satisfy the condition are routed. Currently only 1 endpoint is allowed.
EndpointNames string `pulumi:"endpointNames"`
// The name of the IoTHub to which this Fallback Route belongs. Changing this forces a new resource to be created.
IothubName string `pulumi:"iothubName"`
// The name of the resource group under which the IotHub Storage Container Endpoint resource has to be created. Changing this forces a new resource to be created.
ResourceGroupName string `pulumi:"resourceGroupName"`
// The source that the routing rule is to be applied to. Possible values include: `DeviceConnectionStateEvents`, `DeviceJobLifecycleEvents`, `DeviceLifecycleEvents`, `DeviceMessages`, `Invalid`, `TwinChangeEvents`.
Source *string `pulumi:"source"`
}
// The set of arguments for constructing a FallbackRoute resource.
type FallbackRouteArgs struct {
// The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to `true` by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language.
Condition pulumi.StringPtrInput
// Used to specify whether the fallback route is enabled.
Enabled pulumi.BoolInput
// The endpoints to which messages that satisfy the condition are routed. Currently only 1 endpoint is allowed.
EndpointNames pulumi.StringInput
// The name of the IoTHub to which this Fallback Route belongs. Changing this forces a new resource to be created.
IothubName pulumi.StringInput
// The name of the resource group under which the IotHub Storage Container Endpoint resource has to be created. Changing this forces a new resource to be created.
ResourceGroupName pulumi.StringInput
// The source that the routing rule is to be applied to. Possible values include: `DeviceConnectionStateEvents`, `DeviceJobLifecycleEvents`, `DeviceLifecycleEvents`, `DeviceMessages`, `Invalid`, `TwinChangeEvents`.
Source pulumi.StringPtrInput
}
func (FallbackRouteArgs) ElementType() reflect.Type {
return reflect.TypeOf((*fallbackRouteArgs)(nil)).Elem()
}
type FallbackRouteInput interface {
pulumi.Input
ToFallbackRouteOutput() FallbackRouteOutput
ToFallbackRouteOutputWithContext(ctx context.Context) FallbackRouteOutput
}
func (*FallbackRoute) ElementType() reflect.Type {
return reflect.TypeOf((**FallbackRoute)(nil)).Elem()
}
func (i *FallbackRoute) ToFallbackRouteOutput() FallbackRouteOutput {
return i.ToFallbackRouteOutputWithContext(context.Background())
}
func (i *FallbackRoute) ToFallbackRouteOutputWithContext(ctx context.Context) FallbackRouteOutput {
return pulumi.ToOutputWithContext(ctx, i).(FallbackRouteOutput)
}
// FallbackRouteArrayInput is an input type that accepts FallbackRouteArray and FallbackRouteArrayOutput values.
// You can construct a concrete instance of `FallbackRouteArrayInput` via:
//
// FallbackRouteArray{ FallbackRouteArgs{...} }
type FallbackRouteArrayInput interface {
pulumi.Input
ToFallbackRouteArrayOutput() FallbackRouteArrayOutput
ToFallbackRouteArrayOutputWithContext(context.Context) FallbackRouteArrayOutput
}
type FallbackRouteArray []FallbackRouteInput
func (FallbackRouteArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*FallbackRoute)(nil)).Elem()
}
func (i FallbackRouteArray) ToFallbackRouteArrayOutput() FallbackRouteArrayOutput {
return i.ToFallbackRouteArrayOutputWithContext(context.Background())
}
func (i FallbackRouteArray) ToFallbackRouteArrayOutputWithContext(ctx context.Context) FallbackRouteArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(FallbackRouteArrayOutput)
}
// FallbackRouteMapInput is an input type that accepts FallbackRouteMap and FallbackRouteMapOutput values.
// You can construct a concrete instance of `FallbackRouteMapInput` via:
//
// FallbackRouteMap{ "key": FallbackRouteArgs{...} }
type FallbackRouteMapInput interface {
pulumi.Input
ToFallbackRouteMapOutput() FallbackRouteMapOutput
ToFallbackRouteMapOutputWithContext(context.Context) FallbackRouteMapOutput
}
type FallbackRouteMap map[string]FallbackRouteInput
func (FallbackRouteMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*FallbackRoute)(nil)).Elem()
}
func (i FallbackRouteMap) ToFallbackRouteMapOutput() FallbackRouteMapOutput {
return i.ToFallbackRouteMapOutputWithContext(context.Background())
}
func (i FallbackRouteMap) ToFallbackRouteMapOutputWithContext(ctx context.Context) FallbackRouteMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(FallbackRouteMapOutput)
}
type FallbackRouteOutput struct{ *pulumi.OutputState }
func (FallbackRouteOutput) ElementType() reflect.Type {
return reflect.TypeOf((**FallbackRoute)(nil)).Elem()
}
func (o FallbackRouteOutput) ToFallbackRouteOutput() FallbackRouteOutput {
return o
}
func (o FallbackRouteOutput) ToFallbackRouteOutputWithContext(ctx context.Context) FallbackRouteOutput {
return o
}
type FallbackRouteArrayOutput struct{ *pulumi.OutputState }
func (FallbackRouteArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*FallbackRoute)(nil)).Elem()
}
func (o FallbackRouteArrayOutput) ToFallbackRouteArrayOutput() FallbackRouteArrayOutput {
return o
}
func (o FallbackRouteArrayOutput) ToFallbackRouteArrayOutputWithContext(ctx context.Context) FallbackRouteArrayOutput {
return o
}
func (o FallbackRouteArrayOutput) Index(i pulumi.IntInput) FallbackRouteOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *FallbackRoute {
return vs[0].([]*FallbackRoute)[vs[1].(int)]
}).(FallbackRouteOutput)
}
type FallbackRouteMapOutput struct{ *pulumi.OutputState }
func (FallbackRouteMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*FallbackRoute)(nil)).Elem()
}
func (o FallbackRouteMapOutput) ToFallbackRouteMapOutput() FallbackRouteMapOutput {
return o
}
func (o FallbackRouteMapOutput) ToFallbackRouteMapOutputWithContext(ctx context.Context) FallbackRouteMapOutput {
return o
}
func (o FallbackRouteMapOutput) MapIndex(k pulumi.StringInput) FallbackRouteOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *FallbackRoute {
return vs[0].(map[string]*FallbackRoute)[vs[1].(string)]
}).(FallbackRouteOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*FallbackRouteInput)(nil)).Elem(), &FallbackRoute{})
pulumi.RegisterInputType(reflect.TypeOf((*FallbackRouteArrayInput)(nil)).Elem(), FallbackRouteArray{})
pulumi.RegisterInputType(reflect.TypeOf((*FallbackRouteMapInput)(nil)).Elem(), FallbackRouteMap{})
pulumi.RegisterOutputType(FallbackRouteOutput{})
pulumi.RegisterOutputType(FallbackRouteArrayOutput{})
pulumi.RegisterOutputType(FallbackRouteMapOutput{})
}