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.
44 lines
916 B
44 lines
916 B
package flipgroup
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"strconv"
|
|
|
|
"github.com/rudecs/decort-sdk/opts"
|
|
"github.com/rudecs/decort-sdk/typed"
|
|
)
|
|
|
|
type EditRequest struct {
|
|
FlipGroupID uint64 `url:"flipgroupId"`
|
|
Name string `url:"name,omitempty"`
|
|
Description string `url:"desc,omitempty"`
|
|
}
|
|
|
|
func (frq EditRequest) Validate() error {
|
|
if frq.FlipGroupID == 0 {
|
|
return errors.New("field FlipGroupID can not be empty or equal to 0")
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (f FlipGroup) Edit(ctx context.Context, req EditRequest, options ...opts.DecortOpts) (bool, error) {
|
|
if err := req.Validate(); err != nil {
|
|
return false, err
|
|
}
|
|
|
|
url := "/cloudapi/flipgroup/edit"
|
|
res, err := f.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
result, err := strconv.ParseBool(string(res))
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
return result, nil
|
|
}
|