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.
|
|
|
package image
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"encoding/json"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"repository.basistech.ru/BASIS/dynamix-standard-go-sdk/internal/constants"
|
|
|
|
"repository.basistech.ru/BASIS/dynamix-standard-go-sdk/internal/validators"
|
|
|
|
"repository.basistech.ru/BASIS/dynamix-standard-go-sdk/pkg/image/models"
|
|
|
|
"repository.basistech.ru/BASIS/dynamix-standard-go-sdk/pkg/image/requests"
|
|
|
|
)
|
|
|
|
|
|
|
|
// List gets a list of all images.
|
|
|
|
func (i Image) List(ctx context.Context, req requests.ListImageRequest) (*models.ListImage, error) {
|
|
|
|
|
|
|
|
res, err := i.ListRaw(ctx, req)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
list := models.ListImage{}
|
|
|
|
|
|
|
|
err = json.Unmarshal(res, &list)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &list, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListRaw gets a list of all images as an array of bytes
|
|
|
|
func (i Image) ListRaw(ctx context.Context, req requests.ListImageRequest) ([]byte, error) {
|
|
|
|
|
|
|
|
if err := validators.ValidateRequest(req); err != nil {
|
|
|
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
|
|
}
|
|
|
|
|
|
|
|
url := constants.APIv0 + "/image"
|
|
|
|
|
|
|
|
res, err := i.client.ApiCall(ctx, http.MethodGet, url, req)
|
|
|
|
return res, err
|
|
|
|
}
|