This commit is contained in:
2023-10-23 12:40:54 +03:00
parent b069c31745
commit b666789c7d
73 changed files with 1134 additions and 641 deletions

View File

@@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for get information about VINS
// GetRequest struct to get information about VINS
type GetRequest struct {
// VINS ID
// Required: true
@@ -19,18 +19,9 @@ type GetRequest struct {
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// Get gets information about VINS by ID
// Get gets information about VINS by ID as a RecordVINS struct
func (v VINS) Get(ctx context.Context, req GetRequest) (*RecordVINS, error) {
err := validators.ValidateRequest(req)
if err != nil {
for _, validationError := range validators.GetErrors(err) {
return nil, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/vins/get"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := v.GetRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -44,3 +35,18 @@ func (v VINS) Get(ctx context.Context, req GetRequest) (*RecordVINS, error) {
return &info, nil
}
// GetRaw gets information about VINS by ID as an array of bytes
func (v VINS) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
err := validators.ValidateRequest(req)
if err != nil {
for _, validationError := range validators.GetErrors(err) {
return nil, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/vins/get"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}

View File

@@ -6,7 +6,7 @@ import (
"net/http"
)
// Request struct for get list of VINSes
// ListRequest struct to get list of VINSes
type ListRequest struct {
// Find by ID
// Required: false
@@ -41,11 +41,9 @@ type ListRequest struct {
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
}
// List gets list of VINSes
// List gets list of VINSes as a ListVINS struct
func (v VINS) List(ctx context.Context, req ListRequest) (*ListVINS, error) {
url := "/cloudbroker/vins/list"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := v.ListRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -59,3 +57,11 @@ func (v VINS) List(ctx context.Context, req ListRequest) (*ListVINS, error) {
return &list, nil
}
// ListRaw gets list of VINSes as an array of bytes
func (v VINS) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
url := "/cloudbroker/vins/list"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}