Files
decort-golang-sdk/pkg/cloudbroker/compute/get_log.go

37 lines
856 B
Go
Raw Normal View History

2022-12-22 17:56:47 +03:00
package compute
import (
"context"
"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
// GetLogRequest struct to get compute logs
2022-12-22 17:56:47 +03:00
type GetLogRequest struct {
// ID of compute instance to get log for
// Required: true
2023-03-24 17:09:30 +03:00
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
2022-12-22 17:56:47 +03:00
// Path to log file
// Required: true
2023-03-24 17:09:30 +03:00
Path string `url:"path" json:"path" validate:"required"`
2022-12-22 17:56:47 +03:00
}
// GetLog gets compute's log file by path
func (c Compute) GetLog(ctx context.Context, req GetLogRequest) (string, 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 "", validators.ValidationErrors(validators.GetErrors(err))
2022-12-22 17:56:47 +03:00
}
url := "/cloudbroker/compute/getLog"
2025-07-15 17:39:18 +03:00
res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req)
2022-12-22 17:56:47 +03:00
if err != nil {
return "", err
}
return string(res), nil
}