package dpdknet import ( "context" "net/http" "strconv" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" ) // CreateRequest struct to create DPDK network type CreateRequest struct { // Name of new DPDK network // Required: true Name string `url:"name" json:"name" validate:"required"` // Description of new DPDK network. Prefer to contain additional information about DPDK network. // Required: false Description string `url:"description,omitempty" json:"description,omitempty"` // ID of the grid (platform) // Required: true GID uint64 `url:"gid" json:"gid" validate:"required"` // ID of vlan // Required: true VlanID uint64 `url:"vlanId" json:"vlanId" validate:"required"` // Name of OVS Bridge to use for creating DPDK network on // Required: true OVSBridge string `url:"ovsBridge" json:"ovsBridge" validate:"required"` // List of account IDs to which DPDK network will be available. Empty field means all accounts in the system. // Required: false AccountAccess []uint64 `url:"accountAccess,omitempty" json:"accountAccess,omitempty"` // List of resource groups IDs to which DPDK network will be available. Empty field means all resource groups in the system. // Required: false RGAccess []uint64 `url:"rgAccess,omitempty" json:"rgAccess,omitempty"` } // Create creates a DPDK networks func (d DPDKNet) Create(ctx context.Context, req CreateRequest) (uint64, error) { err := validators.ValidateRequest(req) if err != nil { return 0, validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudbroker/dpdknet/create" res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req) if err != nil { return 0, err } result, err := strconv.ParseUint(string(res), 10, 64) if err != nil { return 0, err } return result, nil }