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.
decort-golang-sdk/pkg/cloudbroker/trunk/update.go

55 lines
1.3 KiB

package trunk
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// UpdateRequest struct to update a trunk
type UpdateRequest struct {
// ID of the trunk to update
// Required: true
TrunkID uint64 `url:"id" json:"id" validate:"required"`
// New 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"`
// New description of the trunk
// Required: false
Description string `url:"description,omitempty" json:"description,omitempty"`
// New native VLAN ID
// Required: false
NativeVLANID uint64 `url:"native_vlan_id,omitempty" json:"native_vlan_id,omitempty"`
}
// Update updates a trunk
func (t Trunk) Update(ctx context.Context, req UpdateRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/trunk/update"
res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}