generated from pulumi/pulumi-tf-provider-boilerplate
/
reservedIP.go
348 lines (296 loc) · 11.2 KB
/
reservedIP.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
// 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 vultr
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Provides a Vultr reserved IP resource. This can be used to create, read, modify, and delete reserved IP addresses on your Vultr account.
//
// ## Example Usage
//
// Create a new reserved IP:
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-vultr/sdk/go/vultr"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := vultr.NewReservedIP(ctx, "myReservedIp", &vultr.ReservedIPArgs{
// IpType: pulumi.String("v4"),
// Label: pulumi.String("my-reserved-ip"),
// Region: pulumi.String("sea"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// Attach a reserved IP to a instance:
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-vultr/sdk/go/vultr"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := vultr.NewReservedIP(ctx, "myReservedIp", &vultr.ReservedIPArgs{
// InstanceId: pulumi.String("b9cc6fad-70b1-40ee-ab6a-4d622858962f"),
// IpType: pulumi.String("v4"),
// Label: pulumi.String("my-reserved-ip"),
// Region: pulumi.String("sea"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// Reserved IPs can be imported using the reserved IP `ID`, e.g.
//
// ```sh
// $ pulumi import vultr:index/reservedIP:ReservedIP my_reserved_ip b9cc6fad-70b1-40ee-ab6a-4d622858962f
// ```
type ReservedIP struct {
pulumi.CustomResourceState
// The VPS ID you want this reserved IP to be attached to.
InstanceId pulumi.StringOutput `pulumi:"instanceId"`
// The type of reserved IP that you want. Either "v4" or "v6".
IpType pulumi.StringOutput `pulumi:"ipType"`
// The label you want to give your reserved IP.
Label pulumi.StringPtrOutput `pulumi:"label"`
// The region ID that you want the reserved IP to be created in.
Region pulumi.StringOutput `pulumi:"region"`
// The reserved IP's subnet.
Subnet pulumi.StringOutput `pulumi:"subnet"`
// The reserved IP's subnet size.
SubnetSize pulumi.IntOutput `pulumi:"subnetSize"`
}
// NewReservedIP registers a new resource with the given unique name, arguments, and options.
func NewReservedIP(ctx *pulumi.Context,
name string, args *ReservedIPArgs, opts ...pulumi.ResourceOption) (*ReservedIP, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.IpType == nil {
return nil, errors.New("invalid value for required argument 'IpType'")
}
if args.Region == nil {
return nil, errors.New("invalid value for required argument 'Region'")
}
var resource ReservedIP
err := ctx.RegisterResource("vultr:index/reservedIP:ReservedIP", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetReservedIP gets an existing ReservedIP 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 GetReservedIP(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *ReservedIPState, opts ...pulumi.ResourceOption) (*ReservedIP, error) {
var resource ReservedIP
err := ctx.ReadResource("vultr:index/reservedIP:ReservedIP", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering ReservedIP resources.
type reservedIPState struct {
// The VPS ID you want this reserved IP to be attached to.
InstanceId *string `pulumi:"instanceId"`
// The type of reserved IP that you want. Either "v4" or "v6".
IpType *string `pulumi:"ipType"`
// The label you want to give your reserved IP.
Label *string `pulumi:"label"`
// The region ID that you want the reserved IP to be created in.
Region *string `pulumi:"region"`
// The reserved IP's subnet.
Subnet *string `pulumi:"subnet"`
// The reserved IP's subnet size.
SubnetSize *int `pulumi:"subnetSize"`
}
type ReservedIPState struct {
// The VPS ID you want this reserved IP to be attached to.
InstanceId pulumi.StringPtrInput
// The type of reserved IP that you want. Either "v4" or "v6".
IpType pulumi.StringPtrInput
// The label you want to give your reserved IP.
Label pulumi.StringPtrInput
// The region ID that you want the reserved IP to be created in.
Region pulumi.StringPtrInput
// The reserved IP's subnet.
Subnet pulumi.StringPtrInput
// The reserved IP's subnet size.
SubnetSize pulumi.IntPtrInput
}
func (ReservedIPState) ElementType() reflect.Type {
return reflect.TypeOf((*reservedIPState)(nil)).Elem()
}
type reservedIPArgs struct {
// The VPS ID you want this reserved IP to be attached to.
InstanceId *string `pulumi:"instanceId"`
// The type of reserved IP that you want. Either "v4" or "v6".
IpType string `pulumi:"ipType"`
// The label you want to give your reserved IP.
Label *string `pulumi:"label"`
// The region ID that you want the reserved IP to be created in.
Region string `pulumi:"region"`
}
// The set of arguments for constructing a ReservedIP resource.
type ReservedIPArgs struct {
// The VPS ID you want this reserved IP to be attached to.
InstanceId pulumi.StringPtrInput
// The type of reserved IP that you want. Either "v4" or "v6".
IpType pulumi.StringInput
// The label you want to give your reserved IP.
Label pulumi.StringPtrInput
// The region ID that you want the reserved IP to be created in.
Region pulumi.StringInput
}
func (ReservedIPArgs) ElementType() reflect.Type {
return reflect.TypeOf((*reservedIPArgs)(nil)).Elem()
}
type ReservedIPInput interface {
pulumi.Input
ToReservedIPOutput() ReservedIPOutput
ToReservedIPOutputWithContext(ctx context.Context) ReservedIPOutput
}
func (*ReservedIP) ElementType() reflect.Type {
return reflect.TypeOf((**ReservedIP)(nil)).Elem()
}
func (i *ReservedIP) ToReservedIPOutput() ReservedIPOutput {
return i.ToReservedIPOutputWithContext(context.Background())
}
func (i *ReservedIP) ToReservedIPOutputWithContext(ctx context.Context) ReservedIPOutput {
return pulumi.ToOutputWithContext(ctx, i).(ReservedIPOutput)
}
// ReservedIPArrayInput is an input type that accepts ReservedIPArray and ReservedIPArrayOutput values.
// You can construct a concrete instance of `ReservedIPArrayInput` via:
//
// ReservedIPArray{ ReservedIPArgs{...} }
type ReservedIPArrayInput interface {
pulumi.Input
ToReservedIPArrayOutput() ReservedIPArrayOutput
ToReservedIPArrayOutputWithContext(context.Context) ReservedIPArrayOutput
}
type ReservedIPArray []ReservedIPInput
func (ReservedIPArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*ReservedIP)(nil)).Elem()
}
func (i ReservedIPArray) ToReservedIPArrayOutput() ReservedIPArrayOutput {
return i.ToReservedIPArrayOutputWithContext(context.Background())
}
func (i ReservedIPArray) ToReservedIPArrayOutputWithContext(ctx context.Context) ReservedIPArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(ReservedIPArrayOutput)
}
// ReservedIPMapInput is an input type that accepts ReservedIPMap and ReservedIPMapOutput values.
// You can construct a concrete instance of `ReservedIPMapInput` via:
//
// ReservedIPMap{ "key": ReservedIPArgs{...} }
type ReservedIPMapInput interface {
pulumi.Input
ToReservedIPMapOutput() ReservedIPMapOutput
ToReservedIPMapOutputWithContext(context.Context) ReservedIPMapOutput
}
type ReservedIPMap map[string]ReservedIPInput
func (ReservedIPMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*ReservedIP)(nil)).Elem()
}
func (i ReservedIPMap) ToReservedIPMapOutput() ReservedIPMapOutput {
return i.ToReservedIPMapOutputWithContext(context.Background())
}
func (i ReservedIPMap) ToReservedIPMapOutputWithContext(ctx context.Context) ReservedIPMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(ReservedIPMapOutput)
}
type ReservedIPOutput struct{ *pulumi.OutputState }
func (ReservedIPOutput) ElementType() reflect.Type {
return reflect.TypeOf((**ReservedIP)(nil)).Elem()
}
func (o ReservedIPOutput) ToReservedIPOutput() ReservedIPOutput {
return o
}
func (o ReservedIPOutput) ToReservedIPOutputWithContext(ctx context.Context) ReservedIPOutput {
return o
}
// The VPS ID you want this reserved IP to be attached to.
func (o ReservedIPOutput) InstanceId() pulumi.StringOutput {
return o.ApplyT(func(v *ReservedIP) pulumi.StringOutput { return v.InstanceId }).(pulumi.StringOutput)
}
// The type of reserved IP that you want. Either "v4" or "v6".
func (o ReservedIPOutput) IpType() pulumi.StringOutput {
return o.ApplyT(func(v *ReservedIP) pulumi.StringOutput { return v.IpType }).(pulumi.StringOutput)
}
// The label you want to give your reserved IP.
func (o ReservedIPOutput) Label() pulumi.StringPtrOutput {
return o.ApplyT(func(v *ReservedIP) pulumi.StringPtrOutput { return v.Label }).(pulumi.StringPtrOutput)
}
// The region ID that you want the reserved IP to be created in.
func (o ReservedIPOutput) Region() pulumi.StringOutput {
return o.ApplyT(func(v *ReservedIP) pulumi.StringOutput { return v.Region }).(pulumi.StringOutput)
}
// The reserved IP's subnet.
func (o ReservedIPOutput) Subnet() pulumi.StringOutput {
return o.ApplyT(func(v *ReservedIP) pulumi.StringOutput { return v.Subnet }).(pulumi.StringOutput)
}
// The reserved IP's subnet size.
func (o ReservedIPOutput) SubnetSize() pulumi.IntOutput {
return o.ApplyT(func(v *ReservedIP) pulumi.IntOutput { return v.SubnetSize }).(pulumi.IntOutput)
}
type ReservedIPArrayOutput struct{ *pulumi.OutputState }
func (ReservedIPArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*ReservedIP)(nil)).Elem()
}
func (o ReservedIPArrayOutput) ToReservedIPArrayOutput() ReservedIPArrayOutput {
return o
}
func (o ReservedIPArrayOutput) ToReservedIPArrayOutputWithContext(ctx context.Context) ReservedIPArrayOutput {
return o
}
func (o ReservedIPArrayOutput) Index(i pulumi.IntInput) ReservedIPOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ReservedIP {
return vs[0].([]*ReservedIP)[vs[1].(int)]
}).(ReservedIPOutput)
}
type ReservedIPMapOutput struct{ *pulumi.OutputState }
func (ReservedIPMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*ReservedIP)(nil)).Elem()
}
func (o ReservedIPMapOutput) ToReservedIPMapOutput() ReservedIPMapOutput {
return o
}
func (o ReservedIPMapOutput) ToReservedIPMapOutputWithContext(ctx context.Context) ReservedIPMapOutput {
return o
}
func (o ReservedIPMapOutput) MapIndex(k pulumi.StringInput) ReservedIPOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ReservedIP {
return vs[0].(map[string]*ReservedIP)[vs[1].(string)]
}).(ReservedIPOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*ReservedIPInput)(nil)).Elem(), &ReservedIP{})
pulumi.RegisterInputType(reflect.TypeOf((*ReservedIPArrayInput)(nil)).Elem(), ReservedIPArray{})
pulumi.RegisterInputType(reflect.TypeOf((*ReservedIPMapInput)(nil)).Elem(), ReservedIPMap{})
pulumi.RegisterOutputType(ReservedIPOutput{})
pulumi.RegisterOutputType(ReservedIPArrayOutput{})
pulumi.RegisterOutputType(ReservedIPMapOutput{})
}