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/storage_policy/update.go

57 lines
1.4 KiB

package storagepolicy
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
type UpdateRequest struct {
// ID of storage policy
// Required: true
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
// New name for the storage policy
// Required: false
Name string `url:"name,omitempty" json:"name,omitempty"`
// New value for limit IOPS
// Required: false
LimitIOPS uint64 `url:"limit_iops,omitempty" json:"limit_iops,omitempty"`
// New description of the storage policy
// Required: false
Description string `url:"description,omitempty" json:"description,omitempty"`
}
// Update updates storage policy
func (sp StoragePolicy) Update(ctx context.Context, req UpdateRequest) (*InfoStoragePolicyWithID, error) {
res, err := sp.UpdateRaw(ctx, req)
if err != nil {
return nil, err
}
info := InfoStoragePolicyWithID{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return &info, nil
}
func (sp StoragePolicy) UpdateRaw(ctx context.Context, req UpdateRequest) ([]byte, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/storage_policy/update"
res, err := sp.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}