/
rule.go
300 lines (249 loc) · 8.96 KB
/
rule.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
// 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 pvtz
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Provides a Private Zone Rule resource.
//
// For information about Private Zone Rule and how to use it, see [What is Rule](https://www.alibabacloud.com/help/en/privatezone/latest/add-forwarding-rule).
//
// > **NOTE:** Available since v1.143.0.
//
// ## Import
//
// Private Zone Rule can be imported using the id, e.g.
//
// ```sh
// $ pulumi import alicloud:pvtz/rule:Rule example <id>
// ```
type Rule struct {
pulumi.CustomResourceState
// The ID of the Endpoint.
EndpointId pulumi.StringOutput `pulumi:"endpointId"`
// Forwarding target. See `forwardIps` below.
ForwardIps RuleForwardIpArrayOutput `pulumi:"forwardIps"`
// The name of the resource.
RuleName pulumi.StringOutput `pulumi:"ruleName"`
// The type of the rule. Valid values: `OUTBOUND`.
Type pulumi.StringPtrOutput `pulumi:"type"`
// The name of the forwarding zone.
ZoneName pulumi.StringOutput `pulumi:"zoneName"`
}
// NewRule registers a new resource with the given unique name, arguments, and options.
func NewRule(ctx *pulumi.Context,
name string, args *RuleArgs, opts ...pulumi.ResourceOption) (*Rule, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.EndpointId == nil {
return nil, errors.New("invalid value for required argument 'EndpointId'")
}
if args.ForwardIps == nil {
return nil, errors.New("invalid value for required argument 'ForwardIps'")
}
if args.RuleName == nil {
return nil, errors.New("invalid value for required argument 'RuleName'")
}
if args.ZoneName == nil {
return nil, errors.New("invalid value for required argument 'ZoneName'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource Rule
err := ctx.RegisterResource("alicloud:pvtz/rule:Rule", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetRule gets an existing Rule 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 GetRule(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *RuleState, opts ...pulumi.ResourceOption) (*Rule, error) {
var resource Rule
err := ctx.ReadResource("alicloud:pvtz/rule:Rule", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Rule resources.
type ruleState struct {
// The ID of the Endpoint.
EndpointId *string `pulumi:"endpointId"`
// Forwarding target. See `forwardIps` below.
ForwardIps []RuleForwardIp `pulumi:"forwardIps"`
// The name of the resource.
RuleName *string `pulumi:"ruleName"`
// The type of the rule. Valid values: `OUTBOUND`.
Type *string `pulumi:"type"`
// The name of the forwarding zone.
ZoneName *string `pulumi:"zoneName"`
}
type RuleState struct {
// The ID of the Endpoint.
EndpointId pulumi.StringPtrInput
// Forwarding target. See `forwardIps` below.
ForwardIps RuleForwardIpArrayInput
// The name of the resource.
RuleName pulumi.StringPtrInput
// The type of the rule. Valid values: `OUTBOUND`.
Type pulumi.StringPtrInput
// The name of the forwarding zone.
ZoneName pulumi.StringPtrInput
}
func (RuleState) ElementType() reflect.Type {
return reflect.TypeOf((*ruleState)(nil)).Elem()
}
type ruleArgs struct {
// The ID of the Endpoint.
EndpointId string `pulumi:"endpointId"`
// Forwarding target. See `forwardIps` below.
ForwardIps []RuleForwardIp `pulumi:"forwardIps"`
// The name of the resource.
RuleName string `pulumi:"ruleName"`
// The type of the rule. Valid values: `OUTBOUND`.
Type *string `pulumi:"type"`
// The name of the forwarding zone.
ZoneName string `pulumi:"zoneName"`
}
// The set of arguments for constructing a Rule resource.
type RuleArgs struct {
// The ID of the Endpoint.
EndpointId pulumi.StringInput
// Forwarding target. See `forwardIps` below.
ForwardIps RuleForwardIpArrayInput
// The name of the resource.
RuleName pulumi.StringInput
// The type of the rule. Valid values: `OUTBOUND`.
Type pulumi.StringPtrInput
// The name of the forwarding zone.
ZoneName pulumi.StringInput
}
func (RuleArgs) ElementType() reflect.Type {
return reflect.TypeOf((*ruleArgs)(nil)).Elem()
}
type RuleInput interface {
pulumi.Input
ToRuleOutput() RuleOutput
ToRuleOutputWithContext(ctx context.Context) RuleOutput
}
func (*Rule) ElementType() reflect.Type {
return reflect.TypeOf((**Rule)(nil)).Elem()
}
func (i *Rule) ToRuleOutput() RuleOutput {
return i.ToRuleOutputWithContext(context.Background())
}
func (i *Rule) ToRuleOutputWithContext(ctx context.Context) RuleOutput {
return pulumi.ToOutputWithContext(ctx, i).(RuleOutput)
}
// RuleArrayInput is an input type that accepts RuleArray and RuleArrayOutput values.
// You can construct a concrete instance of `RuleArrayInput` via:
//
// RuleArray{ RuleArgs{...} }
type RuleArrayInput interface {
pulumi.Input
ToRuleArrayOutput() RuleArrayOutput
ToRuleArrayOutputWithContext(context.Context) RuleArrayOutput
}
type RuleArray []RuleInput
func (RuleArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Rule)(nil)).Elem()
}
func (i RuleArray) ToRuleArrayOutput() RuleArrayOutput {
return i.ToRuleArrayOutputWithContext(context.Background())
}
func (i RuleArray) ToRuleArrayOutputWithContext(ctx context.Context) RuleArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(RuleArrayOutput)
}
// RuleMapInput is an input type that accepts RuleMap and RuleMapOutput values.
// You can construct a concrete instance of `RuleMapInput` via:
//
// RuleMap{ "key": RuleArgs{...} }
type RuleMapInput interface {
pulumi.Input
ToRuleMapOutput() RuleMapOutput
ToRuleMapOutputWithContext(context.Context) RuleMapOutput
}
type RuleMap map[string]RuleInput
func (RuleMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Rule)(nil)).Elem()
}
func (i RuleMap) ToRuleMapOutput() RuleMapOutput {
return i.ToRuleMapOutputWithContext(context.Background())
}
func (i RuleMap) ToRuleMapOutputWithContext(ctx context.Context) RuleMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(RuleMapOutput)
}
type RuleOutput struct{ *pulumi.OutputState }
func (RuleOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Rule)(nil)).Elem()
}
func (o RuleOutput) ToRuleOutput() RuleOutput {
return o
}
func (o RuleOutput) ToRuleOutputWithContext(ctx context.Context) RuleOutput {
return o
}
// The ID of the Endpoint.
func (o RuleOutput) EndpointId() pulumi.StringOutput {
return o.ApplyT(func(v *Rule) pulumi.StringOutput { return v.EndpointId }).(pulumi.StringOutput)
}
// Forwarding target. See `forwardIps` below.
func (o RuleOutput) ForwardIps() RuleForwardIpArrayOutput {
return o.ApplyT(func(v *Rule) RuleForwardIpArrayOutput { return v.ForwardIps }).(RuleForwardIpArrayOutput)
}
// The name of the resource.
func (o RuleOutput) RuleName() pulumi.StringOutput {
return o.ApplyT(func(v *Rule) pulumi.StringOutput { return v.RuleName }).(pulumi.StringOutput)
}
// The type of the rule. Valid values: `OUTBOUND`.
func (o RuleOutput) Type() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Rule) pulumi.StringPtrOutput { return v.Type }).(pulumi.StringPtrOutput)
}
// The name of the forwarding zone.
func (o RuleOutput) ZoneName() pulumi.StringOutput {
return o.ApplyT(func(v *Rule) pulumi.StringOutput { return v.ZoneName }).(pulumi.StringOutput)
}
type RuleArrayOutput struct{ *pulumi.OutputState }
func (RuleArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Rule)(nil)).Elem()
}
func (o RuleArrayOutput) ToRuleArrayOutput() RuleArrayOutput {
return o
}
func (o RuleArrayOutput) ToRuleArrayOutputWithContext(ctx context.Context) RuleArrayOutput {
return o
}
func (o RuleArrayOutput) Index(i pulumi.IntInput) RuleOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Rule {
return vs[0].([]*Rule)[vs[1].(int)]
}).(RuleOutput)
}
type RuleMapOutput struct{ *pulumi.OutputState }
func (RuleMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Rule)(nil)).Elem()
}
func (o RuleMapOutput) ToRuleMapOutput() RuleMapOutput {
return o
}
func (o RuleMapOutput) ToRuleMapOutputWithContext(ctx context.Context) RuleMapOutput {
return o
}
func (o RuleMapOutput) MapIndex(k pulumi.StringInput) RuleOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Rule {
return vs[0].(map[string]*Rule)[vs[1].(string)]
}).(RuleOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*RuleInput)(nil)).Elem(), &Rule{})
pulumi.RegisterInputType(reflect.TypeOf((*RuleArrayInput)(nil)).Elem(), RuleArray{})
pulumi.RegisterInputType(reflect.TypeOf((*RuleMapInput)(nil)).Elem(), RuleMap{})
pulumi.RegisterOutputType(RuleOutput{})
pulumi.RegisterOutputType(RuleArrayOutput{})
pulumi.RegisterOutputType(RuleMapOutput{})
}