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.
59 lines
1.4 KiB
59 lines
1.4 KiB
package trunk
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
)
|
|
|
|
// CreateRequest struct to create a trunk
|
|
type CreateRequest struct {
|
|
// Name of the trunk
|
|
// Required: true
|
|
Name string `url:"name" json:"name" validate:"required"`
|
|
|
|
// List of trunk tags (values between 1-4095)
|
|
// Required: true
|
|
TrunkTags string `url:"trunk_tags" json:"trunk_tags" validate:"required,trunkTags"`
|
|
|
|
// OVS bridge name
|
|
// Required: true
|
|
OVSBridge string `url:"ovs_bridge" json:"ovs_bridge" validate:"required"`
|
|
|
|
// Description of the trunk
|
|
// Required: false
|
|
Description string `url:"description,omitempty" json:"description,omitempty"`
|
|
|
|
// List of account IDs with access to this trunk
|
|
// Required: false
|
|
AccountIDs []uint64 `url:"account_ids,omitempty" json:"account_ids,omitempty"`
|
|
|
|
// Native VLAN ID
|
|
// Required: false
|
|
NativeVLANID uint64 `url:"native_vlan_id,omitempty" json:"native_vlan_id,omitempty"`
|
|
}
|
|
|
|
// Create creates a user.
|
|
func (t Trunk) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
|
err := validators.ValidateRequest(req)
|
|
if err != nil {
|
|
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
|
}
|
|
|
|
url := "/cloudbroker/trunk/create"
|
|
|
|
res, err := t.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
|
|
}
|