Files
lincodex/labd/internal/api/oas_parameters_gen.go

352 lines
7.5 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"
)
// CheckLabParams is parameters of CheckLab operation.
type CheckLabParams struct {
// Random UUID chosen by the backend for one lab. It is the idempotency key of CreateLab and must not
// encode a candidate, attempt, or task identifier.
LabID uuid.UUID
}
func unpackCheckLabParams(packed middleware.Parameters) (params CheckLabParams) {
{
key := middleware.ParameterKey{
Name: "lab_id",
In: "path",
}
params.LabID = packed[key].(uuid.UUID)
}
return params
}
func decodeCheckLabParams(args [1]string, argsEscaped bool, r *http.Request) (params CheckLabParams, _ error) {
// Decode path: lab_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: "lab_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.LabID = c
return nil
}(); err != nil {
return err
}
} else {
return validate.ErrFieldRequired
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "lab_id",
In: "path",
Err: err,
}
}
return params, nil
}
// CreateLabParams is parameters of CreateLab operation.
type CreateLabParams struct {
// Random UUID chosen by the backend for one lab. It is the idempotency key of CreateLab and must not
// encode a candidate, attempt, or task identifier.
LabID uuid.UUID
}
func unpackCreateLabParams(packed middleware.Parameters) (params CreateLabParams) {
{
key := middleware.ParameterKey{
Name: "lab_id",
In: "path",
}
params.LabID = packed[key].(uuid.UUID)
}
return params
}
func decodeCreateLabParams(args [1]string, argsEscaped bool, r *http.Request) (params CreateLabParams, _ error) {
// Decode path: lab_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: "lab_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.LabID = c
return nil
}(); err != nil {
return err
}
} else {
return validate.ErrFieldRequired
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "lab_id",
In: "path",
Err: err,
}
}
return params, nil
}
// CreateLabConsoleTokenParams is parameters of CreateLabConsoleToken operation.
type CreateLabConsoleTokenParams struct {
// Random UUID chosen by the backend for one lab. It is the idempotency key of CreateLab and must not
// encode a candidate, attempt, or task identifier.
LabID uuid.UUID
}
func unpackCreateLabConsoleTokenParams(packed middleware.Parameters) (params CreateLabConsoleTokenParams) {
{
key := middleware.ParameterKey{
Name: "lab_id",
In: "path",
}
params.LabID = packed[key].(uuid.UUID)
}
return params
}
func decodeCreateLabConsoleTokenParams(args [1]string, argsEscaped bool, r *http.Request) (params CreateLabConsoleTokenParams, _ error) {
// Decode path: lab_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: "lab_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.LabID = c
return nil
}(); err != nil {
return err
}
} else {
return validate.ErrFieldRequired
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "lab_id",
In: "path",
Err: err,
}
}
return params, nil
}
// DeleteLabParams is parameters of DeleteLab operation.
type DeleteLabParams struct {
// Random UUID chosen by the backend for one lab. It is the idempotency key of CreateLab and must not
// encode a candidate, attempt, or task identifier.
LabID uuid.UUID
}
func unpackDeleteLabParams(packed middleware.Parameters) (params DeleteLabParams) {
{
key := middleware.ParameterKey{
Name: "lab_id",
In: "path",
}
params.LabID = packed[key].(uuid.UUID)
}
return params
}
func decodeDeleteLabParams(args [1]string, argsEscaped bool, r *http.Request) (params DeleteLabParams, _ error) {
// Decode path: lab_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: "lab_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.LabID = c
return nil
}(); err != nil {
return err
}
} else {
return validate.ErrFieldRequired
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "lab_id",
In: "path",
Err: err,
}
}
return params, nil
}
// GetLabParams is parameters of GetLab operation.
type GetLabParams struct {
// Random UUID chosen by the backend for one lab. It is the idempotency key of CreateLab and must not
// encode a candidate, attempt, or task identifier.
LabID uuid.UUID
}
func unpackGetLabParams(packed middleware.Parameters) (params GetLabParams) {
{
key := middleware.ParameterKey{
Name: "lab_id",
In: "path",
}
params.LabID = packed[key].(uuid.UUID)
}
return params
}
func decodeGetLabParams(args [1]string, argsEscaped bool, r *http.Request) (params GetLabParams, _ error) {
// Decode path: lab_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: "lab_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.LabID = c
return nil
}(); err != nil {
return err
}
} else {
return validate.ErrFieldRequired
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "lab_id",
In: "path",
Err: err,
}
}
return params, nil
}