v12.0.0
This commit is contained in:
56
pkg/cloudbroker/stpolicy/update.go
Normal file
56
pkg/cloudbroker/stpolicy/update.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package stpolicy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/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 StPolicy) 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 StPolicy) 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
|
||||
}
|
||||
Reference in New Issue
Block a user