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.
91 lines
2.3 KiB
91 lines
2.3 KiB
package stpolicy
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
)
|
|
|
|
type ListRequest struct {
|
|
// ID of account ID
|
|
// Required: true
|
|
AccountID uint64 `url:"account_id" json:"account_id" validate:"required"`
|
|
|
|
// 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 storage policy ID
|
|
// Required: false
|
|
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
|
|
|
|
// Search by storage policy name
|
|
// Required: false
|
|
Name string `url:"name,omitempty" json:"name,omitempty"`
|
|
|
|
// Search by storage policy status
|
|
// Required: false
|
|
Status string `url:"status,omitempty" json:"status,omitempty"`
|
|
|
|
// Search by storage policy desc
|
|
// Required: false
|
|
Desc string `url:"desc,omitempty" json:"desc,omitempty"`
|
|
|
|
// Search by storage policy iops limit
|
|
// Required: false
|
|
LimitIOPS uint64 `url:"limit_iops,omitempty" json:"limit_iops,omitempty"`
|
|
|
|
// Sort by one of supported fields, format ±<field>
|
|
// Required: false
|
|
SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"`
|
|
|
|
// Search by resgroup id
|
|
// Required: false
|
|
ResgroupID uint64 `url:"resgroup_id,omitempty" json:"resgroup_id,omitempty"`
|
|
|
|
// Search by sep id
|
|
// Required: false
|
|
SepID uint64 `url:"sep_id,omitempty" json:"sep_id,omitempty"`
|
|
|
|
// Search by pool name
|
|
// Required: false
|
|
PoolName string `url:"pool_name,omitempty" json:"pool_name,omitempty"`
|
|
}
|
|
|
|
// List gets list of storage policies as a ListStoragePolicies struct
|
|
func (sp StPolicy) List(ctx context.Context, req ListRequest) (*ListStoragePolicies, error) {
|
|
|
|
res, err := sp.ListRaw(ctx, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
list := ListStoragePolicies{}
|
|
|
|
err = json.Unmarshal(res, &list)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &list, nil
|
|
}
|
|
|
|
// ListRaw gets list of storage policies as an array of bytes
|
|
func (sp StPolicy) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
|
|
if err := validators.ValidateRequest(req); err != nil {
|
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
}
|
|
|
|
url := "/cloudapi/storage_policy/list"
|
|
|
|
res, err := sp.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
|
return res, err
|
|
}
|