v1.16.4
v1.16.4
This commit is contained in:
46
pkg/cloudapi/stpolicy/get_replication_profile.go
Normal file
46
pkg/cloudapi/stpolicy/get_replication_profile.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package stpolicy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GetReplicationProfileRequest struct to get replication profile
|
||||
type GetReplicationProfileRequest struct {
|
||||
// ID of replication profile
|
||||
// Required: true
|
||||
ProfileID uint64 `url:"profile_id" json:"profile_id" validate:"required"`
|
||||
}
|
||||
|
||||
// GetReplicationProfile gets replication profile as an InfoReplicationProfile struct
|
||||
func (sp StPolicy) GetReplicationProfile(ctx context.Context, req GetReplicationProfileRequest) (*InfoReplicationProfile, error) {
|
||||
res, err := sp.GetReplicationProfileRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := InfoReplicationProfile{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetReplicationProfileRaw gets replication profile as an array of bytes
|
||||
func (sp StPolicy) GetReplicationProfileRaw(ctx context.Context, req GetReplicationProfileRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/storage_policy/get_replication_profile"
|
||||
|
||||
res, err := sp.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||
return res, err
|
||||
}
|
||||
65
pkg/cloudapi/stpolicy/list_replication_profile.go
Normal file
65
pkg/cloudapi/stpolicy/list_replication_profile.go
Normal file
@@ -0,0 +1,65 @@
|
||||
package stpolicy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListReplicationProfileRequest struct to get list of replication profiles
|
||||
type ListReplicationProfileRequest struct {
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
// Page size
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
|
||||
// Search by replication profile ID
|
||||
// Required: false
|
||||
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
|
||||
|
||||
// Search by replication profile name
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// Search by replication type
|
||||
// Required: false
|
||||
ReplicationType string `url:"replication_type,omitempty" json:"replication_type,omitempty"`
|
||||
|
||||
// Sort by one of supported fields, format ±<field>
|
||||
// Required: false
|
||||
SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"`
|
||||
}
|
||||
|
||||
// ListReplicationProfile gets list of replication profiles as a ListReplicationProfiles struct
|
||||
func (sp StPolicy) ListReplicationProfile(ctx context.Context, req ListReplicationProfileRequest) (*ListReplicationProfiles, error) {
|
||||
res, err := sp.ListReplicationProfileRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := ListReplicationProfiles{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
// ListReplicationProfileRaw gets list of replication profiles as an array of bytes
|
||||
func (sp StPolicy) ListReplicationProfileRaw(ctx context.Context, req ListReplicationProfileRequest) ([]byte, error) {
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/storage_policy/list_replication_profile"
|
||||
|
||||
res, err := sp.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||
return res, err
|
||||
}
|
||||
@@ -27,9 +27,12 @@ type ItemStoragePolicy struct {
|
||||
// Status of the storage policy
|
||||
Status string `json:"status"`
|
||||
|
||||
// Max IOPS for the sotrage policy
|
||||
// Max IOPS for the storage policy
|
||||
LimitIOPS uint64 `json:"limit_iops"`
|
||||
|
||||
// ID of the replication profile
|
||||
ReplicationProfileID uint64 `json:"replication_profile_id"`
|
||||
|
||||
// Storage policy ID
|
||||
StoragePolicyID uint64 `json:"storage_policy_id"`
|
||||
|
||||
@@ -56,9 +59,12 @@ type InfoStoragePolicy struct {
|
||||
// Status of the storage policy
|
||||
Status string `json:"status"`
|
||||
|
||||
// Max IOPS for the sotrage policy
|
||||
// Max IOPS for the storage policy
|
||||
LimitIOPS uint64 `json:"limit_iops"`
|
||||
|
||||
// ID of the replication profile
|
||||
ReplicationProfileID uint64 `json:"replication_profile_id"`
|
||||
|
||||
// ID of the storage policy
|
||||
StoragePolicyID uint64 `json:"storage_policy_id"`
|
||||
|
||||
@@ -89,3 +95,72 @@ type Usage struct {
|
||||
// List of resource groups
|
||||
Resgroups []uint64 `json:"resgroups"`
|
||||
}
|
||||
|
||||
type ListReplicationProfiles struct {
|
||||
// List
|
||||
Data []ItemReplicationProfile `json:"data"`
|
||||
|
||||
// Entry Count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
type ItemReplicationProfile struct {
|
||||
// ID of the replication profile
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// GUID
|
||||
GUID uint64 `json:"guid"`
|
||||
|
||||
// Name of the replication profile
|
||||
Name string `json:"name"`
|
||||
|
||||
// Replication types
|
||||
ReplicationType []string `json:"replication_type"`
|
||||
|
||||
// Max copy rate
|
||||
MAXCopyRate uint64 `json:"max_copy_rate"`
|
||||
|
||||
// List of schedules
|
||||
Schedules ListSchedules `json:"schedules"`
|
||||
}
|
||||
|
||||
type InfoReplicationProfile struct {
|
||||
// ID of the replication profile
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// GUID
|
||||
GUID uint64 `json:"guid"`
|
||||
|
||||
// Name of the replication profile
|
||||
Name string `json:"name"`
|
||||
|
||||
// Replication types
|
||||
ReplicationType []string `json:"replication_type"`
|
||||
|
||||
// Max copy rate
|
||||
MAXCopyRate uint64 `json:"max_copy_rate"`
|
||||
|
||||
// List of schedules
|
||||
Schedules ListSchedules `json:"schedules"`
|
||||
}
|
||||
|
||||
type ListSchedules []Schedule
|
||||
|
||||
type Schedule struct {
|
||||
// Type of the schedule
|
||||
Type string `json:"type"`
|
||||
|
||||
// Name of the schedule
|
||||
Name string `json:"name"`
|
||||
|
||||
// Min interval
|
||||
MINInterval uint64 `json:"min_interval"`
|
||||
|
||||
// Calendar of the schedule
|
||||
Calendar Calendar `json:"calendar"`
|
||||
}
|
||||
|
||||
type Calendar struct {
|
||||
// Weekly schedule
|
||||
Weekly map[string][]string `json:"weekly"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user