This commit is contained in:
asteam
2025-09-27 01:06:15 +03:00
parent 1ccc37a104
commit cf584c8123
1175 changed files with 11022 additions and 1832 deletions

View File

@@ -0,0 +1,43 @@
package stpolicy
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
)
type GetRequest struct {
// ID of storage policy
// Required: true
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
}
func (sp StPolicy) Get(ctx context.Context, req GetRequest) (*InfoStoragePolicy, error) {
res, err := sp.GetRaw(ctx, req)
if err != nil {
return nil, err
}
info := InfoStoragePolicy{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return &info, nil
}
func (sp StPolicy) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/storage_policy/get"
res, err := sp.client.DecortApiCall(ctx, http.MethodGet, url, req)
return res, err
}

View File

@@ -0,0 +1,90 @@
package stpolicy
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
)
type ListRequest 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 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"`
// ID of account ID
// Required: false
AccountID uint64 `url:"account_id,omitempty" json:"account_id,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
}

View File

@@ -0,0 +1,82 @@
package stpolicy
type ListStoragePolicies struct {
// List
Data []ItemStoragePolicy `json:"data"`
// Entry Count
EntryCount uint64 `json:"entryCount"`
}
type ItemStoragePolicy struct {
// ID of the storage policy
ID uint64 `json:"id"`
// GUID
GUID uint64 `json:"guid"`
// Name of the storage policy
Name string `json:"name"`
// Description of the storage policy
Description string `json:"description"`
// List of pools in SEP for storage policy
AccessSEPPools ListAccessSEPPools `json:"access_seps_pools"`
// Status of the storage policy
Status string `json:"status"`
// Max IOPS for the sotrage policy
LimitIOPS uint64 `json:"limit_iops"`
// Which accounts and resource groups use the storage policy
Usage Usage `json:"usage"`
}
type InfoStoragePolicy struct {
// ID of the storage policy
ID uint64 `json:"id"`
// GUID
GUID uint64 `json:"guid"`
// Name of the storage policy
Name string `json:"name"`
// Description of the storage policy
Description string `json:"description"`
// List of pools in SEP for storage policy
AccessSEPPools ListAccessSEPPools `json:"access_seps_pools"`
// Status of the storage policy
Status string `json:"status"`
// Max IOPS for the sotrage policy
LimitIOPS uint64 `json:"limit_iops"`
// Which accounts and resource groups use the storage policy
Usage Usage `json:"usage"`
}
type ListAccessSEPPools []AccessSEPPool
type AccessSEPPool struct {
// SEP ID
SEPID uint64 `json:"sep_id"`
// SEP name
Name string `json:"sep_name"`
// Pool names
PoolNames []string `json:"pool_names"`
}
type Usage struct {
// List of accounts
Accounts []uint64 `json:"accounts"`
// List of resource groups
Resgroups []uint64 `json:"resgroups"`
}

View File

@@ -0,0 +1,15 @@
package stpolicy
import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces"
// Structure for creating request to storage policy
type StPolicy struct {
client interfaces.Caller
}
// Builder for stack endpoint
func New(client interfaces.Caller) *StPolicy {
return &StPolicy{
client: client,
}
}