151 lines
3.2 KiB
Go
151 lines
3.2 KiB
Go
// Code generated by ogen, DO NOT EDIT.
|
|
|
|
package api
|
|
|
|
import (
|
|
"net/http"
|
|
"net/url"
|
|
|
|
"github.com/go-faster/errors"
|
|
"github.com/google/uuid"
|
|
"github.com/ogen-go/ogen/conv"
|
|
"github.com/ogen-go/ogen/middleware"
|
|
"github.com/ogen-go/ogen/ogenerrors"
|
|
"github.com/ogen-go/ogen/uri"
|
|
"github.com/ogen-go/ogen/validate"
|
|
)
|
|
|
|
// GetRunParams is parameters of GetRun operation.
|
|
type GetRunParams struct {
|
|
// Random UUID chosen by the backend for one logical run. It is the idempotency key of SubmitRun and
|
|
// must not encode a candidate, attempt, or task identifier.
|
|
RunID uuid.UUID
|
|
}
|
|
|
|
func unpackGetRunParams(packed middleware.Parameters) (params GetRunParams) {
|
|
{
|
|
key := middleware.ParameterKey{
|
|
Name: "run_id",
|
|
In: "path",
|
|
}
|
|
params.RunID = packed[key].(uuid.UUID)
|
|
}
|
|
return params
|
|
}
|
|
|
|
func decodeGetRunParams(args [1]string, argsEscaped bool, r *http.Request) (params GetRunParams, _ error) {
|
|
// Decode path: run_id.
|
|
if err := func() error {
|
|
param := args[0]
|
|
if argsEscaped {
|
|
unescaped, err := url.PathUnescape(args[0])
|
|
if err != nil {
|
|
return errors.Wrap(err, "unescape path")
|
|
}
|
|
param = unescaped
|
|
}
|
|
if len(param) > 0 {
|
|
d := uri.NewPathDecoder(uri.PathDecoderConfig{
|
|
Param: "run_id",
|
|
Value: param,
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
|
|
if err := func() error {
|
|
val, err := d.DecodeValue()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
c, err := conv.ToUUID(val)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
params.RunID = c
|
|
return nil
|
|
}(); err != nil {
|
|
return err
|
|
}
|
|
} else {
|
|
return validate.ErrFieldRequired
|
|
}
|
|
return nil
|
|
}(); err != nil {
|
|
return params, &ogenerrors.DecodeParamError{
|
|
Name: "run_id",
|
|
In: "path",
|
|
Err: err,
|
|
}
|
|
}
|
|
return params, nil
|
|
}
|
|
|
|
// SubmitRunParams is parameters of SubmitRun operation.
|
|
type SubmitRunParams struct {
|
|
// Random UUID chosen by the backend for one logical run. It is the idempotency key of SubmitRun and
|
|
// must not encode a candidate, attempt, or task identifier.
|
|
RunID uuid.UUID
|
|
}
|
|
|
|
func unpackSubmitRunParams(packed middleware.Parameters) (params SubmitRunParams) {
|
|
{
|
|
key := middleware.ParameterKey{
|
|
Name: "run_id",
|
|
In: "path",
|
|
}
|
|
params.RunID = packed[key].(uuid.UUID)
|
|
}
|
|
return params
|
|
}
|
|
|
|
func decodeSubmitRunParams(args [1]string, argsEscaped bool, r *http.Request) (params SubmitRunParams, _ error) {
|
|
// Decode path: run_id.
|
|
if err := func() error {
|
|
param := args[0]
|
|
if argsEscaped {
|
|
unescaped, err := url.PathUnescape(args[0])
|
|
if err != nil {
|
|
return errors.Wrap(err, "unescape path")
|
|
}
|
|
param = unescaped
|
|
}
|
|
if len(param) > 0 {
|
|
d := uri.NewPathDecoder(uri.PathDecoderConfig{
|
|
Param: "run_id",
|
|
Value: param,
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
|
|
if err := func() error {
|
|
val, err := d.DecodeValue()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
c, err := conv.ToUUID(val)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
params.RunID = c
|
|
return nil
|
|
}(); err != nil {
|
|
return err
|
|
}
|
|
} else {
|
|
return validate.ErrFieldRequired
|
|
}
|
|
return nil
|
|
}(); err != nil {
|
|
return params, &ogenerrors.DecodeParamError{
|
|
Name: "run_id",
|
|
In: "path",
|
|
Err: err,
|
|
}
|
|
}
|
|
return params, nil
|
|
}
|