71 lines
2.1 KiB
Go
71 lines
2.1 KiB
Go
package stpolicy
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
)
|
|
|
|
// ConfigRequest struct for replication profile config
|
|
type ConfigRequest struct {
|
|
// New name of the replication profile
|
|
// Required: false
|
|
Name string `url:"name,omitempty" json:"name,omitempty"`
|
|
|
|
// New replication type
|
|
// Required: false
|
|
ReplicationType string `url:"replication_type,omitempty" json:"replication_type,omitempty"`
|
|
|
|
// New max copy rate
|
|
// Required: false
|
|
MAXCopyRate uint64 `url:"max_copy_rate,omitempty" json:"max_copy_rate,omitempty"`
|
|
|
|
// New list of schedules
|
|
// Required: false
|
|
Schedules []SchedulesRequest `url:"schedules,omitempty" json:"schedules,omitempty" validate:"omitempty,dive"`
|
|
}
|
|
|
|
// UpdateReplicationProfileRequest struct to update replication profile
|
|
type UpdateReplicationProfileRequest struct {
|
|
// ID of replication profile
|
|
// Required: true
|
|
ProfileID uint64 `url:"profile_id" json:"profile_id" validate:"required"`
|
|
|
|
// Config of the replication profile
|
|
// Required: true
|
|
Config []ConfigRequest `url:"config" json:"config" validate:"required,dive"`
|
|
}
|
|
|
|
// UpdateReplicationProfile updates replication profile
|
|
func (sp StPolicy) UpdateReplicationProfile(ctx context.Context, req UpdateReplicationProfileRequest) (*InfoReplicationProfile, error) {
|
|
res, err := sp.UpdateReplicationProfileRaw(ctx, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
info := InfoReplicationProfile{}
|
|
|
|
err = json.Unmarshal(res, &info)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &info, nil
|
|
}
|
|
|
|
// UpdateReplicationProfileRaw updates replication profile and returns result as an array of bytes
|
|
func (sp StPolicy) UpdateReplicationProfileRaw(ctx context.Context, req UpdateReplicationProfileRequest) ([]byte, error) {
|
|
err := validators.ValidateRequest(req)
|
|
if err != nil {
|
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
}
|
|
|
|
url := "/cloudbroker/storage_policy/update_replication_profile"
|
|
|
|
res, err := sp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
|
return res, err
|
|
}
|