/
static_route_schema.go
148 lines (141 loc) · 5.16 KB
/
static_route_schema.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
package edgegw
import (
"context"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
schemaD "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
schemaR "github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/int64default"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework-validators/int64validator"
"github.com/hashicorp/terraform-plugin-framework-validators/setvalidator"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
superschema "github.com/FrangipaneTeam/terraform-plugin-framework-superschema"
fstringvalidator "github.com/FrangipaneTeam/terraform-plugin-framework-validators/stringvalidator"
)
func staticRouteSchema(_ context.Context) superschema.Schema {
return superschema.Schema{
Resource: superschema.SchemaDetails{
MarkdownDescription: "The `cloudavenue_edgegateway_static_route` resource allows you to create and manage static routes on an Edge Gateway.",
},
DataSource: superschema.SchemaDetails{
MarkdownDescription: "The `cloudavenue_edgegateway_static_route` data source allows you to retrieve information about a static route on an Edge Gateway.",
},
Attributes: map[string]superschema.Attribute{
"id": superschema.SuperStringAttribute{
Common: &schemaR.StringAttribute{
Computed: true,
MarkdownDescription: "The ID of the Static Route.",
},
Resource: &schemaR.StringAttribute{
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
},
"edge_gateway_name": superschema.SuperStringAttribute{
Common: &schemaR.StringAttribute{
MarkdownDescription: "The name of the Edge Gateway.",
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplaceIfConfigured(),
stringplanmodifier.UseStateForUnknown(),
},
Validators: []validator.String{
stringvalidator.ExactlyOneOf(path.MatchRoot("edge_gateway_name"), path.MatchRoot("edge_gateway_id")),
},
},
},
"edge_gateway_id": superschema.SuperStringAttribute{
Common: &schemaR.StringAttribute{
MarkdownDescription: "The ID of the Edge Gateway.",
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplaceIfConfigured(),
stringplanmodifier.UseStateForUnknown(),
},
Validators: []validator.String{
stringvalidator.ExactlyOneOf(path.MatchRoot("edge_gateway_name"), path.MatchRoot("edge_gateway_id")),
},
},
},
"name": superschema.SuperStringAttribute{
Common: &schemaR.StringAttribute{
MarkdownDescription: "The name of the Static Route.",
Required: true,
},
},
"description": superschema.SuperStringAttribute{
Common: &schemaR.StringAttribute{
MarkdownDescription: "The description of the Static Route.",
},
Resource: &schemaR.StringAttribute{
Optional: true,
},
DataSource: &schemaD.StringAttribute{
Computed: true,
},
},
"network_cidr": superschema.SuperStringAttribute{
Common: &schemaR.StringAttribute{
MarkdownDescription: "The network CIDR of the Static Route. (e.g. 192.168.1.0/24)",
},
Resource: &schemaR.StringAttribute{
Required: true,
},
DataSource: &schemaD.StringAttribute{
Computed: true,
},
},
"next_hops": superschema.SuperSetNestedAttribute{
Common: &schemaR.SetNestedAttribute{
MarkdownDescription: "A set of next hops to use within the static route",
},
Resource: &schemaR.SetNestedAttribute{
Required: true,
Validators: []validator.Set{
setvalidator.SizeAtLeast(1),
},
},
DataSource: &schemaD.SetNestedAttribute{
Computed: true,
},
Attributes: map[string]superschema.Attribute{
"ip_address": superschema.SuperStringAttribute{
Common: &schemaR.StringAttribute{
MarkdownDescription: "IP address for next hop gateway IP Address for the Static Route.",
},
Resource: &schemaR.StringAttribute{
Required: true,
Validators: []validator.String{
fstringvalidator.IsIP(),
},
},
DataSource: &schemaD.StringAttribute{
Computed: true,
},
},
"admin_distance": superschema.SuperInt64Attribute{
Common: &schemaR.Int64Attribute{
MarkdownDescription: "Admin distance is used to choose which route to use when there are multiple routes for a specific network. The lower the admin distance, the higher the preference for the route.",
Computed: true,
},
Resource: &schemaR.Int64Attribute{
Optional: true,
Default: int64default.StaticInt64(1),
Validators: []validator.Int64{
int64validator.AtLeast(1),
},
},
DataSource: &schemaD.Int64Attribute{
Computed: true,
},
},
},
},
},
}
}