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.

77 lines
3.0 KiB

2 months ago
package models
import (
"github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts"
"github.com/hashicorp/terraform-plugin-framework/types"
)
type ResourceRGModel struct {
// request fields - required
AccountID types.Int64 `tfsdk:"account_id"`
GID types.Int64 `tfsdk:"gid"`
Name types.String `tfsdk:"rg_name"`
// request fields - optional
DefNetType types.String `tfsdk:"def_net_type"`
IPCIDR types.String `tfsdk:"ipcidr"`
ExtNetID types.Int64 `tfsdk:"ext_net_id"`
ExtIP types.String `tfsdk:"ext_ip"`
Owner types.String `tfsdk:"owner"`
ResourceLimits types.Object `tfsdk:"resource_limits"`
CPUAllocationParameter types.String `tfsdk:"cpu_allocation_parameter"`
CPUAllocationRatio types.Float64 `tfsdk:"cpu_allocation_ratio"`
Access types.List `tfsdk:"access"`
DefNet types.Object `tfsdk:"def_net"`
Description types.String `tfsdk:"description"`
Force types.Bool `tfsdk:"force"`
Permanently types.Bool `tfsdk:"permanently"`
RegisterComputes types.Bool `tfsdk:"register_computes"`
Restore types.Bool `tfsdk:"restore"`
Enable types.Bool `tfsdk:"enable"`
Timeouts timeouts.Value `tfsdk:"timeouts"`
// response fields
RGID types.Int64 `tfsdk:"rg_id"`
LastUpdated types.String `tfsdk:"last_updated"`
AccountName types.String `tfsdk:"account_name"`
ACL types.List `tfsdk:"acl"`
ComputeFeatures types.List `tfsdk:"compute_features"`
CreatedBy types.String `tfsdk:"created_by"`
CreatedTime types.Int64 `tfsdk:"created_time"`
DefNetID types.Int64 `tfsdk:"def_net_id"`
DeletedBy types.String `tfsdk:"deleted_by"`
DeletedTime types.Int64 `tfsdk:"deleted_time"`
GUID types.Int64 `tfsdk:"guid"`
Id types.String `tfsdk:"id"`
LockStatus types.String `tfsdk:"lock_status"`
Milestones types.Int64 `tfsdk:"milestones"`
Secret types.String `tfsdk:"secret"`
Status types.String `tfsdk:"status"`
UniqPools types.List `tfsdk:"uniq_pools"`
UpdatedBy types.String `tfsdk:"updated_by"`
UpdatedTime types.Int64 `tfsdk:"updated_time"`
ResourceTypes types.List `tfsdk:"resource_types"`
VINS types.List `tfsdk:"vins"`
VMS types.List `tfsdk:"vms"`
}
type AccessModel struct {
User types.String `tfsdk:"user"`
Right types.String `tfsdk:"right"`
}
type DefNetModel struct {
NetType types.String `tfsdk:"net_type"`
NetId types.Int64 `tfsdk:"net_id"`
}
// Contains returns true if accessList contains a as an element. Otherwise it returns false.
func (a *AccessModel) Contains(accessList []AccessModel) bool {
for _, accessElem := range accessList {
if a.User.Equal(accessElem.User) && a.Right.Equal(accessElem.Right) {
return true
}
}
return false
}