You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

317 lines
7.4 KiB

6 months ago
package schemas
import (
"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/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/types"
)
func MakeSchemaResourceLB() map[string]schema.Attribute {
return map[string]schema.Attribute{
// required attributes
"rg_id": schema.Int64Attribute{
Required: true,
},
"name": schema.StringAttribute{
Required: true,
},
"extnet_id": schema.Int64Attribute{
Required: true,
},
"vins_id": schema.Int64Attribute{
Required: true,
},
"start": schema.BoolAttribute{
Required: true,
},
// optional attributes
"ha_mode": schema.BoolAttribute{
Optional: true,
Computed: true,
},
"desc": schema.StringAttribute{
Optional: true,
Computed: true,
},
"enable": schema.BoolAttribute{
Optional: true,
},
"restart": schema.BoolAttribute{
Optional: true,
},
"config_reset": schema.BoolAttribute{
Optional: true,
},
"permanently": schema.BoolAttribute{
Optional: true,
},
"restore": schema.BoolAttribute{
Optional: true,
},
"safe": schema.BoolAttribute{
// Default: true
Optional: true,
},
"sysctl_params": schema.ListNestedAttribute{
Optional: true,
Description: "Custom sysctl values for Load Balancer instance. Applied on boot.",
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"key": schema.StringAttribute{
Required: true,
},
"value": schema.StringAttribute{
Required: true,
},
},
},
},
"acl": schema.StringAttribute{
Computed: true,
},
"backend_haip": schema.StringAttribute{
Computed: true,
},
"backends": schema.ListNestedAttribute{
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"algorithm": schema.StringAttribute{
Computed: true,
},
"guid": schema.StringAttribute{
Computed: true,
},
"name": schema.StringAttribute{
Computed: true,
},
"server_default_settings": schema.SingleNestedAttribute{
Computed: true,
Attributes: map[string]schema.Attribute{
"downinter": schema.Int64Attribute{
Computed: true,
},
"fall": schema.Int64Attribute{
Computed: true,
},
"guid": schema.StringAttribute{
Computed: true,
},
"inter": schema.Int64Attribute{
Computed: true,
},
"maxconn": schema.Int64Attribute{
Computed: true,
},
"maxqueue": schema.Int64Attribute{
Computed: true,
},
"rise": schema.Int64Attribute{
Computed: true,
},
"slowstart": schema.Int64Attribute{
Computed: true,
},
"weight": schema.Int64Attribute{
Computed: true,
},
},
},
"servers": schema.ListNestedAttribute{
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"address": schema.StringAttribute{
Computed: true,
},
"check": schema.StringAttribute{
Computed: true,
},
"guid": schema.StringAttribute{
Computed: true,
},
"name": schema.StringAttribute{
Computed: true,
},
"port": schema.Int64Attribute{
Computed: true,
},
"server_settings": schema.SingleNestedAttribute{
Computed: true,
Attributes: map[string]schema.Attribute{
"downinter": schema.Int64Attribute{
Computed: true,
},
"fall": schema.Int64Attribute{
Computed: true,
},
"guid": schema.StringAttribute{
Computed: true,
},
"inter": schema.Int64Attribute{
Computed: true,
},
"maxconn": schema.Int64Attribute{
Computed: true,
},
"maxqueue": schema.Int64Attribute{
Computed: true,
},
"rise": schema.Int64Attribute{
Computed: true,
},
"slowstart": schema.Int64Attribute{
Computed: true,
},
"weight": schema.Int64Attribute{
Computed: true,
},
},
},
},
},
},
},
},
},
"ckey": schema.StringAttribute{
Computed: true,
},
"meta": schema.ListAttribute{
Computed: true,
ElementType: types.StringType,
},
"dp_api_user": schema.StringAttribute{
Computed: true,
},
"dp_api_password": schema.StringAttribute{
Computed: true,
},
"frontend_haip": schema.StringAttribute{
Computed: true,
},
"frontends": schema.ListNestedAttribute{
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"backend": schema.StringAttribute{
Computed: true,
},
"bindings": schema.ListNestedAttribute{
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"address": schema.StringAttribute{
Computed: true,
},
"guid": schema.StringAttribute{
Computed: true,
},
"name": schema.StringAttribute{
Computed: true,
},
"port": schema.Int64Attribute{
Computed: true,
},
},
},
},
"guid": schema.StringAttribute{
Computed: true,
},
"name": schema.StringAttribute{
Computed: true,
},
},
},
},
"gid": schema.Int64Attribute{
Computed: true,
},
"guid": schema.Int64Attribute{
Computed: true,
},
"id": schema.StringAttribute{
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"lb_id": schema.Int64Attribute{
Computed: true,
},
"manager_id": schema.Int64Attribute{
Computed: true,
},
"manager_type": schema.StringAttribute{
Computed: true,
},
"image_id": schema.Int64Attribute{
Computed: true,
},
"milestones": schema.Int64Attribute{
Computed: true,
},
"part_k8s": schema.BoolAttribute{
Computed: true,
},
"primary_node": schema.SingleNestedAttribute{
Computed: true,
Attributes: map[string]schema.Attribute{
"backend_ip": schema.StringAttribute{
Computed: true,
},
"compute_id": schema.Int64Attribute{
Computed: true,
},
"frontend_ip": schema.StringAttribute{
Computed: true,
},
"guid": schema.StringAttribute{
Computed: true,
},
"mgmt_ip": schema.StringAttribute{
Computed: true,
},
"network_id": schema.Int64Attribute{
Computed: true,
},
},
},
"secondary_node": schema.SingleNestedAttribute{
Computed: true,
Attributes: map[string]schema.Attribute{
"backend_ip": schema.StringAttribute{
Computed: true,
},
"compute_id": schema.Int64Attribute{
Computed: true,
},
"frontend_ip": schema.StringAttribute{
Computed: true,
},
"guid": schema.StringAttribute{
Computed: true,
},
"mgmt_ip": schema.StringAttribute{
Computed: true,
},
"network_id": schema.Int64Attribute{
Computed: true,
},
},
},
"status": schema.StringAttribute{
Computed: true,
},
"tech_status": schema.StringAttribute{
Computed: true,
},
"user_managed": schema.BoolAttribute{
Computed: true,
},
}
}