Files
decort-golang-sdk/pkg/cloudbroker/sep/get_pool.go

45 lines
961 B
Go
Raw Normal View History

2022-12-22 17:56:47 +03:00
package sep
import (
"context"
"encoding/json"
"net/http"
2023-03-24 17:09:30 +03:00
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
2022-12-22 17:56:47 +03:00
)
2023-10-25 17:37:18 +03:00
// GetPoolRequest struct to get SEP pool config by name
2022-12-22 17:56:47 +03:00
type GetPoolRequest struct {
// Storage endpoint provider ID
// Required: true
2023-03-24 17:09:30 +03:00
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
2022-12-22 17:56:47 +03:00
// Pool name
// Required: true
2023-03-24 17:09:30 +03:00
PoolName string `url:"pool_name" json:"pool_name" validate:"required"`
2022-12-22 17:56:47 +03:00
}
// GetPool gets SEP pool config by name
func (s SEP) GetPool(ctx context.Context, req GetPoolRequest) (*RecordPool, error) {
2023-03-24 17:09:30 +03:00
err := validators.ValidateRequest(req)
2022-12-22 17:56:47 +03:00
if err != nil {
2023-10-25 17:37:18 +03:00
return nil, validators.ValidationErrors(validators.GetErrors(err))
2022-12-22 17:56:47 +03:00
}
url := "/cloudbroker/sep/getPool"
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
info := RecordPool{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return &info, nil
}