-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(edgegw): Add schema/types (#404)
Co-authored-by: DUBREUIL Valentin <valentin.dubreuil@orange.com>
- Loading branch information
valentin-dubreuil
and
DUBREUIL Valentin
authored
Jul 24, 2023
1 parent
427f579
commit 0522a0a
Showing
11 changed files
with
253 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package edgegw | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hashicorp/terraform-plugin-framework/schema/validator" | ||
"github.com/hashicorp/terraform-plugin-framework/types" | ||
|
||
schemaR "github.com/hashicorp/terraform-plugin-framework/resource/schema" | ||
|
||
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" | ||
"github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" | ||
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" | ||
|
||
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" | ||
|
||
superschema "github.com/FrangipaneTeam/terraform-plugin-framework-superschema" | ||
) | ||
|
||
func portProfilesSchema(_ context.Context) superschema.Schema { | ||
return superschema.Schema{ | ||
Resource: superschema.SchemaDetails{ | ||
MarkdownDescription: "Provides a NSX-T App Port Profile resource", | ||
}, | ||
Attributes: map[string]superschema.Attribute{ | ||
"id": superschema.StringAttribute{ | ||
Common: &schemaR.StringAttribute{ | ||
MarkdownDescription: "The ID of the VM.", | ||
Computed: true, | ||
}, | ||
Resource: &schemaR.StringAttribute{ | ||
PlanModifiers: []planmodifier.String{ | ||
stringplanmodifier.UseStateForUnknown(), | ||
}, | ||
}, | ||
}, | ||
"name": superschema.StringAttribute{ | ||
Common: &schemaR.StringAttribute{ | ||
MarkdownDescription: "Application Port Profile name.", | ||
}, | ||
Resource: &schemaR.StringAttribute{ | ||
Required: true, | ||
}, | ||
}, | ||
"description": superschema.StringAttribute{ | ||
Common: &schemaR.StringAttribute{ | ||
MarkdownDescription: "Application Port Profile description.", | ||
}, | ||
Resource: &schemaR.StringAttribute{ | ||
Optional: true, | ||
PlanModifiers: []planmodifier.String{ | ||
stringplanmodifier.UseStateForUnknown(), | ||
}, | ||
}, | ||
}, | ||
"vdc": superschema.StringAttribute{ | ||
Common: &schemaR.StringAttribute{ | ||
MarkdownDescription: "ID of VDC or VDC Group", | ||
}, | ||
Resource: &schemaR.StringAttribute{ | ||
Required: true, | ||
PlanModifiers: []planmodifier.String{ | ||
stringplanmodifier.RequiresReplace(), | ||
stringplanmodifier.UseStateForUnknown(), | ||
}, | ||
}, | ||
}, | ||
"app_ports": superschema.ListNestedAttribute{ | ||
Common: &schemaR.ListNestedAttribute{ | ||
MarkdownDescription: "List of application ports.", | ||
Required: true, | ||
}, | ||
Attributes: map[string]superschema.Attribute{ | ||
"ports": superschema.SetAttribute{ | ||
Common: &schemaR.SetAttribute{ | ||
MarkdownDescription: "Set of ports or ranges.", | ||
Computed: true, | ||
}, | ||
Resource: &schemaR.SetAttribute{ | ||
Optional: true, | ||
ElementType: types.StringType, | ||
PlanModifiers: []planmodifier.Set{ | ||
setplanmodifier.UseStateForUnknown(), | ||
}, | ||
}, | ||
}, | ||
"protocol": superschema.StringAttribute{ | ||
Common: &schemaR.StringAttribute{ | ||
MarkdownDescription: "Protocol.", | ||
}, | ||
Resource: &schemaR.StringAttribute{ | ||
Required: true, | ||
Validators: []validator.String{ | ||
stringvalidator.OneOf("ICMPv4", "ICMPv6", "TCP", "UDP"), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package edgegw | ||
|
||
import "github.com/hashicorp/terraform-plugin-framework/types" | ||
|
||
type portProfilesResourceModel struct { | ||
ID types.String `tfsdk:"id"` | ||
Name types.String `tfsdk:"name"` | ||
VDC types.String `tfsdk:"vdc"` | ||
Description types.String `tfsdk:"description"` | ||
AppPorts types.List `tfsdk:"app_ports"` | ||
} | ||
|
||
type portProfilesResourceModelAppPorts []portProfilesResourceModelAppPort | ||
|
||
type portProfilesResourceModelAppPort struct { | ||
Protocol types.String `tfsdk:"protocol"` | ||
Ports types.Set `tfsdk:"ports"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package edgegw | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-framework/types" | ||
|
||
"github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" | ||
) | ||
|
||
type edgeGatewaysResourceModel struct { | ||
Timeouts timeouts.Value `tfsdk:"timeouts"` | ||
ID types.String `tfsdk:"id"` | ||
Tier0VrfID types.String `tfsdk:"tier0_vrf_name"` | ||
Name types.String `tfsdk:"name"` | ||
OwnerType types.String `tfsdk:"owner_type"` | ||
OwnerName types.String `tfsdk:"owner_name"` | ||
Description types.String `tfsdk:"description"` | ||
EnableLoadBalancing types.Bool `tfsdk:"lb_enabled"` | ||
} | ||
|
||
type edgeGatewayDataSourceModel struct { | ||
ID types.String `tfsdk:"id"` | ||
Tier0VrfID types.String `tfsdk:"tier0_vrf_name"` | ||
Name types.String `tfsdk:"name"` | ||
OwnerType types.String `tfsdk:"owner_type"` | ||
OwnerName types.String `tfsdk:"owner_name"` | ||
Description types.String `tfsdk:"description"` | ||
EnableLoadBalancing types.Bool `tfsdk:"lb_enabled"` | ||
} |
Oops, something went wrong.