-
Notifications
You must be signed in to change notification settings - Fork 51
/
route.go
233 lines (220 loc) · 10.7 KB
/
route.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
// *** 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 (
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
// Manages an IotHub Route
//
// > **NOTE:** Routes can be defined either directly on the `iot.IoTHub` resource, or using the `iot.Route` resourcs - but the two cannot be used together. If both are used against the same IoTHub, spurious changes will occur.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-azure/sdk/v3/go/azure/core"
// "github.com/pulumi/pulumi-azure/sdk/v3/go/azure/iot"
// "github.com/pulumi/pulumi-azure/sdk/v3/go/azure/storage"
// "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// exampleResourceGroup, err := core.NewResourceGroup(ctx, "exampleResourceGroup", &core.ResourceGroupArgs{
// Location: pulumi.String("West US"),
// })
// 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,
// IothubName: exampleIoTHub.Name,
// 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.NewRoute(ctx, "exampleRoute", &iot.RouteArgs{
// ResourceGroupName: exampleResourceGroup.Name,
// IothubName: exampleIoTHub.Name,
// Source: pulumi.String("DeviceMessages"),
// Condition: pulumi.String("true"),
// EndpointNames: pulumi.String(pulumi.String{
// exampleEndpointStorageContainer.Name,
// }),
// Enabled: pulumi.Bool(true),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
type Route 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"`
// Specifies whether a route is enabled.
Enabled pulumi.BoolOutput `pulumi:"enabled"`
// The list of endpoints to which messages that satisfy the condition are routed. Currently only one endpoint is allowed.
EndpointNames pulumi.StringOutput `pulumi:"endpointNames"`
// The name of the IoTHub to which this Route belongs. Changing this forces a new resource to be created.
IothubName pulumi.StringOutput `pulumi:"iothubName"`
// The name of the route.
Name pulumi.StringOutput `pulumi:"name"`
// The name of the resource group under which the IotHub Route 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: `DeviceJobLifecycleEvents`, `DeviceLifecycleEvents`, `DeviceMessages`, `Invalid`, `TwinChangeEvents`.
Source pulumi.StringOutput `pulumi:"source"`
}
// NewRoute registers a new resource with the given unique name, arguments, and options.
func NewRoute(ctx *pulumi.Context,
name string, args *RouteArgs, opts ...pulumi.ResourceOption) (*Route, error) {
if args == nil || args.Enabled == nil {
return nil, errors.New("missing required argument 'Enabled'")
}
if args == nil || args.EndpointNames == nil {
return nil, errors.New("missing required argument 'EndpointNames'")
}
if args == nil || args.IothubName == nil {
return nil, errors.New("missing required argument 'IothubName'")
}
if args == nil || args.ResourceGroupName == nil {
return nil, errors.New("missing required argument 'ResourceGroupName'")
}
if args == nil || args.Source == nil {
return nil, errors.New("missing required argument 'Source'")
}
if args == nil {
args = &RouteArgs{}
}
var resource Route
err := ctx.RegisterResource("azure:iot/route:Route", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetRoute gets an existing Route 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 GetRoute(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *RouteState, opts ...pulumi.ResourceOption) (*Route, error) {
var resource Route
err := ctx.ReadResource("azure:iot/route:Route", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Route resources.
type routeState 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"`
// Specifies whether a route is enabled.
Enabled *bool `pulumi:"enabled"`
// The list of endpoints to which messages that satisfy the condition are routed. Currently only one endpoint is allowed.
EndpointNames *string `pulumi:"endpointNames"`
// The name of the IoTHub to which this Route belongs. Changing this forces a new resource to be created.
IothubName *string `pulumi:"iothubName"`
// The name of the route.
Name *string `pulumi:"name"`
// The name of the resource group under which the IotHub Route 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: `DeviceJobLifecycleEvents`, `DeviceLifecycleEvents`, `DeviceMessages`, `Invalid`, `TwinChangeEvents`.
Source *string `pulumi:"source"`
}
type RouteState 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
// Specifies whether a route is enabled.
Enabled pulumi.BoolPtrInput
// The list of endpoints to which messages that satisfy the condition are routed. Currently only one endpoint is allowed.
EndpointNames pulumi.StringPtrInput
// The name of the IoTHub to which this Route belongs. Changing this forces a new resource to be created.
IothubName pulumi.StringPtrInput
// The name of the route.
Name pulumi.StringPtrInput
// The name of the resource group under which the IotHub Route 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: `DeviceJobLifecycleEvents`, `DeviceLifecycleEvents`, `DeviceMessages`, `Invalid`, `TwinChangeEvents`.
Source pulumi.StringPtrInput
}
func (RouteState) ElementType() reflect.Type {
return reflect.TypeOf((*routeState)(nil)).Elem()
}
type routeArgs 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"`
// Specifies whether a route is enabled.
Enabled bool `pulumi:"enabled"`
// The list of endpoints to which messages that satisfy the condition are routed. Currently only one endpoint is allowed.
EndpointNames string `pulumi:"endpointNames"`
// The name of the IoTHub to which this Route belongs. Changing this forces a new resource to be created.
IothubName string `pulumi:"iothubName"`
// The name of the route.
Name *string `pulumi:"name"`
// The name of the resource group under which the IotHub Route 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: `DeviceJobLifecycleEvents`, `DeviceLifecycleEvents`, `DeviceMessages`, `Invalid`, `TwinChangeEvents`.
Source string `pulumi:"source"`
}
// The set of arguments for constructing a Route resource.
type RouteArgs 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
// Specifies whether a route is enabled.
Enabled pulumi.BoolInput
// The list of endpoints to which messages that satisfy the condition are routed. Currently only one endpoint is allowed.
EndpointNames pulumi.StringInput
// The name of the IoTHub to which this Route belongs. Changing this forces a new resource to be created.
IothubName pulumi.StringInput
// The name of the route.
Name pulumi.StringPtrInput
// The name of the resource group under which the IotHub Route 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: `DeviceJobLifecycleEvents`, `DeviceLifecycleEvents`, `DeviceMessages`, `Invalid`, `TwinChangeEvents`.
Source pulumi.StringInput
}
func (RouteArgs) ElementType() reflect.Type {
return reflect.TypeOf((*routeArgs)(nil)).Elem()
}