v1.0.0
This commit is contained in:
@@ -7,16 +7,21 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for create snapshot
|
||||
type SnapshotCreateRequest struct {
|
||||
// ID of the Basic Service
|
||||
// Required: true
|
||||
ServiceID uint64 `url:"serviceId"`
|
||||
Label string `url:"label"`
|
||||
|
||||
// Label of the snapshot
|
||||
// Required: true
|
||||
Label string `url:"label"`
|
||||
}
|
||||
|
||||
func (bsrq SnapshotCreateRequest) Validate() error {
|
||||
func (bsrq SnapshotCreateRequest) validate() error {
|
||||
if bsrq.ServiceID == 0 {
|
||||
return errors.New("field ServiceID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if bsrq.Label == "" {
|
||||
return errors.New("field Label can not be empty")
|
||||
}
|
||||
@@ -24,16 +29,24 @@ func (bsrq SnapshotCreateRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// SnapshotCreate create snapshot of the Basic Service
|
||||
func (b BService) SnapshotCreate(ctx context.Context, req SnapshotCreateRequest) (bool, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/bservice/snapshotCreate"
|
||||
|
||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return strconv.ParseBool(string(res))
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user