feat(labs): describe the lab task contract and the provisioner port

This commit is contained in:
shira committed 2026-10-11 15:40:14 +03:00
1 parent 3de226b16c
commit 9fdaa62b9b
91 files changed
+19262 -155

No files matched your search

@@ -17,27 +17,29 @@ import (
)
var regexMap = map[string]ogenregex.Regexp{
"\\S": ogenregex.MustCompile("\\S"),
"^(/([^~/]|~[01])*)*$": ogenregex.MustCompile("^(/([^~/]|~[01])*)*$"),
"^/[A-Za-z0-9/_-]{0,255}$": ogenregex.MustCompile("^/[A-Za-z0-9/_-]{0,255}$"),
"^@[A-Za-z0-9_]{5,32}$": ogenregex.MustCompile("^@[A-Za-z0-9_]{5,32}$"),
"^SC-[0-9]{4}-[0-9]{6,10}$": ogenregex.MustCompile("^SC-[0-9]{4}-[0-9]{6,10}$"),
"^[0-9A-HJKMNP-TV-Z]{5}-?[0-9A-HJKMNP-TV-Z]{5}$": ogenregex.MustCompile("^[0-9A-HJKMNP-TV-Z]{5}-?[0-9A-HJKMNP-TV-Z]{5}$"),
"^[0-9]{4}-(0[1-9]|1[0-2])$": ogenregex.MustCompile("^[0-9]{4}-(0[1-9]|1[0-2])$"),
"^[0-9]{6}$": ogenregex.MustCompile("^[0-9]{6}$"),
"^[A-Za-z0-9._-]+$": ogenregex.MustCompile("^[A-Za-z0-9._-]+$"),
"^[A-Za-z0-9._:-]+$": ogenregex.MustCompile("^[A-Za-z0-9._:-]+$"),
"^[A-Za-z0-9_-]+$": ogenregex.MustCompile("^[A-Za-z0-9_-]+$"),
"^[a-z0-9][a-z0-9_.+#-]*$": ogenregex.MustCompile("^[a-z0-9][a-z0-9_.+#-]*$"),
"^[a-z0-9_+-]+$": ogenregex.MustCompile("^[a-z0-9_+-]+$"),
"^[a-z0-9_]+$": ogenregex.MustCompile("^[a-z0-9_]+$"),
"^[a-z][a-z0-9_]*$": ogenregex.MustCompile("^[a-z][a-z0-9_]*$"),
"^\\+[1-9][0-9]{6,14}$": ogenregex.MustCompile("^\\+[1-9][0-9]{6,14}$"),
"^\\S(?:.*\\S)?$": ogenregex.MustCompile("^\\S(?:.*\\S)?$"),
"^\\S(?:[^\\n\\r]*\\S)?$": ogenregex.MustCompile("^\\S(?:[^\\n\\r]*\\S)?$"),
"^__Host-lincodex_session=": ogenregex.MustCompile("^__Host-lincodex_session="),
"^cv1_[A-Za-z0-9_-]{43}$": ogenregex.MustCompile("^cv1_[A-Za-z0-9_-]{43}$"),
"^https://[^\\s/?#@]+(?:[/?#][^\\s]*)?$": ogenregex.MustCompile("^https://[^\\s/?#@]+(?:[/?#][^\\s]*)?$"),
"\\S": ogenregex.MustCompile("\\S"),
"^(/([^~/]|~[01])*)*$": ogenregex.MustCompile("^(/([^~/]|~[01])*)*$"),
"^/[A-Za-z0-9/_-]{0,255}$": ogenregex.MustCompile("^/[A-Za-z0-9/_-]{0,255}$"),
"^/api/v1/me/assessment-lab-consoles/[0-9a-f-]{36}$": ogenregex.MustCompile("^/api/v1/me/assessment-lab-consoles/[0-9a-f-]{36}$"),
"^@[A-Za-z0-9_]{5,32}$": ogenregex.MustCompile("^@[A-Za-z0-9_]{5,32}$"),
"^SC-[0-9]{4}-[0-9]{6,10}$": ogenregex.MustCompile("^SC-[0-9]{4}-[0-9]{6,10}$"),
"^[0-9A-HJKMNP-TV-Z]{5}-?[0-9A-HJKMNP-TV-Z]{5}$": ogenregex.MustCompile("^[0-9A-HJKMNP-TV-Z]{5}-?[0-9A-HJKMNP-TV-Z]{5}$"),
"^[0-9]{4}-(0[1-9]|1[0-2])$": ogenregex.MustCompile("^[0-9]{4}-(0[1-9]|1[0-2])$"),
"^[0-9]{6}$": ogenregex.MustCompile("^[0-9]{6}$"),
"^[A-Za-z0-9._-]+$": ogenregex.MustCompile("^[A-Za-z0-9._-]+$"),
"^[A-Za-z0-9._:-]+$": ogenregex.MustCompile("^[A-Za-z0-9._:-]+$"),
"^[A-Za-z0-9_-]+$": ogenregex.MustCompile("^[A-Za-z0-9_-]+$"),
"^[a-z0-9][a-z0-9_.+#-]*$": ogenregex.MustCompile("^[a-z0-9][a-z0-9_.+#-]*$"),
"^[a-z0-9_+-]+$": ogenregex.MustCompile("^[a-z0-9_+-]+$"),
"^[a-z0-9_]+$": ogenregex.MustCompile("^[a-z0-9_]+$"),
"^[a-z][a-z0-9-]{0,14}$": ogenregex.MustCompile("^[a-z][a-z0-9-]{0,14}$"),
"^[a-z][a-z0-9_]*$": ogenregex.MustCompile("^[a-z][a-z0-9_]*$"),
"^\\+[1-9][0-9]{6,14}$": ogenregex.MustCompile("^\\+[1-9][0-9]{6,14}$"),
"^\\S(?:.*\\S)?$": ogenregex.MustCompile("^\\S(?:.*\\S)?$"),
"^\\S(?:[^\\n\\r]*\\S)?$": ogenregex.MustCompile("^\\S(?:[^\\n\\r]*\\S)?$"),
"^__Host-lincodex_session=": ogenregex.MustCompile("^__Host-lincodex_session="),
"^cv1_[A-Za-z0-9_-]{43}$": ogenregex.MustCompile("^cv1_[A-Za-z0-9_-]{43}$"),
"^https://[^\\s/?#@]+(?:[/?#][^\\s]*)?$": ogenregex.MustCompile("^https://[^\\s/?#@]+(?:[/?#][^\\s]*)?$"),
"^https://github\\.com/[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})/[A-Za-z0-9._-]{1,100}/?$": ogenregex.MustCompile("^https://github\\.com/[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})/[A-Za-z0-9._-]{1,100}/?$"),
}
var (
File diff suppressed because it is too large. Load diff
@@ -25,6 +25,14 @@ type CreateMyAssessmentAttemptRes interface {
createMyAssessmentAttemptRes()
}
type CreateMyAssessmentLabConsoleSessionRes interface {
createMyAssessmentLabConsoleSessionRes()
}
type CreateMyAssessmentLabRes interface {
createMyAssessmentLabRes()
}
type CreateMyAssessmentPracticeRunRes interface {
createMyAssessmentPracticeRunRes()
}
@@ -73,6 +81,10 @@ type GetMyAssessmentAvailabilityRes interface {
getMyAssessmentAvailabilityRes()
}
type GetMyAssessmentLabRes interface {
getMyAssessmentLabRes()
}
type GetMyAssessmentPracticeRunRes interface {
getMyAssessmentPracticeRunRes()
}
@@ -285,6 +297,10 @@ type SubmitMyAssessmentAnswerRes interface {
submitMyAssessmentAnswerRes()
}
type SubmitMyAssessmentLabRes interface {
submitMyAssessmentLabRes()
}
type UnhideOrganizationRes interface {
unhideOrganizationRes()
}
File diff suppressed because it is too large. Load diff
@@ -12,6 +12,8 @@ const (
ConfirmEmailOperation OperationName = "ConfirmEmail"
ConfirmEmailByCodeOperation OperationName = "ConfirmEmailByCode"
CreateMyAssessmentAttemptOperation OperationName = "CreateMyAssessmentAttempt"
CreateMyAssessmentLabOperation OperationName = "CreateMyAssessmentLab"
CreateMyAssessmentLabConsoleSessionOperation OperationName = "CreateMyAssessmentLabConsoleSession"
CreateMyAssessmentPracticeRunOperation OperationName = "CreateMyAssessmentPracticeRun"
CreateMySupportCaseOperation OperationName = "CreateMySupportCase"
CreateOrganizationOperation OperationName = "CreateOrganization"
@@ -25,6 +27,7 @@ const (
GetHealthzOperation OperationName = "GetHealthz"
GetMyAssessmentAttemptOperation OperationName = "GetMyAssessmentAttempt"
GetMyAssessmentAvailabilityOperation OperationName = "GetMyAssessmentAvailability"
GetMyAssessmentLabOperation OperationName = "GetMyAssessmentLab"
GetMyAssessmentPracticeRunOperation OperationName = "GetMyAssessmentPracticeRun"
GetMyAssessmentResultOperation OperationName = "GetMyAssessmentResult"
GetMyAssessmentSignalNoticeOperation OperationName = "GetMyAssessmentSignalNotice"
@@ -79,6 +82,7 @@ const (
SetMySearchStatusOperation OperationName = "SetMySearchStatus"
StartMyAssessmentAttemptSessionOperation OperationName = "StartMyAssessmentAttemptSession"
SubmitMyAssessmentAnswerOperation OperationName = "SubmitMyAssessmentAnswer"
SubmitMyAssessmentLabOperation OperationName = "SubmitMyAssessmentLab"
UnhideOrganizationOperation OperationName = "UnhideOrganization"
UpdateOrganizationOperation OperationName = "UpdateOrganization"
UpdateOrganizationInvitationOperation OperationName = "UpdateOrganizationInvitation"
@@ -593,6 +593,276 @@ func decodeCreateMyAssessmentAttemptParams(args [0]string, argsEscaped bool, r *
return params, nil
}
// CreateMyAssessmentLabParams is parameters of CreateMyAssessmentLab operation.
type CreateMyAssessmentLabParams struct {
// Identifier of an assessment attempt of the current candidate. An attempt of another candidate and an
// unknown identifier both answer 404 not_found, so identifiers cannot be enumerated.
AttemptID uuid.UUID
// Client-generated key that makes a retried mutating command safe; a UUID v4 is recommended. The value
// is sent without quotes. The server scopes the key by caller and operation and fingerprints the
// request by method, path, and body.
//
// Stored for 24 hours after the first request and replayed with the same status, headers, and body:
// the final 2xx outcome and final deterministic 4xx business outcomes of the command, such as 404
// not_found or 409 state_conflict. A replay does not repeat the side effect.
//
// Not stored, so a retry with the same key is evaluated again: 400 validation_failed, 413, and 415 for
// the request itself, 401 and 403, 409 idempotency_in_progress, 412 version_conflict and 428
// precondition_required (nothing changed; read the resource again and retry), 422
// idempotency_key_reused, 429, and every 5xx.
//
// Order of checks: authentication (401), request validation (400, 413, 415), authorization (403), then
// the key. A stored or running request with a different fingerprint returns 422 idempotency_key_reused
// before any other key check; a running request with the same fingerprint returns 409
// idempotency_in_progress; a stored outcome with the same fingerprint is replayed. Only after that
// does the server check If-Match, so a retry of a completed change replays its outcome instead of
// failing on the version it has just changed. After 24 hours the key may be accepted as new.
IdempotencyKey string
}
func unpackCreateMyAssessmentLabParams(packed middleware.Parameters) (params CreateMyAssessmentLabParams) {
{
key := middleware.ParameterKey{
Name: "attempt_id",
In: "path",
}
params.AttemptID = packed[key].(uuid.UUID)
}
{
key := middleware.ParameterKey{
Name: "Idempotency-Key",
In: "header",
}
params.IdempotencyKey = packed[key].(string)
}
return params
}
func decodeCreateMyAssessmentLabParams(args [1]string, argsEscaped bool, r *http.Request) (params CreateMyAssessmentLabParams, _ error) {
h := uri.NewHeaderDecoder(r.Header)
// Decode path: attempt_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: "attempt_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.AttemptID = c
return nil
}(); err != nil {
return err
}
} else {
return validate.ErrFieldRequired
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "attempt_id",
In: "path",
Err: err,
}
}
// Decode header: Idempotency-Key.
if err := func() error {
cfg := uri.HeaderParameterDecodingConfig{
Name: "Idempotency-Key",
Explode: false,
}
if err := h.HasParam(cfg); err == nil {
if err := h.DecodeParam(cfg, func(d uri.Decoder) error {
val, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToString(val)
if err != nil {
return err
}
params.IdempotencyKey = c
return nil
}); err != nil {
return err
}
if err := func() error {
if err := (validate.String{
MinLength: 1,
MinLengthSet: true,
MaxLength: 255,
MaxLengthSet: true,
Email: false,
Hostname: false,
Regex: regexMap["^[A-Za-z0-9._:-]+$"],
MinNumeric: 0,
MinNumericSet: false,
MaxNumeric: 0,
MaxNumericSet: false,
}).Validate(string(params.IdempotencyKey)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}(); err != nil {
return err
}
} else {
return err
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "Idempotency-Key",
In: "header",
Err: err,
}
}
return params, nil
}
// CreateMyAssessmentLabConsoleSessionParams is parameters of CreateMyAssessmentLabConsoleSession operation.
type CreateMyAssessmentLabConsoleSessionParams struct {
// Identifier of an assessment attempt of the current candidate. An attempt of another candidate and an
// unknown identifier both answer 404 not_found, so identifiers cannot be enumerated.
AttemptID uuid.UUID
// Identifier of a lab of this attempt.
LabID uuid.UUID
}
func unpackCreateMyAssessmentLabConsoleSessionParams(packed middleware.Parameters) (params CreateMyAssessmentLabConsoleSessionParams) {
{
key := middleware.ParameterKey{
Name: "attempt_id",
In: "path",
}
params.AttemptID = packed[key].(uuid.UUID)
}
{
key := middleware.ParameterKey{
Name: "lab_id",
In: "path",
}
params.LabID = packed[key].(uuid.UUID)
}
return params
}
func decodeCreateMyAssessmentLabConsoleSessionParams(args [2]string, argsEscaped bool, r *http.Request) (params CreateMyAssessmentLabConsoleSessionParams, _ error) {
// Decode path: attempt_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: "attempt_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.AttemptID = c
return nil
}(); err != nil {
return err
}
} else {
return validate.ErrFieldRequired
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "attempt_id",
In: "path",
Err: err,
}
}
// Decode path: lab_id.
if err := func() error {
param := args[1]
if argsEscaped {
unescaped, err := url.PathUnescape(args[1])
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
}
// CreateMyAssessmentPracticeRunParams is parameters of CreateMyAssessmentPracticeRun operation.
type CreateMyAssessmentPracticeRunParams struct {
// Identifier of an assessment attempt of the current candidate. An attempt of another candidate and an
@@ -1672,6 +1942,127 @@ func decodeGetMyAssessmentAttemptParams(args [1]string, argsEscaped bool, r *htt
return params, nil
}
// GetMyAssessmentLabParams is parameters of GetMyAssessmentLab operation.
type GetMyAssessmentLabParams struct {
// Identifier of an assessment attempt of the current candidate. An attempt of another candidate and an
// unknown identifier both answer 404 not_found, so identifiers cannot be enumerated.
AttemptID uuid.UUID
// Identifier of a lab of this attempt.
LabID uuid.UUID
}
func unpackGetMyAssessmentLabParams(packed middleware.Parameters) (params GetMyAssessmentLabParams) {
{
key := middleware.ParameterKey{
Name: "attempt_id",
In: "path",
}
params.AttemptID = packed[key].(uuid.UUID)
}
{
key := middleware.ParameterKey{
Name: "lab_id",
In: "path",
}
params.LabID = packed[key].(uuid.UUID)
}
return params
}
func decodeGetMyAssessmentLabParams(args [2]string, argsEscaped bool, r *http.Request) (params GetMyAssessmentLabParams, _ error) {
// Decode path: attempt_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: "attempt_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.AttemptID = c
return nil
}(); err != nil {
return err
}
} else {
return validate.ErrFieldRequired
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "attempt_id",
In: "path",
Err: err,
}
}
// Decode path: lab_id.
if err := func() error {
param := args[1]
if argsEscaped {
unescaped, err := url.PathUnescape(args[1])
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
}
// GetMyAssessmentPracticeRunParams is parameters of GetMyAssessmentPracticeRun operation.
type GetMyAssessmentPracticeRunParams struct {
// Identifier of an assessment attempt of the current candidate. An attempt of another candidate and an
@@ -7249,6 +7640,209 @@ func decodeSubmitMyAssessmentAnswerParams(args [1]string, argsEscaped bool, r *h
return params, nil
}
// SubmitMyAssessmentLabParams is parameters of SubmitMyAssessmentLab operation.
type SubmitMyAssessmentLabParams struct {
// Identifier of an assessment attempt of the current candidate. An attempt of another candidate and an
// unknown identifier both answer 404 not_found, so identifiers cannot be enumerated.
AttemptID uuid.UUID
// Client-generated key that makes a retried mutating command safe; a UUID v4 is recommended. The value
// is sent without quotes. The server scopes the key by caller and operation and fingerprints the
// request by method, path, and body.
//
// Stored for 24 hours after the first request and replayed with the same status, headers, and body:
// the final 2xx outcome and final deterministic 4xx business outcomes of the command, such as 404
// not_found or 409 state_conflict. A replay does not repeat the side effect.
//
// Not stored, so a retry with the same key is evaluated again: 400 validation_failed, 413, and 415 for
// the request itself, 401 and 403, 409 idempotency_in_progress, 412 version_conflict and 428
// precondition_required (nothing changed; read the resource again and retry), 422
// idempotency_key_reused, 429, and every 5xx.
//
// Order of checks: authentication (401), request validation (400, 413, 415), authorization (403), then
// the key. A stored or running request with a different fingerprint returns 422 idempotency_key_reused
// before any other key check; a running request with the same fingerprint returns 409
// idempotency_in_progress; a stored outcome with the same fingerprint is replayed. Only after that
// does the server check If-Match, so a retry of a completed change replays its outcome instead of
// failing on the version it has just changed. After 24 hours the key may be accepted as new.
IdempotencyKey string
// Identifier of the lab to submit.
LabID uuid.UUID
}
func unpackSubmitMyAssessmentLabParams(packed middleware.Parameters) (params SubmitMyAssessmentLabParams) {
{
key := middleware.ParameterKey{
Name: "attempt_id",
In: "path",
}
params.AttemptID = packed[key].(uuid.UUID)
}
{
key := middleware.ParameterKey{
Name: "Idempotency-Key",
In: "header",
}
params.IdempotencyKey = packed[key].(string)
}
{
key := middleware.ParameterKey{
Name: "lab_id",
In: "path",
}
params.LabID = packed[key].(uuid.UUID)
}
return params
}
func decodeSubmitMyAssessmentLabParams(args [2]string, argsEscaped bool, r *http.Request) (params SubmitMyAssessmentLabParams, _ error) {
h := uri.NewHeaderDecoder(r.Header)
// Decode path: attempt_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: "attempt_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.AttemptID = c
return nil
}(); err != nil {
return err
}
} else {
return validate.ErrFieldRequired
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "attempt_id",
In: "path",
Err: err,
}
}
// Decode header: Idempotency-Key.
if err := func() error {
cfg := uri.HeaderParameterDecodingConfig{
Name: "Idempotency-Key",
Explode: false,
}
if err := h.HasParam(cfg); err == nil {
if err := h.DecodeParam(cfg, func(d uri.Decoder) error {
val, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToString(val)
if err != nil {
return err
}
params.IdempotencyKey = c
return nil
}); err != nil {
return err
}
if err := func() error {
if err := (validate.String{
MinLength: 1,
MinLengthSet: true,
MaxLength: 255,
MaxLengthSet: true,
Email: false,
Hostname: false,
Regex: regexMap["^[A-Za-z0-9._:-]+$"],
MinNumeric: 0,
MinNumericSet: false,
MaxNumeric: 0,
MaxNumericSet: false,
}).Validate(string(params.IdempotencyKey)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}(); err != nil {
return err
}
} else {
return err
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "Idempotency-Key",
In: "header",
Err: err,
}
}
// Decode path: lab_id.
if err := func() error {
param := args[1]
if argsEscaped {
unescaped, err := url.PathUnescape(args[1])
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
}
// UnhideOrganizationParams is parameters of UnhideOrganization operation.
type UnhideOrganizationParams struct {
// Identifier of the organization that the current candidate hides or stops hiding the profile from. It
@@ -488,6 +488,156 @@ func (s *Server) decodeCreateMyAssessmentAttemptRequest(r *http.Request) (
}
}
func (s *Server) decodeCreateMyAssessmentLabRequest(r *http.Request) (
req *AssessmentLabCreate,
rawBody []byte,
close func() error,
rerr error,
) {
var closers []func() error
close = func() error {
var merr error
// Close in reverse order, to match defer behavior.
for i := len(closers) - 1; i >= 0; i-- {
c := closers[i]
merr = errors.Join(merr, c())
}
return merr
}
defer func() {
if rerr != nil {
rerr = errors.Join(rerr, close())
}
}()
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
if err != nil {
return req, rawBody, close, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/json":
if r.ContentLength == 0 {
return req, rawBody, close, validate.ErrBodyRequired
}
buf, err := io.ReadAll(r.Body)
defer func() {
_ = r.Body.Close()
}()
if err != nil {
return req, rawBody, close, err
}
// Reset the body to allow for downstream reading.
r.Body = io.NopCloser(bytes.NewBuffer(buf))
if len(buf) == 0 {
return req, rawBody, close, validate.ErrBodyRequired
}
rawBody = append(rawBody, buf...)
d := jx.DecodeBytes(buf)
var request AssessmentLabCreate
if err := func() error {
if err := request.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return req, rawBody, close, err
}
return &request, rawBody, close, nil
default:
return req, rawBody, close, validate.InvalidContentType(ct)
}
}
func (s *Server) decodeCreateMyAssessmentLabConsoleSessionRequest(r *http.Request) (
req *AssessmentLabConsoleSessionCreate,
rawBody []byte,
close func() error,
rerr error,
) {
var closers []func() error
close = func() error {
var merr error
// Close in reverse order, to match defer behavior.
for i := len(closers) - 1; i >= 0; i-- {
c := closers[i]
merr = errors.Join(merr, c())
}
return merr
}
defer func() {
if rerr != nil {
rerr = errors.Join(rerr, close())
}
}()
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
if err != nil {
return req, rawBody, close, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/json":
if r.ContentLength == 0 {
return req, rawBody, close, validate.ErrBodyRequired
}
buf, err := io.ReadAll(r.Body)
defer func() {
_ = r.Body.Close()
}()
if err != nil {
return req, rawBody, close, err
}
// Reset the body to allow for downstream reading.
r.Body = io.NopCloser(bytes.NewBuffer(buf))
if len(buf) == 0 {
return req, rawBody, close, validate.ErrBodyRequired
}
rawBody = append(rawBody, buf...)
d := jx.DecodeBytes(buf)
var request AssessmentLabConsoleSessionCreate
if err := func() error {
if err := request.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return req, rawBody, close, err
}
if err := func() error {
if err := request.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return req, rawBody, close, errors.Wrap(err, "validate")
}
return &request, rawBody, close, nil
default:
return req, rawBody, close, validate.InvalidContentType(ct)
}
}
func (s *Server) decodeCreateMyAssessmentPracticeRunRequest(r *http.Request) (
req *PracticeRunCreate,
rawBody []byte,
@@ -2147,6 +2297,85 @@ func (s *Server) decodeSubmitMyAssessmentAnswerRequest(r *http.Request) (
}
}
func (s *Server) decodeSubmitMyAssessmentLabRequest(r *http.Request) (
req *AssessmentLabSubmission,
rawBody []byte,
close func() error,
rerr error,
) {
var closers []func() error
close = func() error {
var merr error
// Close in reverse order, to match defer behavior.
for i := len(closers) - 1; i >= 0; i-- {
c := closers[i]
merr = errors.Join(merr, c())
}
return merr
}
defer func() {
if rerr != nil {
rerr = errors.Join(rerr, close())
}
}()
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
if err != nil {
return req, rawBody, close, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/json":
if r.ContentLength == 0 {
return req, rawBody, close, validate.ErrBodyRequired
}
buf, err := io.ReadAll(r.Body)
defer func() {
_ = r.Body.Close()
}()
if err != nil {
return req, rawBody, close, err
}
// Reset the body to allow for downstream reading.
r.Body = io.NopCloser(bytes.NewBuffer(buf))
if len(buf) == 0 {
return req, rawBody, close, validate.ErrBodyRequired
}
rawBody = append(rawBody, buf...)
d := jx.DecodeBytes(buf)
var request AssessmentLabSubmission
if err := func() error {
if err := request.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return req, rawBody, close, err
}
if err := func() error {
if err := request.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return req, rawBody, close, errors.Wrap(err, "validate")
}
return &request, rawBody, close, nil
default:
return req, rawBody, close, validate.InvalidContentType(ct)
}
}
func (s *Server) decodeUpdateOrganizationRequest(r *http.Request) (
req *OrganizationUpdate,
rawBody []byte,
@@ -676,6 +676,366 @@ func encodeCreateMyAssessmentAttemptResponse(response CreateMyAssessmentAttemptR
}
}
func encodeCreateMyAssessmentLabResponse(response CreateMyAssessmentLabRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *CreateMyAssessmentLabOK:
w.Header().Set("Content-Type", "application/json; charset=utf-8")
// Encoding response headers.
{
h := uri.NewHeaderEncoder(w.Header())
// Encode "Cache-Control" header.
{
cfg := uri.HeaderParameterEncodingConfig{
Name: "Cache-Control",
Explode: false,
}
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
}); err != nil {
return errors.Wrap(err, "encode Cache-Control header")
}
}
}
w.WriteHeader(200)
e := new(jx.Encoder)
response.Response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *CreateMyAssessmentLabCreated:
w.Header().Set("Content-Type", "application/json; charset=utf-8")
// Encoding response headers.
{
h := uri.NewHeaderEncoder(w.Header())
// Encode "Cache-Control" header.
{
cfg := uri.HeaderParameterEncodingConfig{
Name: "Cache-Control",
Explode: false,
}
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
}); err != nil {
return errors.Wrap(err, "encode Cache-Control header")
}
}
}
w.WriteHeader(201)
e := new(jx.Encoder)
response.Response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *CreateMyAssessmentLabBadRequest:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(400)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *CreateMyAssessmentLabUnauthorized:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(401)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *CreateMyAssessmentLabForbidden:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(403)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *CreateMyAssessmentLabNotFound:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(404)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *CreateMyAssessmentLabConflict:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(409)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *CreateMyAssessmentLabUnprocessableEntity:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(422)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *TooManyRequestsHeaders:
w.Header().Set("Content-Type", "application/problem+json")
w.Header().Set("Access-Control-Expose-Headers", "Retry-After")
// Encoding response headers.
{
h := uri.NewHeaderEncoder(w.Header())
// Encode "Retry-After" header.
{
cfg := uri.HeaderParameterEncodingConfig{
Name: "Retry-After",
Explode: false,
}
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := response.RetryAfter.Get(); ok {
return e.EncodeValue(conv.Int32ToString(val))
}
return nil
}); err != nil {
return errors.Wrap(err, "encode Retry-After header")
}
}
}
w.WriteHeader(429)
e := new(jx.Encoder)
response.Response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *ServiceUnavailableHeaders:
w.Header().Set("Content-Type", "application/problem+json")
w.Header().Set("Access-Control-Expose-Headers", "Retry-After")
// Encoding response headers.
{
h := uri.NewHeaderEncoder(w.Header())
// Encode "Retry-After" header.
{
cfg := uri.HeaderParameterEncodingConfig{
Name: "Retry-After",
Explode: false,
}
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := response.RetryAfter.Get(); ok {
return e.EncodeValue(conv.Int32ToString(val))
}
return nil
}); err != nil {
return errors.Wrap(err, "encode Retry-After header")
}
}
}
w.WriteHeader(503)
span.SetStatus(codes.Error, http.StatusText(503))
e := new(jx.Encoder)
response.Response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
default:
return errors.Errorf("unexpected response type: %T", response)
}
}
func encodeCreateMyAssessmentLabConsoleSessionResponse(response CreateMyAssessmentLabConsoleSessionRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *AssessmentLabConsoleSessionHeaders:
w.Header().Set("Content-Type", "application/json; charset=utf-8")
// Encoding response headers.
{
h := uri.NewHeaderEncoder(w.Header())
// Encode "Cache-Control" header.
{
cfg := uri.HeaderParameterEncodingConfig{
Name: "Cache-Control",
Explode: false,
}
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
}); err != nil {
return errors.Wrap(err, "encode Cache-Control header")
}
}
}
w.WriteHeader(201)
e := new(jx.Encoder)
response.Response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *CreateMyAssessmentLabConsoleSessionBadRequest:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(400)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *CreateMyAssessmentLabConsoleSessionUnauthorized:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(401)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *CreateMyAssessmentLabConsoleSessionForbidden:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(403)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *CreateMyAssessmentLabConsoleSessionNotFound:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(404)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *CreateMyAssessmentLabConsoleSessionConflict:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(409)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *TooManyRequestsHeaders:
w.Header().Set("Content-Type", "application/problem+json")
w.Header().Set("Access-Control-Expose-Headers", "Retry-After")
// Encoding response headers.
{
h := uri.NewHeaderEncoder(w.Header())
// Encode "Retry-After" header.
{
cfg := uri.HeaderParameterEncodingConfig{
Name: "Retry-After",
Explode: false,
}
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := response.RetryAfter.Get(); ok {
return e.EncodeValue(conv.Int32ToString(val))
}
return nil
}); err != nil {
return errors.Wrap(err, "encode Retry-After header")
}
}
}
w.WriteHeader(429)
e := new(jx.Encoder)
response.Response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *ServiceUnavailableHeaders:
w.Header().Set("Content-Type", "application/problem+json")
w.Header().Set("Access-Control-Expose-Headers", "Retry-After")
// Encoding response headers.
{
h := uri.NewHeaderEncoder(w.Header())
// Encode "Retry-After" header.
{
cfg := uri.HeaderParameterEncodingConfig{
Name: "Retry-After",
Explode: false,
}
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := response.RetryAfter.Get(); ok {
return e.EncodeValue(conv.Int32ToString(val))
}
return nil
}); err != nil {
return errors.Wrap(err, "encode Retry-After header")
}
}
}
w.WriteHeader(503)
span.SetStatus(codes.Error, http.StatusText(503))
e := new(jx.Encoder)
response.Response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
default:
return errors.Errorf("unexpected response type: %T", response)
}
}
func encodeCreateMyAssessmentPracticeRunResponse(response CreateMyAssessmentPracticeRunRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *PracticeRunHeaders:
@@ -1930,6 +2290,77 @@ func encodeGetMyAssessmentAvailabilityResponse(response GetMyAssessmentAvailabil
}
}
func encodeGetMyAssessmentLabResponse(response GetMyAssessmentLabRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *AssessmentLabHeaders:
w.Header().Set("Content-Type", "application/json; charset=utf-8")
// Encoding response headers.
{
h := uri.NewHeaderEncoder(w.Header())
// Encode "Cache-Control" header.
{
cfg := uri.HeaderParameterEncodingConfig{
Name: "Cache-Control",
Explode: false,
}
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
}); err != nil {
return errors.Wrap(err, "encode Cache-Control header")
}
}
}
w.WriteHeader(200)
e := new(jx.Encoder)
response.Response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *GetMyAssessmentLabUnauthorized:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(401)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *GetMyAssessmentLabForbidden:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(403)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *GetMyAssessmentLabNotFound:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(404)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
default:
return errors.Errorf("unexpected response type: %T", response)
}
}
func encodeGetMyAssessmentPracticeRunResponse(response GetMyAssessmentPracticeRunRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *PracticeRunHeaders:
@@ -6465,6 +6896,190 @@ func encodeSubmitMyAssessmentAnswerResponse(response SubmitMyAssessmentAnswerRes
}
}
func encodeSubmitMyAssessmentLabResponse(response SubmitMyAssessmentLabRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *AssessmentLabHeaders:
w.Header().Set("Content-Type", "application/json; charset=utf-8")
// Encoding response headers.
{
h := uri.NewHeaderEncoder(w.Header())
// Encode "Cache-Control" header.
{
cfg := uri.HeaderParameterEncodingConfig{
Name: "Cache-Control",
Explode: false,
}
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
}); err != nil {
return errors.Wrap(err, "encode Cache-Control header")
}
}
}
w.WriteHeader(202)
e := new(jx.Encoder)
response.Response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *SubmitMyAssessmentLabBadRequest:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(400)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *SubmitMyAssessmentLabUnauthorized:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(401)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *SubmitMyAssessmentLabForbidden:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(403)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *SubmitMyAssessmentLabNotFound:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(404)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *SubmitMyAssessmentLabConflict:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(409)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *SubmitMyAssessmentLabPreconditionFailed:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(412)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *SubmitMyAssessmentLabUnprocessableEntity:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(422)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *TooManyRequestsHeaders:
w.Header().Set("Content-Type", "application/problem+json")
w.Header().Set("Access-Control-Expose-Headers", "Retry-After")
// Encoding response headers.
{
h := uri.NewHeaderEncoder(w.Header())
// Encode "Retry-After" header.
{
cfg := uri.HeaderParameterEncodingConfig{
Name: "Retry-After",
Explode: false,
}
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := response.RetryAfter.Get(); ok {
return e.EncodeValue(conv.Int32ToString(val))
}
return nil
}); err != nil {
return errors.Wrap(err, "encode Retry-After header")
}
}
}
w.WriteHeader(429)
e := new(jx.Encoder)
response.Response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *ServiceUnavailableHeaders:
w.Header().Set("Content-Type", "application/problem+json")
w.Header().Set("Access-Control-Expose-Headers", "Retry-After")
// Encoding response headers.
{
h := uri.NewHeaderEncoder(w.Header())
// Encode "Retry-After" header.
{
cfg := uri.HeaderParameterEncodingConfig{
Name: "Retry-After",
Explode: false,
}
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := response.RetryAfter.Get(); ok {
return e.EncodeValue(conv.Int32ToString(val))
}
return nil
}); err != nil {
return errors.Wrap(err, "encode Retry-After header")
}
}
}
w.WriteHeader(503)
span.SetStatus(codes.Error, http.StatusText(503))
e := new(jx.Encoder)
response.Response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
default:
return errors.Errorf("unexpected response type: %T", response)
}
}
func encodeUnhideOrganizationResponse(response UnhideOrganizationRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *UnhideOrganizationNoContent:
@@ -11,7 +11,7 @@ import (
)
var (
rn89AllowedHeaders = map[string]string{
rn93AllowedHeaders = map[string]string{
"POST": "Content-Type",
}
rn9AllowedHeaders = map[string]string{
@@ -20,47 +20,56 @@ var (
rn10AllowedHeaders = map[string]string{
"POST": "Content-Type,Origin",
}
rn84AllowedHeaders = map[string]string{
rn88AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key",
}
rn74AllowedHeaders = map[string]string{
rn78AllowedHeaders = map[string]string{
"POST": "Content-Type",
}
rn30AllowedHeaders = map[string]string{
rn34AllowedHeaders = map[string]string{
"DELETE": "X-Csrf-Token",
}
rn86AllowedHeaders = map[string]string{
rn90AllowedHeaders = map[string]string{
"POST": "X-Csrf-Token",
}
rn12AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn100AllowedHeaders = map[string]string{
rn104AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Attempt-Client,X-Csrf-Token",
}
rn25AllowedHeaders = map[string]string{
rn29AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn15AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn99AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Attempt-Client,X-Csrf-Token",
rn18AllowedHeaders = map[string]string{
"POST": "Content-Type,X-Csrf-Token",
}
rn83AllowedHeaders = map[string]string{
rn106AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn61AllowedHeaders = map[string]string{
rn20AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn103AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Attempt-Client,X-Csrf-Token",
}
rn87AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn65AllowedHeaders = map[string]string{
"DELETE": "X-Attempt-Client,X-Csrf-Token",
"PUT": "X-Attempt-Client,X-Csrf-Token",
}
rn5AllowedHeaders = map[string]string{
"PUT": "Content-Type,X-Csrf-Token",
}
rn91AllowedHeaders = map[string]string{
rn95AllowedHeaders = map[string]string{
"DELETE": "X-Csrf-Token",
}
rn57AllowedHeaders = map[string]string{
rn61AllowedHeaders = map[string]string{
"DELETE": "X-Csrf-Token",
"PUT": "Content-Type,X-Csrf-Token",
}
@@ -70,68 +79,68 @@ var (
rn7AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn23AllowedHeaders = map[string]string{
rn28AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn101AllowedHeaders = map[string]string{
rn107AllowedHeaders = map[string]string{
"POST": "X-Csrf-Token",
}
rn77AllowedHeaders = map[string]string{
rn81AllowedHeaders = map[string]string{
"POST": "X-Csrf-Token",
}
rn60AllowedHeaders = map[string]string{
rn64AllowedHeaders = map[string]string{
"DELETE": "X-Csrf-Token",
"PUT": "X-Csrf-Token",
}
rn96AllowedHeaders = map[string]string{
rn100AllowedHeaders = map[string]string{
"PUT": "Content-Type,X-Csrf-Token",
}
rn97AllowedHeaders = map[string]string{
rn101AllowedHeaders = map[string]string{
"PUT": "Content-Type,X-Csrf-Token",
}
rn42AllowedHeaders = map[string]string{
rn46AllowedHeaders = map[string]string{
"PUT": "Content-Type,X-Csrf-Token",
}
rn87AllowedHeaders = map[string]string{
rn91AllowedHeaders = map[string]string{
"POST": "X-Csrf-Token",
}
rn43AllowedHeaders = map[string]string{
rn47AllowedHeaders = map[string]string{
"PUT": "Content-Type,X-Csrf-Token",
}
rn16AllowedHeaders = map[string]string{
rn21AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn17AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn19AllowedHeaders = map[string]string{
"PATCH": "Content-Type,X-Csrf-Token",
}
rn20AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn50AllowedHeaders = map[string]string{
"PATCH": "Content-Type,X-Csrf-Token",
}
rn82AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn94AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn102AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn92AllowedHeaders = map[string]string{
"POST": "Content-Type,X-Csrf-Token",
}
rn22AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn53AllowedHeaders = map[string]string{
rn24AllowedHeaders = map[string]string{
"PATCH": "Content-Type,X-Csrf-Token",
}
rn80AllowedHeaders = map[string]string{
rn25AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn54AllowedHeaders = map[string]string{
"PATCH": "Content-Type,X-Csrf-Token",
}
rn86AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn98AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn108AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn96AllowedHeaders = map[string]string{
"POST": "Content-Type,X-Csrf-Token",
}
rn27AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn57AllowedHeaders = map[string]string{
"PATCH": "Content-Type,X-Csrf-Token",
}
rn84AllowedHeaders = map[string]string{
"POST": "X-Csrf-Token",
}
)
@@ -288,7 +297,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn89AllowedHeaders,
allowedHeaders: rn93AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -391,7 +400,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn84AllowedHeaders,
allowedHeaders: rn88AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -415,7 +424,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn74AllowedHeaders,
allowedHeaders: rn78AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -442,7 +451,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "DELETE,GET",
allowedHeaders: rn30AllowedHeaders,
allowedHeaders: rn34AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -495,7 +504,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn86AllowedHeaders,
allowedHeaders: rn90AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -617,7 +626,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn100AllowedHeaders,
allowedHeaders: rn104AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -644,7 +653,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn25AllowedHeaders,
allowedHeaders: rn29AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -653,6 +662,142 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
case 'l': // Prefix: "labs"
if l := len("labs"); len(elem) >= l && elem[0:l] == "labs" {
elem = elem[l:]
} else {
break
}
if len(elem) == 0 {
switch r.Method {
case "POST":
s.handleCreateMyAssessmentLabRequest([1]string{
args[0],
}, elemIsEscaped, w, r)
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn15AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
}
return
}
switch elem[0] {
case '/': // Prefix: "/"
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
elem = elem[l:]
} else {
break
}
// Param: "lab_id"
// Match until "/"
idx := strings.IndexByte(elem, '/')
if idx < 0 {
idx = len(elem)
}
args[1] = elem[:idx]
elem = elem[idx:]
if len(elem) == 0 {
switch r.Method {
case "GET":
s.handleGetMyAssessmentLabRequest([2]string{
args[0],
args[1],
}, elemIsEscaped, w, r)
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "GET",
allowedHeaders: nil,
acceptPost: "",
acceptPatch: "",
})
}
return
}
switch elem[0] {
case '/': // Prefix: "/"
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
elem = elem[l:]
} else {
break
}
if len(elem) == 0 {
break
}
switch elem[0] {
case 'c': // Prefix: "console-sessions"
if l := len("console-sessions"); len(elem) >= l && elem[0:l] == "console-sessions" {
elem = elem[l:]
} else {
break
}
if len(elem) == 0 {
// Leaf node.
switch r.Method {
case "POST":
s.handleCreateMyAssessmentLabConsoleSessionRequest([2]string{
args[0],
args[1],
}, elemIsEscaped, w, r)
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn18AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
}
return
}
case 's': // Prefix: "submission"
if l := len("submission"); len(elem) >= l && elem[0:l] == "submission" {
elem = elem[l:]
} else {
break
}
if len(elem) == 0 {
// Leaf node.
switch r.Method {
case "POST":
s.handleSubmitMyAssessmentLabRequest([2]string{
args[0],
args[1],
}, elemIsEscaped, w, r)
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn106AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
}
return
}
}
}
}
case 'p': // Prefix: "practice-runs"
if l := len("practice-runs"); len(elem) >= l && elem[0:l] == "practice-runs" {
@@ -670,7 +815,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn15AllowedHeaders,
allowedHeaders: rn20AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -775,7 +920,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn99AllowedHeaders,
allowedHeaders: rn103AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -802,7 +947,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn83AllowedHeaders,
allowedHeaders: rn87AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -835,7 +980,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "DELETE,PUT",
allowedHeaders: rn61AllowedHeaders,
allowedHeaders: rn65AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -1044,7 +1189,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "DELETE",
allowedHeaders: rn91AllowedHeaders,
allowedHeaders: rn95AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -1078,7 +1223,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "DELETE,PUT",
allowedHeaders: rn57AllowedHeaders,
allowedHeaders: rn61AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -1259,7 +1404,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn23AllowedHeaders,
allowedHeaders: rn28AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -1286,7 +1431,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn101AllowedHeaders,
allowedHeaders: rn107AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -1364,7 +1509,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn77AllowedHeaders,
allowedHeaders: rn81AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -1542,7 +1687,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "DELETE,PUT",
allowedHeaders: rn60AllowedHeaders,
allowedHeaders: rn64AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -1633,7 +1778,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "PUT",
allowedHeaders: rn96AllowedHeaders,
allowedHeaders: rn100AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -1660,7 +1805,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "PUT",
allowedHeaders: rn97AllowedHeaders,
allowedHeaders: rn101AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -1690,7 +1835,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "GET,PUT",
allowedHeaders: rn42AllowedHeaders,
allowedHeaders: rn46AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -1715,7 +1860,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn87AllowedHeaders,
allowedHeaders: rn91AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -1746,7 +1891,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "GET,PUT",
allowedHeaders: rn43AllowedHeaders,
allowedHeaders: rn47AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -1772,7 +1917,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "GET,POST",
allowedHeaders: rn16AllowedHeaders,
allowedHeaders: rn21AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -1836,7 +1981,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn17AllowedHeaders,
allowedHeaders: rn22AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -1875,7 +2020,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "GET,PATCH",
allowedHeaders: rn19AllowedHeaders,
allowedHeaders: rn24AllowedHeaders,
acceptPost: "",
acceptPatch: "application/json",
})
@@ -1983,7 +2128,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "GET,POST",
allowedHeaders: rn20AllowedHeaders,
allowedHeaders: rn25AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -2024,7 +2169,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "GET,PATCH",
allowedHeaders: rn50AllowedHeaders,
allowedHeaders: rn54AllowedHeaders,
acceptPost: "",
acceptPatch: "application/json",
})
@@ -2104,7 +2249,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn82AllowedHeaders,
allowedHeaders: rn86AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -2132,7 +2277,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn94AllowedHeaders,
allowedHeaders: rn98AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -2162,7 +2307,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn102AllowedHeaders,
allowedHeaders: rn108AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -2195,7 +2340,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn92AllowedHeaders,
allowedHeaders: rn96AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -2237,7 +2382,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "GET,POST",
allowedHeaders: rn22AllowedHeaders,
allowedHeaders: rn27AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -2279,7 +2424,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "GET,PATCH",
allowedHeaders: rn53AllowedHeaders,
allowedHeaders: rn57AllowedHeaders,
acceptPost: "",
acceptPatch: "application/json",
})
@@ -2356,7 +2501,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn80AllowedHeaders,
allowedHeaders: rn84AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -2967,6 +3112,131 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
}
}
case 'l': // Prefix: "labs"
if l := len("labs"); len(elem) >= l && elem[0:l] == "labs" {
elem = elem[l:]
} else {
break
}
if len(elem) == 0 {
switch method {
case "POST":
r.name = CreateMyAssessmentLabOperation
r.summary = "Start the lab of the current lab item of an assessment attempt."
r.operationID = "CreateMyAssessmentLab"
r.operationGroup = ""
r.pathPattern = "/api/v1/me/assessment-attempts/{attempt_id}/labs"
r.args = args
r.count = 1
return r, true
default:
return
}
}
switch elem[0] {
case '/': // Prefix: "/"
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
elem = elem[l:]
} else {
break
}
// Param: "lab_id"
// Match until "/"
idx := strings.IndexByte(elem, '/')
if idx < 0 {
idx = len(elem)
}
args[1] = elem[:idx]
elem = elem[idx:]
if len(elem) == 0 {
switch method {
case "GET":
r.name = GetMyAssessmentLabOperation
r.summary = "Read the lab of an assessment attempt item."
r.operationID = "GetMyAssessmentLab"
r.operationGroup = ""
r.pathPattern = "/api/v1/me/assessment-attempts/{attempt_id}/labs/{lab_id}"
r.args = args
r.count = 2
return r, true
default:
return
}
}
switch elem[0] {
case '/': // Prefix: "/"
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
elem = elem[l:]
} else {
break
}
if len(elem) == 0 {
break
}
switch elem[0] {
case 'c': // Prefix: "console-sessions"
if l := len("console-sessions"); len(elem) >= l && elem[0:l] == "console-sessions" {
elem = elem[l:]
} else {
break
}
if len(elem) == 0 {
// Leaf node.
switch method {
case "POST":
r.name = CreateMyAssessmentLabConsoleSessionOperation
r.summary = "Open a console session of one node of a ready lab."
r.operationID = "CreateMyAssessmentLabConsoleSession"
r.operationGroup = ""
r.pathPattern = "/api/v1/me/assessment-attempts/{attempt_id}/labs/{lab_id}/console-sessions"
r.args = args
r.count = 2
return r, true
default:
return
}
}
case 's': // Prefix: "submission"
if l := len("submission"); len(elem) >= l && elem[0:l] == "submission" {
elem = elem[l:]
} else {
break
}
if len(elem) == 0 {
// Leaf node.
switch method {
case "POST":
r.name = SubmitMyAssessmentLabOperation
r.summary = "Submit the lab of the current lab item as its answer."
r.operationID = "SubmitMyAssessmentLab"
r.operationGroup = ""
r.pathPattern = "/api/v1/me/assessment-attempts/{attempt_id}/labs/{lab_id}/submission"
r.args = args
r.count = 2
return r, true
default:
return
}
}
}
}
}
case 'p': // Prefix: "practice-runs"
if l := len("practice-runs"); len(elem) >= l && elem[0:l] == "practice-runs" {
@@ -3610,6 +3610,488 @@ func (s *AssessmentItem) SetContent(val ItemContent) {
type AssessmentItemId uuid.UUID
// Candidate view of the lab of one attempt item. It contains no node address, MAC address, port,
// password, key, token, seed, checker state, criteria, score, or infrastructure name.
// Ref: #/components/schemas/AssessmentLab
type AssessmentLab struct {
// Identifier of the lab.
ID uuid.UUID `json:"id"`
ItemID AssessmentItemId `json:"item_id"`
State AssessmentLabState `json:"state"`
Nodes []AssessmentLabNode `json:"nodes"`
CreatedAt Timestamp `json:"created_at"`
// Time the lab became `ready`, or null before.
ReadyAt NilTimestamp `json:"ready_at"`
// Time the lab ends unless it was submitted before: the earlier of the lifetime of the item and the
// attempt deadline. It never moves.
ExpiresAt Timestamp `json:"expires_at"`
// Time the lab reached `submitted`, `expired`, or `failed`, or null.
FinishedAt NilTimestamp `json:"finished_at"`
// `lab_error` when `state` is `failed`, otherwise null.
FailureReason NilAssessmentLabFailureReason `json:"failure_reason"`
}
// GetID returns the value of ID.
func (s *AssessmentLab) GetID() uuid.UUID {
return s.ID
}
// GetItemID returns the value of ItemID.
func (s *AssessmentLab) GetItemID() AssessmentItemId {
return s.ItemID
}
// GetState returns the value of State.
func (s *AssessmentLab) GetState() AssessmentLabState {
return s.State
}
// GetNodes returns the value of Nodes.
func (s *AssessmentLab) GetNodes() []AssessmentLabNode {
return s.Nodes
}
// GetCreatedAt returns the value of CreatedAt.
func (s *AssessmentLab) GetCreatedAt() Timestamp {
return s.CreatedAt
}
// GetReadyAt returns the value of ReadyAt.
func (s *AssessmentLab) GetReadyAt() NilTimestamp {
return s.ReadyAt
}
// GetExpiresAt returns the value of ExpiresAt.
func (s *AssessmentLab) GetExpiresAt() Timestamp {
return s.ExpiresAt
}
// GetFinishedAt returns the value of FinishedAt.
func (s *AssessmentLab) GetFinishedAt() NilTimestamp {
return s.FinishedAt
}
// GetFailureReason returns the value of FailureReason.
func (s *AssessmentLab) GetFailureReason() NilAssessmentLabFailureReason {
return s.FailureReason
}
// SetID sets the value of ID.
func (s *AssessmentLab) SetID(val uuid.UUID) {
s.ID = val
}
// SetItemID sets the value of ItemID.
func (s *AssessmentLab) SetItemID(val AssessmentItemId) {
s.ItemID = val
}
// SetState sets the value of State.
func (s *AssessmentLab) SetState(val AssessmentLabState) {
s.State = val
}
// SetNodes sets the value of Nodes.
func (s *AssessmentLab) SetNodes(val []AssessmentLabNode) {
s.Nodes = val
}
// SetCreatedAt sets the value of CreatedAt.
func (s *AssessmentLab) SetCreatedAt(val Timestamp) {
s.CreatedAt = val
}
// SetReadyAt sets the value of ReadyAt.
func (s *AssessmentLab) SetReadyAt(val NilTimestamp) {
s.ReadyAt = val
}
// SetExpiresAt sets the value of ExpiresAt.
func (s *AssessmentLab) SetExpiresAt(val Timestamp) {
s.ExpiresAt = val
}
// SetFinishedAt sets the value of FinishedAt.
func (s *AssessmentLab) SetFinishedAt(val NilTimestamp) {
s.FinishedAt = val
}
// SetFailureReason sets the value of FailureReason.
func (s *AssessmentLab) SetFailureReason(val NilAssessmentLabFailureReason) {
s.FailureReason = val
}
// A console session of one node. The client opens a WebSocket to `websocket_path` on the same origin
// before `expires_at`; the session cookie and the Origin check authorize the upgrade, so no secret
// travels in the path, the body, or a query string. A session can be attached once and ends with the
// lab.
// Ref: #/components/schemas/AssessmentLabConsoleSession
type AssessmentLabConsoleSession struct {
// Identifier of the console session; it is not a secret.
ID uuid.UUID `json:"id"`
Node AssessmentLabNodeName `json:"node"`
// Same-origin path of the console WebSocket.
WebsocketPath string `json:"websocket_path"`
// Time by which the WebSocket must be opened.
ExpiresAt Timestamp `json:"expires_at"`
}
// GetID returns the value of ID.
func (s *AssessmentLabConsoleSession) GetID() uuid.UUID {
return s.ID
}
// GetNode returns the value of Node.
func (s *AssessmentLabConsoleSession) GetNode() AssessmentLabNodeName {
return s.Node
}
// GetWebsocketPath returns the value of WebsocketPath.
func (s *AssessmentLabConsoleSession) GetWebsocketPath() string {
return s.WebsocketPath
}
// GetExpiresAt returns the value of ExpiresAt.
func (s *AssessmentLabConsoleSession) GetExpiresAt() Timestamp {
return s.ExpiresAt
}
// SetID sets the value of ID.
func (s *AssessmentLabConsoleSession) SetID(val uuid.UUID) {
s.ID = val
}
// SetNode sets the value of Node.
func (s *AssessmentLabConsoleSession) SetNode(val AssessmentLabNodeName) {
s.Node = val
}
// SetWebsocketPath sets the value of WebsocketPath.
func (s *AssessmentLabConsoleSession) SetWebsocketPath(val string) {
s.WebsocketPath = val
}
// SetExpiresAt sets the value of ExpiresAt.
func (s *AssessmentLabConsoleSession) SetExpiresAt(val Timestamp) {
s.ExpiresAt = val
}
// Open a console of one node of a ready lab. Unknown fields are rejected.
// Ref: #/components/schemas/AssessmentLabConsoleSessionCreate
type AssessmentLabConsoleSessionCreate struct {
Node AssessmentLabNodeName `json:"node"`
}
// GetNode returns the value of Node.
func (s *AssessmentLabConsoleSessionCreate) GetNode() AssessmentLabNodeName {
return s.Node
}
// SetNode sets the value of Node.
func (s *AssessmentLabConsoleSessionCreate) SetNode(val AssessmentLabNodeName) {
s.Node = val
}
// AssessmentLabConsoleSessionHeaders wraps AssessmentLabConsoleSession with response headers.
type AssessmentLabConsoleSessionHeaders struct {
CacheControl CacheControlNoStore
Response AssessmentLabConsoleSession
}
// GetCacheControl returns the value of CacheControl.
func (s *AssessmentLabConsoleSessionHeaders) GetCacheControl() CacheControlNoStore {
return s.CacheControl
}
// GetResponse returns the value of Response.
func (s *AssessmentLabConsoleSessionHeaders) GetResponse() AssessmentLabConsoleSession {
return s.Response
}
// SetCacheControl sets the value of CacheControl.
func (s *AssessmentLabConsoleSessionHeaders) SetCacheControl(val CacheControlNoStore) {
s.CacheControl = val
}
// SetResponse sets the value of Response.
func (s *AssessmentLabConsoleSessionHeaders) SetResponse(val AssessmentLabConsoleSession) {
s.Response = val
}
func (*AssessmentLabConsoleSessionHeaders) createMyAssessmentLabConsoleSessionRes() {}
// Start the lab of the current lab item. Unknown fields are rejected.
// Ref: #/components/schemas/AssessmentLabCreate
type AssessmentLabCreate struct {
ItemID AssessmentItemId `json:"item_id"`
}
// GetItemID returns the value of ItemID.
func (s *AssessmentLabCreate) GetItemID() AssessmentItemId {
return s.ItemID
}
// SetItemID sets the value of ItemID.
func (s *AssessmentLabCreate) SetItemID(val AssessmentItemId) {
s.ItemID = val
}
// Why a lab failed: `lab_error` for an infrastructure failure, such as a node that did not boot or a
// check that could not reach a node. It never depends on the candidate and is never a failed check.
// Ref: #/components/schemas/AssessmentLabFailureReason
type AssessmentLabFailureReason string
const (
AssessmentLabFailureReasonLabError AssessmentLabFailureReason = "lab_error"
)
// AllValues returns all AssessmentLabFailureReason values.
func (AssessmentLabFailureReason) AllValues() []AssessmentLabFailureReason {
return []AssessmentLabFailureReason{
AssessmentLabFailureReasonLabError,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s AssessmentLabFailureReason) MarshalText() ([]byte, error) {
switch s {
case AssessmentLabFailureReasonLabError:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *AssessmentLabFailureReason) UnmarshalText(data []byte) error {
switch AssessmentLabFailureReason(data) {
case AssessmentLabFailureReasonLabError:
*s = AssessmentLabFailureReasonLabError
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
// AssessmentLabHeaders wraps AssessmentLab with response headers.
type AssessmentLabHeaders struct {
CacheControl CacheControlNoStore
Response AssessmentLab
}
// GetCacheControl returns the value of CacheControl.
func (s *AssessmentLabHeaders) GetCacheControl() CacheControlNoStore {
return s.CacheControl
}
// GetResponse returns the value of Response.
func (s *AssessmentLabHeaders) GetResponse() AssessmentLab {
return s.Response
}
// SetCacheControl sets the value of CacheControl.
func (s *AssessmentLabHeaders) SetCacheControl(val CacheControlNoStore) {
s.CacheControl = val
}
// SetResponse sets the value of Response.
func (s *AssessmentLabHeaders) SetResponse(val AssessmentLab) {
s.Response = val
}
func (*AssessmentLabHeaders) getMyAssessmentLabRes() {}
func (*AssessmentLabHeaders) submitMyAssessmentLabRes() {}
// A node of a lab by its task name and kind. It never carries an address, a MAC address, a port, a
// password, a key, or an infrastructure name.
// Ref: #/components/schemas/AssessmentLabNode
type AssessmentLabNode struct {
Name AssessmentLabNodeName `json:"name"`
Kind AssessmentLabNodeKind `json:"kind"`
}
// GetName returns the value of Name.
func (s *AssessmentLabNode) GetName() AssessmentLabNodeName {
return s.Name
}
// GetKind returns the value of Kind.
func (s *AssessmentLabNode) GetKind() AssessmentLabNodeKind {
return s.Kind
}
// SetName sets the value of Name.
func (s *AssessmentLabNode) SetName(val AssessmentLabNodeName) {
s.Name = val
}
// SetKind sets the value of Kind.
func (s *AssessmentLabNode) SetKind(val AssessmentLabNodeKind) {
s.Kind = val
}
// What the console of a node shows.
//
// - mikrotik: a MikroTik router with the RouterOS console.
// - ubuntu: a small Ubuntu server with a Linux login.
//
// Adding a value is a contract change.
// Ref: #/components/schemas/AssessmentLabNodeKind
type AssessmentLabNodeKind string
const (
AssessmentLabNodeKindMikrotik AssessmentLabNodeKind = "mikrotik"
AssessmentLabNodeKindUbuntu AssessmentLabNodeKind = "ubuntu"
)
// AllValues returns all AssessmentLabNodeKind values.
func (AssessmentLabNodeKind) AllValues() []AssessmentLabNodeKind {
return []AssessmentLabNodeKind{
AssessmentLabNodeKindMikrotik,
AssessmentLabNodeKindUbuntu,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s AssessmentLabNodeKind) MarshalText() ([]byte, error) {
switch s {
case AssessmentLabNodeKindMikrotik:
return []byte(s), nil
case AssessmentLabNodeKindUbuntu:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *AssessmentLabNodeKind) UnmarshalText(data []byte) error {
switch AssessmentLabNodeKind(data) {
case AssessmentLabNodeKindMikrotik:
*s = AssessmentLabNodeKindMikrotik
return nil
case AssessmentLabNodeKindUbuntu:
*s = AssessmentLabNodeKindUbuntu
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
type AssessmentLabNodeName string
// State of a lab of an attempt item.
//
// - provisioning: the nodes are being prepared; poll GetMyAssessmentLab.
// - ready: the consoles can be opened until `expires_at`.
// - checking: the answer was accepted; the consoles are closed and the server checks the nodes.
// - submitted: the check finished and the answer is recorded; the lab is deleted. The state never
// says whether the answer was correct.
// - expired: the lifetime or the attempt deadline ended before a submission; the lab is deleted and
// the item cannot start another lab.
// - failed: the lab infrastructure failed, independently of the candidate; `failure_reason` is
// `lab_error`. Nothing was recorded or consumed, and the candidate may start a new lab of the same
// item while the item is current.
//
// Adding a value is a contract change.
// Ref: #/components/schemas/AssessmentLabState
type AssessmentLabState string
const (
AssessmentLabStateProvisioning AssessmentLabState = "provisioning"
AssessmentLabStateReady AssessmentLabState = "ready"
AssessmentLabStateChecking AssessmentLabState = "checking"
AssessmentLabStateSubmitted AssessmentLabState = "submitted"
AssessmentLabStateExpired AssessmentLabState = "expired"
AssessmentLabStateFailed AssessmentLabState = "failed"
)
// AllValues returns all AssessmentLabState values.
func (AssessmentLabState) AllValues() []AssessmentLabState {
return []AssessmentLabState{
AssessmentLabStateProvisioning,
AssessmentLabStateReady,
AssessmentLabStateChecking,
AssessmentLabStateSubmitted,
AssessmentLabStateExpired,
AssessmentLabStateFailed,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s AssessmentLabState) MarshalText() ([]byte, error) {
switch s {
case AssessmentLabStateProvisioning:
return []byte(s), nil
case AssessmentLabStateReady:
return []byte(s), nil
case AssessmentLabStateChecking:
return []byte(s), nil
case AssessmentLabStateSubmitted:
return []byte(s), nil
case AssessmentLabStateExpired:
return []byte(s), nil
case AssessmentLabStateFailed:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *AssessmentLabState) UnmarshalText(data []byte) error {
switch AssessmentLabState(data) {
case AssessmentLabStateProvisioning:
*s = AssessmentLabStateProvisioning
return nil
case AssessmentLabStateReady:
*s = AssessmentLabStateReady
return nil
case AssessmentLabStateChecking:
*s = AssessmentLabStateChecking
return nil
case AssessmentLabStateSubmitted:
*s = AssessmentLabStateSubmitted
return nil
case AssessmentLabStateExpired:
*s = AssessmentLabStateExpired
return nil
case AssessmentLabStateFailed:
*s = AssessmentLabStateFailed
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
// Submit the lab of the current lab item as its answer. Unknown fields are rejected, so a request
// cannot send a score or a correctness flag.
// Ref: #/components/schemas/AssessmentLabSubmission
type AssessmentLabSubmission struct {
ExpectedVersion AssessmentAttemptVersion `json:"expected_version"`
Answer LabAnswer `json:"answer"`
}
// GetExpectedVersion returns the value of ExpectedVersion.
func (s *AssessmentLabSubmission) GetExpectedVersion() AssessmentAttemptVersion {
return s.ExpectedVersion
}
// GetAnswer returns the value of Answer.
func (s *AssessmentLabSubmission) GetAnswer() LabAnswer {
return s.Answer
}
// SetExpectedVersion sets the value of ExpectedVersion.
func (s *AssessmentLabSubmission) SetExpectedVersion(val AssessmentAttemptVersion) {
s.ExpectedVersion = val
}
// SetAnswer sets the value of Answer.
func (s *AssessmentLabSubmission) SetAnswer(val LabAnswer) {
s.Answer = val
}
// Known limitation of the method behind a real-assessment result, shown with the result.
//
// - uncalibrated_thresholds: the thresholds are not yet validated on a pilot.
@@ -9746,6 +10228,58 @@ type CreateMyAssessmentAttemptUnprocessableEntity Problem
func (*CreateMyAssessmentAttemptUnprocessableEntity) createMyAssessmentAttemptRes() {}
type CreateMyAssessmentLabBadRequest Problem
func (*CreateMyAssessmentLabBadRequest) createMyAssessmentLabRes() {}
type CreateMyAssessmentLabConflict Problem
func (*CreateMyAssessmentLabConflict) createMyAssessmentLabRes() {}
type CreateMyAssessmentLabConsoleSessionBadRequest Problem
func (*CreateMyAssessmentLabConsoleSessionBadRequest) createMyAssessmentLabConsoleSessionRes() {}
type CreateMyAssessmentLabConsoleSessionConflict Problem
func (*CreateMyAssessmentLabConsoleSessionConflict) createMyAssessmentLabConsoleSessionRes() {}
type CreateMyAssessmentLabConsoleSessionForbidden Problem
func (*CreateMyAssessmentLabConsoleSessionForbidden) createMyAssessmentLabConsoleSessionRes() {}
type CreateMyAssessmentLabConsoleSessionNotFound Problem
func (*CreateMyAssessmentLabConsoleSessionNotFound) createMyAssessmentLabConsoleSessionRes() {}
type CreateMyAssessmentLabConsoleSessionUnauthorized Problem
func (*CreateMyAssessmentLabConsoleSessionUnauthorized) createMyAssessmentLabConsoleSessionRes() {}
type CreateMyAssessmentLabCreated AssessmentLabHeaders
func (*CreateMyAssessmentLabCreated) createMyAssessmentLabRes() {}
type CreateMyAssessmentLabForbidden Problem
func (*CreateMyAssessmentLabForbidden) createMyAssessmentLabRes() {}
type CreateMyAssessmentLabNotFound Problem
func (*CreateMyAssessmentLabNotFound) createMyAssessmentLabRes() {}
type CreateMyAssessmentLabOK AssessmentLabHeaders
func (*CreateMyAssessmentLabOK) createMyAssessmentLabRes() {}
type CreateMyAssessmentLabUnauthorized Problem
func (*CreateMyAssessmentLabUnauthorized) createMyAssessmentLabRes() {}
type CreateMyAssessmentLabUnprocessableEntity Problem
func (*CreateMyAssessmentLabUnprocessableEntity) createMyAssessmentLabRes() {}
type CreateMyAssessmentPracticeRunBadRequest Problem
func (*CreateMyAssessmentPracticeRunBadRequest) createMyAssessmentPracticeRunRes() {}
@@ -11015,6 +11549,18 @@ type GetMyAssessmentAvailabilityUnauthorized Problem
func (*GetMyAssessmentAvailabilityUnauthorized) getMyAssessmentAvailabilityRes() {}
type GetMyAssessmentLabForbidden Problem
func (*GetMyAssessmentLabForbidden) getMyAssessmentLabRes() {}
type GetMyAssessmentLabNotFound Problem
func (*GetMyAssessmentLabNotFound) getMyAssessmentLabRes() {}
type GetMyAssessmentLabUnauthorized Problem
func (*GetMyAssessmentLabUnauthorized) getMyAssessmentLabRes() {}
type GetMyAssessmentPracticeRunForbidden Problem
func (*GetMyAssessmentPracticeRunForbidden) getMyAssessmentPracticeRunRes() {}
@@ -12862,6 +13408,7 @@ type ItemContent struct {
FindErrorItemContent FindErrorItemContent
ConfigurationItemContent ConfigurationItemContent
PracticeItemContent PracticeItemContent
LabItemContent LabItemContent
}
// ItemContentType is oneOf type of ItemContent.
@@ -12876,6 +13423,7 @@ const (
FindErrorItemContentItemContent ItemContentType = "FindErrorItemContent"
ConfigurationItemContentItemContent ItemContentType = "ConfigurationItemContent"
PracticeItemContentItemContent ItemContentType = "PracticeItemContent"
LabItemContentItemContent ItemContentType = "LabItemContent"
)
// IsChoiceItemContent reports whether ItemContent is ChoiceItemContent.
@@ -12901,6 +13449,9 @@ func (s ItemContent) IsConfigurationItemContent() bool {
// IsPracticeItemContent reports whether ItemContent is PracticeItemContent.
func (s ItemContent) IsPracticeItemContent() bool { return s.Type == PracticeItemContentItemContent }
// IsLabItemContent reports whether ItemContent is LabItemContent.
func (s ItemContent) IsLabItemContent() bool { return s.Type == LabItemContentItemContent }
// SetChoiceItemContent sets ItemContent to ChoiceItemContent.
func (s *ItemContent) SetChoiceItemContent(v ChoiceItemContent) {
s.Type = ChoiceItemContentItemContent
@@ -13048,6 +13599,172 @@ func NewPracticeItemContentItemContent(v PracticeItemContent) ItemContent {
return s
}
// SetLabItemContent sets ItemContent to LabItemContent.
func (s *ItemContent) SetLabItemContent(v LabItemContent) {
s.Type = LabItemContentItemContent
s.LabItemContent = v
}
// GetLabItemContent returns LabItemContent and true boolean if ItemContent is LabItemContent.
func (s ItemContent) GetLabItemContent() (v LabItemContent, ok bool) {
if !s.IsLabItemContent() {
return v, false
}
return s.LabItemContent, true
}
// NewLabItemContentItemContent returns new ItemContent from LabItemContent.
func NewLabItemContentItemContent(v LabItemContent) ItemContent {
var s ItemContent
s.SetLabItemContent(v)
return s
}
// Answer of a lab item: the state of the nodes of the named lab at the moment of submission. The
// server reads that state with the checker of the task; the body carries no configuration text, score,
// or correctness flag. Two answers are equal when they name the same lab. It is the answer of
// SubmitMyAssessmentLab only and is not a member of AssessmentAnswer.
// Ref: #/components/schemas/LabAnswer
type LabAnswer struct {
Format LabAnswerFormat `json:"format"`
// The lab of this item that the candidate worked in.
LabID uuid.UUID `json:"lab_id"`
}
// GetFormat returns the value of Format.
func (s *LabAnswer) GetFormat() LabAnswerFormat {
return s.Format
}
// GetLabID returns the value of LabID.
func (s *LabAnswer) GetLabID() uuid.UUID {
return s.LabID
}
// SetFormat sets the value of Format.
func (s *LabAnswer) SetFormat(val LabAnswerFormat) {
s.Format = val
}
// SetLabID sets the value of LabID.
func (s *LabAnswer) SetLabID(val uuid.UUID) {
s.LabID = val
}
type LabAnswerFormat string
const (
LabAnswerFormatLab LabAnswerFormat = "lab"
)
// AllValues returns all LabAnswerFormat values.
func (LabAnswerFormat) AllValues() []LabAnswerFormat {
return []LabAnswerFormat{
LabAnswerFormatLab,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s LabAnswerFormat) MarshalText() ([]byte, error) {
switch s {
case LabAnswerFormatLab:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *LabAnswerFormat) UnmarshalText(data []byte) error {
switch LabAnswerFormat(data) {
case LabAnswerFormatLab:
*s = LabAnswerFormatLab
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
// Practical lab: configure or repair a small network of virtual nodes through their consoles. The
// candidate starts the lab of the item with CreateMyAssessmentLab, works in the node consoles, and
// submits with SubmitMyAssessmentLab; the server then checks the state of the nodes. The content lists
// only the nodes the statement names and the lifetime of the lab, never the checker, its criteria, the
// seed, or an address. SubmitMyAssessmentAnswer takes no answer to a lab item; its result is submitted
// only with SubmitMyAssessmentLab.
// Ref: #/components/schemas/LabItemContent
type LabItemContent struct {
Format LabItemContentFormat `json:"format"`
// Nodes of the lab in the order of the statement.
Nodes []AssessmentLabNode `json:"nodes"`
// Lifetime of a lab of this item from its creation. The lab also ends no later than the attempt
// deadline.
TimeLimitSeconds int32 `json:"time_limit_seconds"`
}
// GetFormat returns the value of Format.
func (s *LabItemContent) GetFormat() LabItemContentFormat {
return s.Format
}
// GetNodes returns the value of Nodes.
func (s *LabItemContent) GetNodes() []AssessmentLabNode {
return s.Nodes
}
// GetTimeLimitSeconds returns the value of TimeLimitSeconds.
func (s *LabItemContent) GetTimeLimitSeconds() int32 {
return s.TimeLimitSeconds
}
// SetFormat sets the value of Format.
func (s *LabItemContent) SetFormat(val LabItemContentFormat) {
s.Format = val
}
// SetNodes sets the value of Nodes.
func (s *LabItemContent) SetNodes(val []AssessmentLabNode) {
s.Nodes = val
}
// SetTimeLimitSeconds sets the value of TimeLimitSeconds.
func (s *LabItemContent) SetTimeLimitSeconds(val int32) {
s.TimeLimitSeconds = val
}
type LabItemContentFormat string
const (
LabItemContentFormatLab LabItemContentFormat = "lab"
)
// AllValues returns all LabItemContentFormat values.
func (LabItemContentFormat) AllValues() []LabItemContentFormat {
return []LabItemContentFormat{
LabItemContentFormatLab,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s LabItemContentFormat) MarshalText() ([]byte, error) {
switch s {
case LabItemContentFormatLab:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *LabItemContentFormat) UnmarshalText(data []byte) error {
switch LabItemContentFormat(data) {
case LabItemContentFormatLab:
*s = LabItemContentFormatLab
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
type ListMyAssessmentResultsBadRequest Problem
func (*ListMyAssessmentResultsBadRequest) listMyAssessmentResultsRes() {}
@@ -17873,6 +18590,51 @@ func (o NilAssessmentItem) Or(d AssessmentItem) AssessmentItem {
return d
}
// NewNilAssessmentLabFailureReason returns new NilAssessmentLabFailureReason with value set to v.
func NewNilAssessmentLabFailureReason(v AssessmentLabFailureReason) NilAssessmentLabFailureReason {
return NilAssessmentLabFailureReason{
Value: v,
}
}
// NilAssessmentLabFailureReason is nullable AssessmentLabFailureReason.
type NilAssessmentLabFailureReason struct {
Value AssessmentLabFailureReason
Null bool
}
// SetTo sets value to v.
func (o *NilAssessmentLabFailureReason) SetTo(v AssessmentLabFailureReason) {
o.Null = false
o.Value = v
}
// IsNull returns true if value is Null.
func (o NilAssessmentLabFailureReason) IsNull() bool { return o.Null }
// SetToNull sets value to null.
func (o *NilAssessmentLabFailureReason) SetToNull() {
o.Null = true
var v AssessmentLabFailureReason
o.Value = v
}
// Get returns value and boolean that denotes whether value was set.
func (o NilAssessmentLabFailureReason) Get() (v AssessmentLabFailureReason, ok bool) {
if o.Null {
return v, false
}
return o.Value, true
}
// Or returns value if set, or given parameter if does not.
func (o NilAssessmentLabFailureReason) Or(d AssessmentLabFailureReason) AssessmentLabFailureReason {
if v, ok := o.Get(); ok {
return v
}
return d
}
// NewNilAssessmentNotDeterminedReason returns new NilAssessmentNotDeterminedReason with value set to v.
func NewNilAssessmentNotDeterminedReason(v AssessmentNotDeterminedReason) NilAssessmentNotDeterminedReason {
return NilAssessmentNotDeterminedReason{
@@ -30237,7 +30999,10 @@ func (s *ServiceUnavailableHeaders) SetResponse(val Problem) {
s.Response = val
}
func (*ServiceUnavailableHeaders) createMyAssessmentPracticeRunRes() {}
func (*ServiceUnavailableHeaders) createMyAssessmentLabConsoleSessionRes() {}
func (*ServiceUnavailableHeaders) createMyAssessmentLabRes() {}
func (*ServiceUnavailableHeaders) createMyAssessmentPracticeRunRes() {}
func (*ServiceUnavailableHeaders) submitMyAssessmentLabRes() {}
// Current session as the client may see it: the account and the CSRF token. The session identifier
// itself travels only in the HttpOnly session cookie and never appears in a body.
@@ -30717,6 +31482,34 @@ type SubmitMyAssessmentAnswerUnprocessableEntity Problem
func (*SubmitMyAssessmentAnswerUnprocessableEntity) submitMyAssessmentAnswerRes() {}
type SubmitMyAssessmentLabBadRequest Problem
func (*SubmitMyAssessmentLabBadRequest) submitMyAssessmentLabRes() {}
type SubmitMyAssessmentLabConflict Problem
func (*SubmitMyAssessmentLabConflict) submitMyAssessmentLabRes() {}
type SubmitMyAssessmentLabForbidden Problem
func (*SubmitMyAssessmentLabForbidden) submitMyAssessmentLabRes() {}
type SubmitMyAssessmentLabNotFound Problem
func (*SubmitMyAssessmentLabNotFound) submitMyAssessmentLabRes() {}
type SubmitMyAssessmentLabPreconditionFailed Problem
func (*SubmitMyAssessmentLabPreconditionFailed) submitMyAssessmentLabRes() {}
type SubmitMyAssessmentLabUnauthorized Problem
func (*SubmitMyAssessmentLabUnauthorized) submitMyAssessmentLabRes() {}
type SubmitMyAssessmentLabUnprocessableEntity Problem
func (*SubmitMyAssessmentLabUnprocessableEntity) submitMyAssessmentLabRes() {}
// Case of the current account. It contains what the author sent, the public processing state, and the
// public history. It never contains the identity of a moderator, an expert, or a support agent,
// internal notes, evidence, assessment answers or anti-cheat signals, risk signals, or contact data of
@@ -32837,36 +33630,39 @@ func (s *TooManyRequestsHeaders) SetResponse(val Problem) {
s.Response = val
}
func (*TooManyRequestsHeaders) acceptMyInvitationRes() {}
func (*TooManyRequestsHeaders) cancelMyInvitationRes() {}
func (*TooManyRequestsHeaders) confirmEmailByCodeRes() {}
func (*TooManyRequestsHeaders) confirmEmailRes() {}
func (*TooManyRequestsHeaders) createMyAssessmentAttemptRes() {}
func (*TooManyRequestsHeaders) createMyAssessmentPracticeRunRes() {}
func (*TooManyRequestsHeaders) createMySupportCaseRes() {}
func (*TooManyRequestsHeaders) createOrganizationInvitationRes() {}
func (*TooManyRequestsHeaders) createOrganizationNeedRes() {}
func (*TooManyRequestsHeaders) createOrganizationRes() {}
func (*TooManyRequestsHeaders) declineMyInvitationRes() {}
func (*TooManyRequestsHeaders) getOrganizationCandidateCardRes() {}
func (*TooManyRequestsHeaders) getOrganizationCandidateEvidenceRes() {}
func (*TooManyRequestsHeaders) hideOrganizationRes() {}
func (*TooManyRequestsHeaders) loginRes() {}
func (*TooManyRequestsHeaders) markMyNotificationReadRes() {}
func (*TooManyRequestsHeaders) markOrganizationNotificationReadRes() {}
func (*TooManyRequestsHeaders) raiseOrganizationInvitationSalaryRes() {}
func (*TooManyRequestsHeaders) recordMyAssessmentAttemptSignalsRes() {}
func (*TooManyRequestsHeaders) registerAccountRes() {}
func (*TooManyRequestsHeaders) requestMyRepositoryChecksRes() {}
func (*TooManyRequestsHeaders) resendEmailVerificationRes() {}
func (*TooManyRequestsHeaders) sendOrganizationInvitationRes() {}
func (*TooManyRequestsHeaders) startMyAssessmentAttemptSessionRes() {}
func (*TooManyRequestsHeaders) submitMyAssessmentAnswerRes() {}
func (*TooManyRequestsHeaders) updateOrganizationInvitationRes() {}
func (*TooManyRequestsHeaders) updateOrganizationNeedRes() {}
func (*TooManyRequestsHeaders) updateOrganizationRes() {}
func (*TooManyRequestsHeaders) viewMyInvitationRes() {}
func (*TooManyRequestsHeaders) withdrawOrganizationInvitationRes() {}
func (*TooManyRequestsHeaders) acceptMyInvitationRes() {}
func (*TooManyRequestsHeaders) cancelMyInvitationRes() {}
func (*TooManyRequestsHeaders) confirmEmailByCodeRes() {}
func (*TooManyRequestsHeaders) confirmEmailRes() {}
func (*TooManyRequestsHeaders) createMyAssessmentAttemptRes() {}
func (*TooManyRequestsHeaders) createMyAssessmentLabConsoleSessionRes() {}
func (*TooManyRequestsHeaders) createMyAssessmentLabRes() {}
func (*TooManyRequestsHeaders) createMyAssessmentPracticeRunRes() {}
func (*TooManyRequestsHeaders) createMySupportCaseRes() {}
func (*TooManyRequestsHeaders) createOrganizationInvitationRes() {}
func (*TooManyRequestsHeaders) createOrganizationNeedRes() {}
func (*TooManyRequestsHeaders) createOrganizationRes() {}
func (*TooManyRequestsHeaders) declineMyInvitationRes() {}
func (*TooManyRequestsHeaders) getOrganizationCandidateCardRes() {}
func (*TooManyRequestsHeaders) getOrganizationCandidateEvidenceRes() {}
func (*TooManyRequestsHeaders) hideOrganizationRes() {}
func (*TooManyRequestsHeaders) loginRes() {}
func (*TooManyRequestsHeaders) markMyNotificationReadRes() {}
func (*TooManyRequestsHeaders) markOrganizationNotificationReadRes() {}
func (*TooManyRequestsHeaders) raiseOrganizationInvitationSalaryRes() {}
func (*TooManyRequestsHeaders) recordMyAssessmentAttemptSignalsRes() {}
func (*TooManyRequestsHeaders) registerAccountRes() {}
func (*TooManyRequestsHeaders) requestMyRepositoryChecksRes() {}
func (*TooManyRequestsHeaders) resendEmailVerificationRes() {}
func (*TooManyRequestsHeaders) sendOrganizationInvitationRes() {}
func (*TooManyRequestsHeaders) startMyAssessmentAttemptSessionRes() {}
func (*TooManyRequestsHeaders) submitMyAssessmentAnswerRes() {}
func (*TooManyRequestsHeaders) submitMyAssessmentLabRes() {}
func (*TooManyRequestsHeaders) updateOrganizationInvitationRes() {}
func (*TooManyRequestsHeaders) updateOrganizationNeedRes() {}
func (*TooManyRequestsHeaders) updateOrganizationRes() {}
func (*TooManyRequestsHeaders) viewMyInvitationRes() {}
func (*TooManyRequestsHeaders) withdrawOrganizationInvitationRes() {}
type UnhideOrganizationBadRequest Problem
@@ -60,6 +60,8 @@ var operationRolesSessionCookie = map[string][]string{
AcknowledgeMyAssessmentSignalNoticeOperation: []string{},
CancelMyInvitationOperation: []string{},
CreateMyAssessmentAttemptOperation: []string{},
CreateMyAssessmentLabOperation: []string{},
CreateMyAssessmentLabConsoleSessionOperation: []string{},
CreateMyAssessmentPracticeRunOperation: []string{},
CreateMySupportCaseOperation: []string{},
CreateOrganizationOperation: []string{},
@@ -71,6 +73,7 @@ var operationRolesSessionCookie = map[string][]string{
GetCurrentSessionOperation: []string{},
GetMyAssessmentAttemptOperation: []string{},
GetMyAssessmentAvailabilityOperation: []string{},
GetMyAssessmentLabOperation: []string{},
GetMyAssessmentPracticeRunOperation: []string{},
GetMyAssessmentResultOperation: []string{},
GetMyAssessmentSignalNoticeOperation: []string{},
@@ -121,6 +124,7 @@ var operationRolesSessionCookie = map[string][]string{
SetMySearchStatusOperation: []string{},
StartMyAssessmentAttemptSessionOperation: []string{},
SubmitMyAssessmentAnswerOperation: []string{},
SubmitMyAssessmentLabOperation: []string{},
UnhideOrganizationOperation: []string{},
UpdateOrganizationOperation: []string{},
UpdateOrganizationInvitationOperation: []string{},
@@ -156,6 +160,8 @@ var operationRolesSessionCsrf = map[string][]string{
AcknowledgeMyAssessmentSignalNoticeOperation: []string{},
CancelMyInvitationOperation: []string{},
CreateMyAssessmentAttemptOperation: []string{},
CreateMyAssessmentLabOperation: []string{},
CreateMyAssessmentLabConsoleSessionOperation: []string{},
CreateMyAssessmentPracticeRunOperation: []string{},
CreateMySupportCaseOperation: []string{},
CreateOrganizationOperation: []string{},
@@ -184,6 +190,7 @@ var operationRolesSessionCsrf = map[string][]string{
SetMySearchStatusOperation: []string{},
StartMyAssessmentAttemptSessionOperation: []string{},
SubmitMyAssessmentAnswerOperation: []string{},
SubmitMyAssessmentLabOperation: []string{},
UnhideOrganizationOperation: []string{},
UpdateOrganizationOperation: []string{},
UpdateOrganizationInvitationOperation: []string{},
@@ -230,6 +230,67 @@ type Handler interface {
//
// POST /api/v1/me/assessment-attempts
CreateMyAssessmentAttempt(ctx context.Context, req AssessmentAttemptCreate, params CreateMyAssessmentAttemptParams) (CreateMyAssessmentAttemptRes, error)
// CreateMyAssessmentLab implements CreateMyAssessmentLab operation.
//
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
// an allowed Origin, and an Idempotency-Key. The body names the current item, whose content has the
// format `lab`.
//
// The server asks the lab provisioner for a lab of the variant fixed for this item instance and
// answers 201 with the lab `provisioning`; the client polls GetMyAssessmentLab until it is `ready`.
// The lab lives until `expires_at`, the earlier of the item's `time_limit_seconds` and the attempt
// deadline, and is then deleted with everything done in it. Creating a lab does not change the attempt
// version, the current item, or any answer.
//
// One lab per item at a time. While the item has a lab in `provisioning`, `ready`, or `checking`, the
// server answers 200 with that lab and starts no second one. After a `failed` lab the candidate may
// start a new one while the item is current; after `submitted` or `expired` the item cannot start
// another lab (409 state_conflict).
//
// Busy pool. When the lab pool of the provisioner has no free capacity, the server answers 503
// service_unavailable with Retry-After, for example
// `{"type": "urn:lincodex:problem:service_unavailable", "title": "Service unavailable", "status": 503, "code": "service_unavailable", "detail": "No lab capacity is free. The attempt is unchanged; retry later."}`.
// Nothing was stored: no lab exists, the attempt version and the current item are unchanged, the lab
// lifetime has not started, and the attempt is not consumed; the client retries after Retry-After with
// a new Idempotency-Key. When labs are not enabled on this server, or the provisioner cannot be
// reached, the server answers 503 service_unavailable without Retry-After and stores nothing either.
// The attempt deadline keeps running in both cases.
//
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
// account scenario (403 forbidden), the Idempotency-Key (422, 409 idempotency_in_progress, replay),
// the attempt and the item (404 not_found for an unknown attempt or item, or one of another
// candidate), the state (409 state_conflict: the attempt is terminal or its work session ended, the
// item is not current, its format is not `lab`, or its lab was submitted or expired), the rate limit
// (429), then the availability of labs and the capacity (503). Following the Idempotency-Key
// convention, 201, 200, 404, and 409 state_conflict are stored under the key and replayed; 400, 429,
// and 503 are not.
//
// POST /api/v1/me/assessment-attempts/{attempt_id}/labs
CreateMyAssessmentLab(ctx context.Context, req *AssessmentLabCreate, params CreateMyAssessmentLabParams) (CreateMyAssessmentLabRes, error)
// CreateMyAssessmentLabConsoleSession implements CreateMyAssessmentLabConsoleSession operation.
//
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
// and an allowed Origin. The body names a node of the lab by its task name.
//
// The response describes one console session: the client opens a WebSocket to `websocket_path` on the
// same origin before `expires_at`. The upgrade is authorized by the session cookie and the Origin
// check, and the server relays the serial console of the node through the lab provisioner. The
// response never carries a node address, a port, a password, a key, or a token; the browser never
// connects to a node or to the provisioner. Console traffic is not stored as an answer and is not
// logged.
//
// The WebSocket relay is planned together with the candidate interface of labs; this contract fixes
// the session shape it uses.
//
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
// account scenario (403 forbidden), the attempt and the lab (404 not_found for an unknown attempt,
// lab, or one of another candidate), the node (400 with the pointer `/node`), the state (409
// state_conflict: the lab is not `ready`, the attempt is terminal, or its work session ended), the
// limit of open sessions per lab (429 rate_limited with Retry-After), then the provisioner (503
// service_unavailable without Retry-After; nothing was opened).
//
// POST /api/v1/me/assessment-attempts/{attempt_id}/labs/{lab_id}/console-sessions
CreateMyAssessmentLabConsoleSession(ctx context.Context, req *AssessmentLabConsoleSessionCreate, params CreateMyAssessmentLabConsoleSessionParams) (CreateMyAssessmentLabConsoleSessionRes, error)
// CreateMyAssessmentPracticeRun implements CreateMyAssessmentPracticeRun operation.
//
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
@@ -663,6 +724,19 @@ type Handler interface {
//
// GET /api/v1/me/assessment-availability
GetMyAssessmentAvailability(ctx context.Context) (GetMyAssessmentAvailabilityRes, error)
// GetMyAssessmentLab implements GetMyAssessmentLab operation.
//
// Requires the session cookie of a candidate account. Returns the state of a lab started with
// CreateMyAssessmentLab: whether it is still provisioning, ready for the consoles, being checked after
// the submission, or ended. It never contains a node address, a credential, the seed, the checker
// state, or the result of the check. This GET is read-only; the server may record a due timer
// transition, such as `ready` to `expired`, before it answers.
//
// A lab of another candidate's attempt, a lab of another attempt, and an unknown identifier all answer
// 404 not_found.
//
// GET /api/v1/me/assessment-attempts/{attempt_id}/labs/{lab_id}
GetMyAssessmentLab(ctx context.Context, params GetMyAssessmentLabParams) (GetMyAssessmentLabRes, error)
// GetMyAssessmentPracticeRun implements GetMyAssessmentPracticeRun operation.
//
// Requires the session cookie of a candidate account. Returns the state of a debug run started with
@@ -2031,6 +2105,10 @@ type Handler interface {
// times itself and scores the answer with the key of the fixed item instance. Time never enters the
// ability estimate or the grade decision.
//
// Lab: an item with format `lab` takes no answer here. Its lab is started with CreateMyAssessmentLab
// and submitted with SubmitMyAssessmentLab; any answer to a lab item answers 400 validation_failed
// with the pointer `/answer/format`, like an answer in the wrong format, and stores nothing.
//
// The response is the attempt with the next item to answer. It never says whether the answer was
// correct. Items are answered in order and each answer is final.
//
@@ -2089,6 +2167,37 @@ type Handler interface {
//
// POST /api/v1/me/assessment-attempts/{attempt_id}/answers
SubmitMyAssessmentAnswer(ctx context.Context, req *AssessmentAnswerSubmission, params SubmitMyAssessmentAnswerParams) (SubmitMyAssessmentAnswerRes, error)
// SubmitMyAssessmentLab implements SubmitMyAssessmentLab operation.
//
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
// an allowed Origin, and an Idempotency-Key. The body carries the attempt version last read and the
// answer with format `lab`, which names the lab.
//
// The server closes the consoles, freezes the lab, and answers 202 with the lab `checking`; the
// checker of the task reads the state of the nodes asynchronously, the answer is recorded, and the lab
// becomes `submitted` and is deleted. The client polls GetMyAssessmentLab and then reads the attempt,
// which moves to the next item. Neither response says whether the answer was correct, and the
// candidate never sees the checker criteria or their results.
//
// When the checker cannot reach the nodes because of the lab infrastructure, the lab becomes `failed`
// with `lab_error`: nothing is recorded or consumed, the attempt version is unchanged, and the
// candidate may start a new lab of the item while it is current. A failure of the infrastructure is
// never scored as a wrong answer.
//
// Optimistic concurrency: `expected_version` must equal the current attempt version, otherwise the
// server answers 412 version_conflict and stores nothing.
//
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
// account scenario (403 forbidden), the Idempotency-Key (422, 409 idempotency_in_progress, replay),
// the attempt and the lab (404 not_found for an unknown attempt or lab, or one of another candidate),
// the version (412), the state (409 state_conflict: the lab is not `ready`, `answer.lab_id` is not the
// lab in the path, the item is not current, the attempt is terminal, or its work session ended), then
// the provisioner (503 service_unavailable without Retry-After; nothing was stored and the lab keeps
// running). Following the Idempotency-Key convention, 202, 404, and 409 state_conflict are stored
// under the key and replayed; 400, 412, 429, and 5xx are not.
//
// POST /api/v1/me/assessment-attempts/{attempt_id}/labs/{lab_id}/submission
SubmitMyAssessmentLab(ctx context.Context, req *AssessmentLabSubmission, params SubmitMyAssessmentLabParams) (SubmitMyAssessmentLabRes, error)
// UnhideOrganization implements UnhideOrganization operation.
//
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
@@ -253,6 +253,73 @@ func (UnimplementedHandler) CreateMyAssessmentAttempt(ctx context.Context, req A
return r, ht.ErrNotImplemented
}
// CreateMyAssessmentLab implements CreateMyAssessmentLab operation.
//
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
// an allowed Origin, and an Idempotency-Key. The body names the current item, whose content has the
// format `lab`.
//
// The server asks the lab provisioner for a lab of the variant fixed for this item instance and
// answers 201 with the lab `provisioning`; the client polls GetMyAssessmentLab until it is `ready`.
// The lab lives until `expires_at`, the earlier of the item's `time_limit_seconds` and the attempt
// deadline, and is then deleted with everything done in it. Creating a lab does not change the attempt
// version, the current item, or any answer.
//
// One lab per item at a time. While the item has a lab in `provisioning`, `ready`, or `checking`, the
// server answers 200 with that lab and starts no second one. After a `failed` lab the candidate may
// start a new one while the item is current; after `submitted` or `expired` the item cannot start
// another lab (409 state_conflict).
//
// Busy pool. When the lab pool of the provisioner has no free capacity, the server answers 503
// service_unavailable with Retry-After, for example
// `{"type": "urn:lincodex:problem:service_unavailable", "title": "Service unavailable", "status": 503, "code": "service_unavailable", "detail": "No lab capacity is free. The attempt is unchanged; retry later."}`.
// Nothing was stored: no lab exists, the attempt version and the current item are unchanged, the lab
// lifetime has not started, and the attempt is not consumed; the client retries after Retry-After with
// a new Idempotency-Key. When labs are not enabled on this server, or the provisioner cannot be
// reached, the server answers 503 service_unavailable without Retry-After and stores nothing either.
// The attempt deadline keeps running in both cases.
//
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
// account scenario (403 forbidden), the Idempotency-Key (422, 409 idempotency_in_progress, replay),
// the attempt and the item (404 not_found for an unknown attempt or item, or one of another
// candidate), the state (409 state_conflict: the attempt is terminal or its work session ended, the
// item is not current, its format is not `lab`, or its lab was submitted or expired), the rate limit
// (429), then the availability of labs and the capacity (503). Following the Idempotency-Key
// convention, 201, 200, 404, and 409 state_conflict are stored under the key and replayed; 400, 429,
// and 503 are not.
//
// POST /api/v1/me/assessment-attempts/{attempt_id}/labs
func (UnimplementedHandler) CreateMyAssessmentLab(ctx context.Context, req *AssessmentLabCreate, params CreateMyAssessmentLabParams) (r CreateMyAssessmentLabRes, _ error) {
return r, ht.ErrNotImplemented
}
// CreateMyAssessmentLabConsoleSession implements CreateMyAssessmentLabConsoleSession operation.
//
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
// and an allowed Origin. The body names a node of the lab by its task name.
//
// The response describes one console session: the client opens a WebSocket to `websocket_path` on the
// same origin before `expires_at`. The upgrade is authorized by the session cookie and the Origin
// check, and the server relays the serial console of the node through the lab provisioner. The
// response never carries a node address, a port, a password, a key, or a token; the browser never
// connects to a node or to the provisioner. Console traffic is not stored as an answer and is not
// logged.
//
// The WebSocket relay is planned together with the candidate interface of labs; this contract fixes
// the session shape it uses.
//
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
// account scenario (403 forbidden), the attempt and the lab (404 not_found for an unknown attempt,
// lab, or one of another candidate), the node (400 with the pointer `/node`), the state (409
// state_conflict: the lab is not `ready`, the attempt is terminal, or its work session ended), the
// limit of open sessions per lab (429 rate_limited with Retry-After), then the provisioner (503
// service_unavailable without Retry-After; nothing was opened).
//
// POST /api/v1/me/assessment-attempts/{attempt_id}/labs/{lab_id}/console-sessions
func (UnimplementedHandler) CreateMyAssessmentLabConsoleSession(ctx context.Context, req *AssessmentLabConsoleSessionCreate, params CreateMyAssessmentLabConsoleSessionParams) (r CreateMyAssessmentLabConsoleSessionRes, _ error) {
return r, ht.ErrNotImplemented
}
// CreateMyAssessmentPracticeRun implements CreateMyAssessmentPracticeRun operation.
//
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
@@ -725,6 +792,22 @@ func (UnimplementedHandler) GetMyAssessmentAvailability(ctx context.Context) (r
return r, ht.ErrNotImplemented
}
// GetMyAssessmentLab implements GetMyAssessmentLab operation.
//
// Requires the session cookie of a candidate account. Returns the state of a lab started with
// CreateMyAssessmentLab: whether it is still provisioning, ready for the consoles, being checked after
// the submission, or ended. It never contains a node address, a credential, the seed, the checker
// state, or the result of the check. This GET is read-only; the server may record a due timer
// transition, such as `ready` to `expired`, before it answers.
//
// A lab of another candidate's attempt, a lab of another attempt, and an unknown identifier all answer
// 404 not_found.
//
// GET /api/v1/me/assessment-attempts/{attempt_id}/labs/{lab_id}
func (UnimplementedHandler) GetMyAssessmentLab(ctx context.Context, params GetMyAssessmentLabParams) (r GetMyAssessmentLabRes, _ error) {
return r, ht.ErrNotImplemented
}
// GetMyAssessmentPracticeRun implements GetMyAssessmentPracticeRun operation.
//
// Requires the session cookie of a candidate account. Returns the state of a debug run started with
@@ -2252,6 +2335,10 @@ func (UnimplementedHandler) StartMyAssessmentAttemptSession(ctx context.Context,
// times itself and scores the answer with the key of the fixed item instance. Time never enters the
// ability estimate or the grade decision.
//
// Lab: an item with format `lab` takes no answer here. Its lab is started with CreateMyAssessmentLab
// and submitted with SubmitMyAssessmentLab; any answer to a lab item answers 400 validation_failed
// with the pointer `/answer/format`, like an answer in the wrong format, and stores nothing.
//
// The response is the attempt with the next item to answer. It never says whether the answer was
// correct. Items are answered in order and each answer is final.
//
@@ -2313,6 +2400,40 @@ func (UnimplementedHandler) SubmitMyAssessmentAnswer(ctx context.Context, req *A
return r, ht.ErrNotImplemented
}
// SubmitMyAssessmentLab implements SubmitMyAssessmentLab operation.
//
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
// an allowed Origin, and an Idempotency-Key. The body carries the attempt version last read and the
// answer with format `lab`, which names the lab.
//
// The server closes the consoles, freezes the lab, and answers 202 with the lab `checking`; the
// checker of the task reads the state of the nodes asynchronously, the answer is recorded, and the lab
// becomes `submitted` and is deleted. The client polls GetMyAssessmentLab and then reads the attempt,
// which moves to the next item. Neither response says whether the answer was correct, and the
// candidate never sees the checker criteria or their results.
//
// When the checker cannot reach the nodes because of the lab infrastructure, the lab becomes `failed`
// with `lab_error`: nothing is recorded or consumed, the attempt version is unchanged, and the
// candidate may start a new lab of the item while it is current. A failure of the infrastructure is
// never scored as a wrong answer.
//
// Optimistic concurrency: `expected_version` must equal the current attempt version, otherwise the
// server answers 412 version_conflict and stores nothing.
//
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
// account scenario (403 forbidden), the Idempotency-Key (422, 409 idempotency_in_progress, replay),
// the attempt and the lab (404 not_found for an unknown attempt or lab, or one of another candidate),
// the version (412), the state (409 state_conflict: the lab is not `ready`, `answer.lab_id` is not the
// lab in the path, the item is not current, the attempt is terminal, or its work session ended), then
// the provisioner (503 service_unavailable without Retry-After; nothing was stored and the lab keeps
// running). Following the Idempotency-Key convention, 202, 404, and 409 state_conflict are stored
// under the key and replayed; 400, 412, 429, and 5xx are not.
//
// POST /api/v1/me/assessment-attempts/{attempt_id}/labs/{lab_id}/submission
func (UnimplementedHandler) SubmitMyAssessmentLab(ctx context.Context, req *AssessmentLabSubmission, params SubmitMyAssessmentLabParams) (r SubmitMyAssessmentLabRes, _ error) {
return r, ht.ErrNotImplemented
}
// UnhideOrganization implements UnhideOrganization operation.
//
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
@@ -3016,6 +3016,347 @@ func (s *AssessmentItem) Validate() error {
return nil
}
func (s *AssessmentLab) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if err := s.State.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "state",
Error: err,
})
}
if err := func() error {
if s.Nodes == nil {
return errors.New("nil is invalid value")
}
if err := (validate.Array{
MinLength: 1,
MinLengthSet: true,
MaxLength: 8,
MaxLengthSet: true,
}).ValidateLength(len(s.Nodes)); err != nil {
return errors.Wrap(err, "array")
}
var failures []validate.FieldError
for i, elem := range s.Nodes {
if err := func() error {
if err := elem.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: fmt.Sprintf("[%d]", i),
Error: err,
})
}
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "nodes",
Error: err,
})
}
if err := func() error {
if value, ok := s.FailureReason.Get(); ok {
if err := func() error {
if err := value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "failure_reason",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *AssessmentLabConsoleSession) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if err := s.Node.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "node",
Error: err,
})
}
if err := func() error {
if err := (validate.String{
MinLength: 0,
MinLengthSet: false,
MaxLength: 128,
MaxLengthSet: true,
Email: false,
Hostname: false,
Regex: regexMap["^/api/v1/me/assessment-lab-consoles/[0-9a-f-]{36}$"],
MinNumeric: 0,
MinNumericSet: false,
MaxNumeric: 0,
MaxNumericSet: false,
}).Validate(string(s.WebsocketPath)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "websocket_path",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *AssessmentLabConsoleSessionCreate) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if err := s.Node.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "node",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *AssessmentLabConsoleSessionHeaders) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if err := s.CacheControl.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "CacheControl",
Error: err,
})
}
if err := func() error {
if err := s.Response.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "Response",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s AssessmentLabFailureReason) Validate() error {
switch s {
case "lab_error":
return nil
default:
return errors.Errorf("invalid value: %v", s)
}
}
func (s *AssessmentLabHeaders) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if err := s.CacheControl.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "CacheControl",
Error: err,
})
}
if err := func() error {
if err := s.Response.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "Response",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *AssessmentLabNode) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if err := s.Name.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "name",
Error: err,
})
}
if err := func() error {
if err := s.Kind.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "kind",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s AssessmentLabNodeKind) Validate() error {
switch s {
case "mikrotik":
return nil
case "ubuntu":
return nil
default:
return errors.Errorf("invalid value: %v", s)
}
}
func (s AssessmentLabNodeName) Validate() error {
alias := (string)(s)
if err := (validate.String{
MinLength: 1,
MinLengthSet: true,
MaxLength: 15,
MaxLengthSet: true,
Email: false,
Hostname: false,
Regex: regexMap["^[a-z][a-z0-9-]{0,14}$"],
MinNumeric: 0,
MinNumericSet: false,
MaxNumeric: 0,
MaxNumericSet: false,
}).Validate(string(alias)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}
func (s AssessmentLabState) Validate() error {
switch s {
case "provisioning":
return nil
case "ready":
return nil
case "checking":
return nil
case "submitted":
return nil
case "expired":
return nil
case "failed":
return nil
default:
return errors.Errorf("invalid value: %v", s)
}
}
func (s *AssessmentLabSubmission) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if err := s.ExpectedVersion.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "expected_version",
Error: err,
})
}
if err := func() error {
if err := s.Answer.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "answer",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s AssessmentLimitation) Validate() error {
switch s {
case "uncalibrated_thresholds":
@@ -8873,6 +9214,110 @@ func (s *CreateMyAssessmentAttemptUnprocessableEntity) Validate() error {
return nil
}
func (s *CreateMyAssessmentLabBadRequest) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *CreateMyAssessmentLabConflict) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *CreateMyAssessmentLabConsoleSessionBadRequest) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *CreateMyAssessmentLabConsoleSessionConflict) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *CreateMyAssessmentLabConsoleSessionForbidden) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *CreateMyAssessmentLabConsoleSessionNotFound) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *CreateMyAssessmentLabConsoleSessionUnauthorized) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *CreateMyAssessmentLabCreated) Validate() error {
alias := (*AssessmentLabHeaders)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *CreateMyAssessmentLabForbidden) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *CreateMyAssessmentLabNotFound) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *CreateMyAssessmentLabOK) Validate() error {
alias := (*AssessmentLabHeaders)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *CreateMyAssessmentLabUnauthorized) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *CreateMyAssessmentLabUnprocessableEntity) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *CreateMyAssessmentPracticeRunBadRequest) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
@@ -10120,6 +10565,30 @@ func (s *GetMyAssessmentAvailabilityUnauthorized) Validate() error {
return nil
}
func (s *GetMyAssessmentLabForbidden) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *GetMyAssessmentLabNotFound) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *GetMyAssessmentLabUnauthorized) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *GetMyAssessmentPracticeRunForbidden) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
@@ -11906,11 +12375,137 @@ func (s ItemContent) Validate() error {
return err
}
return nil
case LabItemContentItemContent:
if err := s.LabItemContent.Validate(); err != nil {
return err
}
return nil
default:
return errors.Errorf("invalid type %q", s.Type)
}
}
func (s *LabAnswer) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if err := s.Format.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "format",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s LabAnswerFormat) Validate() error {
switch s {
case "lab":
return nil
default:
return errors.Errorf("invalid value: %v", s)
}
}
func (s *LabItemContent) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if err := s.Format.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "format",
Error: err,
})
}
if err := func() error {
if s.Nodes == nil {
return errors.New("nil is invalid value")
}
if err := (validate.Array{
MinLength: 1,
MinLengthSet: true,
MaxLength: 8,
MaxLengthSet: true,
}).ValidateLength(len(s.Nodes)); err != nil {
return errors.Wrap(err, "array")
}
var failures []validate.FieldError
for i, elem := range s.Nodes {
if err := func() error {
if err := elem.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: fmt.Sprintf("[%d]", i),
Error: err,
})
}
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "nodes",
Error: err,
})
}
if err := func() error {
if err := (validate.Int{
MinSet: true,
Min: 300,
MaxSet: true,
Max: 14400,
MinExclusive: false,
MaxExclusive: false,
MultipleOfSet: false,
MultipleOf: 0,
Pattern: nil,
}).Validate(int64(s.TimeLimitSeconds)); err != nil {
return errors.Wrap(err, "int")
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "time_limit_seconds",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s LabItemContentFormat) Validate() error {
switch s {
case "lab":
return nil
default:
return errors.Errorf("invalid value: %v", s)
}
}
func (s *ListMyAssessmentResultsBadRequest) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
@@ -24811,6 +25406,62 @@ func (s *SubmitMyAssessmentAnswerUnprocessableEntity) Validate() error {
return nil
}
func (s *SubmitMyAssessmentLabBadRequest) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *SubmitMyAssessmentLabConflict) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *SubmitMyAssessmentLabForbidden) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *SubmitMyAssessmentLabNotFound) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *SubmitMyAssessmentLabPreconditionFailed) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *SubmitMyAssessmentLabUnauthorized) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *SubmitMyAssessmentLabUnprocessableEntity) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *SupportCase) Validate() error {
if s == nil {
return validate.ErrNilPointer
@@ -0,0 +1,156 @@
// Code generated by ogen, DO NOT EDIT.
package api
import (
"net/http"
ht "github.com/ogen-go/ogen/http"
"github.com/ogen-go/ogen/ogenregex"
"github.com/ogen-go/ogen/otelogen"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/trace"
)
var regexMap = map[string]ogenregex.Regexp{
"^(/([^~/]|~[01])*)*$": ogenregex.MustCompile("^(/([^~/]|~[01])*)*$"),
"^/v1/labs/[0-9a-f-]{36}/console$": ogenregex.MustCompile("^/v1/labs/[0-9a-f-]{36}/console$"),
"^[0-9a-f]{64}$": ogenregex.MustCompile("^[0-9a-f]{64}$"),
"^[A-Za-z0-9._-]+$": ogenregex.MustCompile("^[A-Za-z0-9._-]+$"),
"^[A-Za-z0-9_-]{43}$": ogenregex.MustCompile("^[A-Za-z0-9_-]{43}$"),
"^[a-z0-9][a-z0-9-]{0,47}$": ogenregex.MustCompile("^[a-z0-9][a-z0-9-]{0,47}$"),
"^[a-z0-9][a-z0-9_-]{0,31}$": ogenregex.MustCompile("^[a-z0-9][a-z0-9_-]{0,31}$"),
"^[a-z][a-z0-9-]{0,14}$": ogenregex.MustCompile("^[a-z][a-z0-9-]{0,14}$"),
"^[a-z][a-z0-9_]*$": ogenregex.MustCompile("^[a-z][a-z0-9_]*$"),
}
var (
// Allocate option closure once.
clientSpanKind = trace.WithSpanKind(trace.SpanKindClient)
)
type (
optionFunc[C any] func(*C)
otelOptionFunc func(*otelConfig)
)
type otelConfig struct {
TracerProvider trace.TracerProvider
Tracer trace.Tracer
MeterProvider metric.MeterProvider
Meter metric.Meter
Attributes []attribute.KeyValue
}
func (cfg *otelConfig) initOTEL() {
if cfg.TracerProvider == nil {
cfg.TracerProvider = otel.GetTracerProvider()
}
if cfg.MeterProvider == nil {
cfg.MeterProvider = otel.GetMeterProvider()
}
cfg.Tracer = cfg.TracerProvider.Tracer(otelogen.Name,
trace.WithInstrumentationVersion(otelogen.SemVersion()),
)
cfg.Meter = cfg.MeterProvider.Meter(otelogen.Name,
metric.WithInstrumentationVersion(otelogen.SemVersion()),
)
}
type clientConfig struct {
otelConfig
Client ht.Client
}
// ClientOption is client config option.
type ClientOption interface {
applyClient(*clientConfig)
}
var _ ClientOption = (optionFunc[clientConfig])(nil)
func (o optionFunc[C]) applyClient(c *C) {
o(c)
}
var _ ClientOption = (otelOptionFunc)(nil)
func (o otelOptionFunc) applyClient(c *clientConfig) {
o(&c.otelConfig)
}
func newClientConfig(opts ...ClientOption) clientConfig {
cfg := clientConfig{
Client: http.DefaultClient,
}
for _, opt := range opts {
opt.applyClient(&cfg)
}
cfg.initOTEL()
return cfg
}
type baseClient struct {
cfg clientConfig
requests metric.Int64Counter
errors metric.Int64Counter
duration metric.Float64Histogram
}
func (cfg clientConfig) baseClient() (c baseClient, err error) {
c = baseClient{cfg: cfg}
if c.requests, err = otelogen.ClientRequestCountCounter(c.cfg.Meter); err != nil {
return c, err
}
if c.errors, err = otelogen.ClientErrorsCountCounter(c.cfg.Meter); err != nil {
return c, err
}
if c.duration, err = otelogen.ClientDurationHistogram(c.cfg.Meter); err != nil {
return c, err
}
return c, nil
}
// Option is config option.
type Option interface {
ClientOption
}
// WithTracerProvider specifies a tracer provider to use for creating a tracer.
//
// If none is specified, the global provider is used.
func WithTracerProvider(provider trace.TracerProvider) Option {
return otelOptionFunc(func(cfg *otelConfig) {
if provider != nil {
cfg.TracerProvider = provider
}
})
}
// WithMeterProvider specifies a meter provider to use for creating a meter.
//
// If none is specified, the otel.GetMeterProvider() is used.
func WithMeterProvider(provider metric.MeterProvider) Option {
return otelOptionFunc(func(cfg *otelConfig) {
if provider != nil {
cfg.MeterProvider = provider
}
})
}
// WithAttributes specifies default otel attributes.
func WithAttributes(attributes ...attribute.KeyValue) Option {
return otelOptionFunc(func(cfg *otelConfig) {
cfg.Attributes = attributes
})
}
// WithClient specifies http client to use.
func WithClient(client ht.Client) ClientOption {
return optionFunc[clientConfig](func(cfg *clientConfig) {
if client != nil {
cfg.Client = client
}
})
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,14 @@
// Code generated by ogen, DO NOT EDIT.
package api
type CreateLabRes interface {
createLabRes()
}
type DeleteLabRes interface {
deleteLabRes()
}
type GetLabdReadyzRes interface {
getLabdReadyzRes()
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,16 @@
// Code generated by ogen, DO NOT EDIT.
package api
// OperationName is the ogen operation name
type OperationName = string
const (
CheckLabOperation OperationName = "CheckLab"
CreateLabOperation OperationName = "CreateLab"
CreateLabConsoleTokenOperation OperationName = "CreateLabConsoleToken"
DeleteLabOperation OperationName = "DeleteLab"
GetLabOperation OperationName = "GetLab"
GetLabdHealthzOperation OperationName = "GetLabdHealthz"
GetLabdReadyzOperation OperationName = "GetLabdReadyz"
)
@@ -0,0 +1,42 @@
// Code generated by ogen, DO NOT EDIT.
package api
import (
"github.com/google/uuid"
)
// 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
}
// 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
}
// 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
}
// 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
}
// 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
}
@@ -0,0 +1,39 @@
// Code generated by ogen, DO NOT EDIT.
package api
import (
"bytes"
"net/http"
"github.com/go-faster/jx"
ht "github.com/ogen-go/ogen/http"
)
func encodeCreateLabRequest(
req *LabCreateRequest,
r *http.Request,
) error {
const contentType = "application/json"
e := new(jx.Encoder)
{
req.Encode(e)
}
encoded := e.Bytes()
ht.SetBody(r, bytes.NewReader(encoded), contentType)
return nil
}
func encodeCreateLabConsoleTokenRequest(
req *ConsoleTokenRequest,
r *http.Request,
) error {
const contentType = "application/json"
e := new(jx.Encoder)
{
req.Encode(e)
}
encoded := e.Bytes()
ht.SetBody(r, bytes.NewReader(encoded), contentType)
return nil
}
@@ -0,0 +1,995 @@
// Code generated by ogen, DO NOT EDIT.
package api
import (
"io"
"mime"
"net/http"
"github.com/go-faster/errors"
"github.com/go-faster/jx"
"github.com/ogen-go/ogen/conv"
"github.com/ogen-go/ogen/ogenerrors"
"github.com/ogen-go/ogen/uri"
"github.com/ogen-go/ogen/validate"
)
func decodeCheckLabResponse(resp *http.Response) (res *LabCheckResult, _ error) {
switch resp.StatusCode {
case 200:
// Code 200.
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
if err != nil {
return res, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/json":
buf, err := io.ReadAll(resp.Body)
if err != nil {
return res, err
}
d := jx.DecodeBytes(buf)
var response LabCheckResult
if err := func() error {
if err := response.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return res, err
}
// Validate response.
if err := func() error {
if err := response.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return res, errors.Wrap(err, "validate")
}
return &response, nil
default:
return res, validate.InvalidContentType(ct)
}
}
// Convenient error response.
defRes, err := func() (res *ProblemStatusCode, err error) {
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
if err != nil {
return res, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/problem+json":
buf, err := io.ReadAll(resp.Body)
if err != nil {
return res, err
}
d := jx.DecodeBytes(buf)
var response Problem
if err := func() error {
if err := response.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return res, err
}
// Validate response.
if err := func() error {
if err := response.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return res, errors.Wrap(err, "validate")
}
return &ProblemStatusCode{
StatusCode: resp.StatusCode,
Response: response,
}, nil
default:
return res, validate.InvalidContentType(ct)
}
}()
if err != nil {
return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode)
}
return res, errors.Wrap(defRes, "error")
}
func decodeCreateLabResponse(resp *http.Response) (res CreateLabRes, _ error) {
switch resp.StatusCode {
case 200:
// Code 200.
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
if err != nil {
return res, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/json":
buf, err := io.ReadAll(resp.Body)
if err != nil {
return res, err
}
d := jx.DecodeBytes(buf)
var response CreateLabOK
if err := func() error {
if err := response.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return res, err
}
// Validate response.
if err := func() error {
if err := response.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return res, errors.Wrap(err, "validate")
}
return &response, nil
default:
return res, validate.InvalidContentType(ct)
}
case 202:
// Code 202.
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
if err != nil {
return res, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/json":
buf, err := io.ReadAll(resp.Body)
if err != nil {
return res, err
}
d := jx.DecodeBytes(buf)
var response CreateLabAccepted
if err := func() error {
if err := response.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return res, err
}
// Validate response.
if err := func() error {
if err := response.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return res, errors.Wrap(err, "validate")
}
return &response, nil
default:
return res, validate.InvalidContentType(ct)
}
case 503:
// Code 503.
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
if err != nil {
return res, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/problem+json":
buf, err := io.ReadAll(resp.Body)
if err != nil {
return res, err
}
d := jx.DecodeBytes(buf)
var response Problem
if err := func() error {
if err := response.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return res, err
}
// Validate response.
if err := func() error {
if err := response.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return res, errors.Wrap(err, "validate")
}
var wrapper LabPoolBusyHeaders
wrapper.Response = response
h := uri.NewHeaderDecoder(resp.Header)
// Parse "Retry-After" header.
{
cfg := uri.HeaderParameterDecodingConfig{
Name: "Retry-After",
Explode: false,
}
if err := func() error {
if err := h.HasParam(cfg); err == nil {
if err := h.DecodeParam(cfg, func(d uri.Decoder) error {
val, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToInt32(val)
if err != nil {
return err
}
wrapper.RetryAfter = c
return nil
}); err != nil {
return err
}
if err := func() error {
if err := (validate.Int{
MinSet: true,
Min: 0,
MaxSet: true,
Max: 3600,
MinExclusive: false,
MaxExclusive: false,
MultipleOfSet: false,
MultipleOf: 0,
Pattern: nil,
}).Validate(int64(wrapper.RetryAfter)); err != nil {
return errors.Wrap(err, "int")
}
return nil
}(); err != nil {
return err
}
} else {
return err
}
return nil
}(); err != nil {
return res, errors.Wrap(err, "parse Retry-After header")
}
}
return &wrapper, nil
default:
return res, validate.InvalidContentType(ct)
}
}
// Convenient error response.
defRes, err := func() (res *ProblemStatusCode, err error) {
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
if err != nil {
return res, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/problem+json":
buf, err := io.ReadAll(resp.Body)
if err != nil {
return res, err
}
d := jx.DecodeBytes(buf)
var response Problem
if err := func() error {
if err := response.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return res, err
}
// Validate response.
if err := func() error {
if err := response.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return res, errors.Wrap(err, "validate")
}
return &ProblemStatusCode{
StatusCode: resp.StatusCode,
Response: response,
}, nil
default:
return res, validate.InvalidContentType(ct)
}
}()
if err != nil {
return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode)
}
return res, errors.Wrap(defRes, "error")
}
func decodeCreateLabConsoleTokenResponse(resp *http.Response) (res *ConsoleTokenHeaders, _ error) {
switch resp.StatusCode {
case 201:
// Code 201.
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
if err != nil {
return res, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/json":
buf, err := io.ReadAll(resp.Body)
if err != nil {
return res, err
}
d := jx.DecodeBytes(buf)
var response ConsoleToken
if err := func() error {
if err := response.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return res, err
}
// Validate response.
if err := func() error {
if err := response.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return res, errors.Wrap(err, "validate")
}
var wrapper ConsoleTokenHeaders
wrapper.Response = response
h := uri.NewHeaderDecoder(resp.Header)
// Parse "Cache-Control" header.
{
cfg := uri.HeaderParameterDecodingConfig{
Name: "Cache-Control",
Explode: false,
}
if err := func() error {
if err := h.HasParam(cfg); err == nil {
if err := h.DecodeParam(cfg, func(d uri.Decoder) error {
val, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToString(val)
if err != nil {
return err
}
wrapper.CacheControl = CreateLabConsoleTokenCreatedCacheControl(c)
return nil
}); err != nil {
return err
}
if err := func() error {
if err := wrapper.CacheControl.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
} else {
return err
}
return nil
}(); err != nil {
return res, errors.Wrap(err, "parse Cache-Control header")
}
}
return &wrapper, nil
default:
return res, validate.InvalidContentType(ct)
}
}
// Convenient error response.
defRes, err := func() (res *ProblemStatusCode, err error) {
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
if err != nil {
return res, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/problem+json":
buf, err := io.ReadAll(resp.Body)
if err != nil {
return res, err
}
d := jx.DecodeBytes(buf)
var response Problem
if err := func() error {
if err := response.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return res, err
}
// Validate response.
if err := func() error {
if err := response.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return res, errors.Wrap(err, "validate")
}
return &ProblemStatusCode{
StatusCode: resp.StatusCode,
Response: response,
}, nil
default:
return res, validate.InvalidContentType(ct)
}
}()
if err != nil {
return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode)
}
return res, errors.Wrap(defRes, "error")
}
func decodeDeleteLabResponse(resp *http.Response) (res DeleteLabRes, _ error) {
switch resp.StatusCode {
case 200:
// Code 200.
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
if err != nil {
return res, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/json":
buf, err := io.ReadAll(resp.Body)
if err != nil {
return res, err
}
d := jx.DecodeBytes(buf)
var response DeleteLabOK
if err := func() error {
if err := response.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return res, err
}
// Validate response.
if err := func() error {
if err := response.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return res, errors.Wrap(err, "validate")
}
return &response, nil
default:
return res, validate.InvalidContentType(ct)
}
case 202:
// Code 202.
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
if err != nil {
return res, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/json":
buf, err := io.ReadAll(resp.Body)
if err != nil {
return res, err
}
d := jx.DecodeBytes(buf)
var response DeleteLabAccepted
if err := func() error {
if err := response.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return res, err
}
// Validate response.
if err := func() error {
if err := response.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return res, errors.Wrap(err, "validate")
}
return &response, nil
default:
return res, validate.InvalidContentType(ct)
}
}
// Convenient error response.
defRes, err := func() (res *ProblemStatusCode, err error) {
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
if err != nil {
return res, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/problem+json":
buf, err := io.ReadAll(resp.Body)
if err != nil {
return res, err
}
d := jx.DecodeBytes(buf)
var response Problem
if err := func() error {
if err := response.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return res, err
}
// Validate response.
if err := func() error {
if err := response.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return res, errors.Wrap(err, "validate")
}
return &ProblemStatusCode{
StatusCode: resp.StatusCode,
Response: response,
}, nil
default:
return res, validate.InvalidContentType(ct)
}
}()
if err != nil {
return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode)
}
return res, errors.Wrap(defRes, "error")
}
func decodeGetLabResponse(resp *http.Response) (res *LabStatus, _ error) {
switch resp.StatusCode {
case 200:
// Code 200.
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
if err != nil {
return res, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/json":
buf, err := io.ReadAll(resp.Body)
if err != nil {
return res, err
}
d := jx.DecodeBytes(buf)
var response LabStatus
if err := func() error {
if err := response.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return res, err
}
// Validate response.
if err := func() error {
if err := response.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return res, errors.Wrap(err, "validate")
}
return &response, nil
default:
return res, validate.InvalidContentType(ct)
}
}
// Convenient error response.
defRes, err := func() (res *ProblemStatusCode, err error) {
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
if err != nil {
return res, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/problem+json":
buf, err := io.ReadAll(resp.Body)
if err != nil {
return res, err
}
d := jx.DecodeBytes(buf)
var response Problem
if err := func() error {
if err := response.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return res, err
}
// Validate response.
if err := func() error {
if err := response.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return res, errors.Wrap(err, "validate")
}
return &ProblemStatusCode{
StatusCode: resp.StatusCode,
Response: response,
}, nil
default:
return res, validate.InvalidContentType(ct)
}
}()
if err != nil {
return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode)
}
return res, errors.Wrap(defRes, "error")
}
func decodeGetLabdHealthzResponse(resp *http.Response) (res *LabdHealthResponse, _ error) {
switch resp.StatusCode {
case 200:
// Code 200.
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
if err != nil {
return res, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/json":
buf, err := io.ReadAll(resp.Body)
if err != nil {
return res, err
}
d := jx.DecodeBytes(buf)
var response LabdHealthResponse
if err := func() error {
if err := response.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return res, err
}
// Validate response.
if err := func() error {
if err := response.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return res, errors.Wrap(err, "validate")
}
return &response, nil
default:
return res, validate.InvalidContentType(ct)
}
}
// Convenient error response.
defRes, err := func() (res *ProblemStatusCode, err error) {
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
if err != nil {
return res, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/problem+json":
buf, err := io.ReadAll(resp.Body)
if err != nil {
return res, err
}
d := jx.DecodeBytes(buf)
var response Problem
if err := func() error {
if err := response.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return res, err
}
// Validate response.
if err := func() error {
if err := response.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return res, errors.Wrap(err, "validate")
}
return &ProblemStatusCode{
StatusCode: resp.StatusCode,
Response: response,
}, nil
default:
return res, validate.InvalidContentType(ct)
}
}()
if err != nil {
return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode)
}
return res, errors.Wrap(defRes, "error")
}
func decodeGetLabdReadyzResponse(resp *http.Response) (res GetLabdReadyzRes, _ error) {
switch resp.StatusCode {
case 200:
// Code 200.
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
if err != nil {
return res, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/json":
buf, err := io.ReadAll(resp.Body)
if err != nil {
return res, err
}
d := jx.DecodeBytes(buf)
var response GetLabdReadyzOK
if err := func() error {
if err := response.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return res, err
}
// Validate response.
if err := func() error {
if err := response.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return res, errors.Wrap(err, "validate")
}
return &response, nil
default:
return res, validate.InvalidContentType(ct)
}
case 503:
// Code 503.
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
if err != nil {
return res, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/json":
buf, err := io.ReadAll(resp.Body)
if err != nil {
return res, err
}
d := jx.DecodeBytes(buf)
var response GetLabdReadyzServiceUnavailable
if err := func() error {
if err := response.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return res, err
}
// Validate response.
if err := func() error {
if err := response.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return res, errors.Wrap(err, "validate")
}
return &response, nil
default:
return res, validate.InvalidContentType(ct)
}
}
// Convenient error response.
defRes, err := func() (res *ProblemStatusCode, err error) {
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
if err != nil {
return res, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/problem+json":
buf, err := io.ReadAll(resp.Body)
if err != nil {
return res, err
}
d := jx.DecodeBytes(buf)
var response Problem
if err := func() error {
if err := response.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return res, err
}
// Validate response.
if err := func() error {
if err := response.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return res, errors.Wrap(err, "validate")
}
return &ProblemStatusCode{
StatusCode: resp.StatusCode,
Response: response,
}, nil
default:
return res, validate.InvalidContentType(ct)
}
}()
if err != nil {
return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode)
}
return res, errors.Wrap(defRes, "error")
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,58 @@
// Code generated by ogen, DO NOT EDIT.
package api
import (
"context"
"net/http"
"github.com/go-faster/errors"
)
// SecuritySource is provider of security values (tokens, passwords, etc.).
type SecuritySource interface {
// BearerAuth provides bearerAuth security value.
// Shared random service token sent as `Authorization: Bearer <token>` over TLS. `labd` compares it in
// constant time and never logs it. Rotation replaces the secret on both sides; there are no per-user
// tokens.
BearerAuth(ctx context.Context, operationName OperationName) (BearerAuth, error)
}
// operationRolesBearerAuth is a private map storing roles per operation.
var operationRolesBearerAuth = map[string][]string{
CheckLabOperation: []string{},
CreateLabOperation: []string{},
CreateLabConsoleTokenOperation: []string{},
DeleteLabOperation: []string{},
GetLabOperation: []string{},
}
// GetRolesForBearerAuth returns the required roles for the given operation.
//
// This is useful for authorization scenarios where you need to know which roles
// are required for an operation.
//
// Example:
//
// requiredRoles := GetRolesForBearerAuth(AddPetOperation)
//
// Returns nil if the operation has no role requirements or if the operation is unknown.
func GetRolesForBearerAuth(operation string) []string {
roles, ok := operationRolesBearerAuth[operation]
if !ok {
return nil
}
// Return a copy to prevent external modification
result := make([]string, len(roles))
copy(result, roles)
return result
}
func (s *Client) securityBearerAuth(ctx context.Context, operationName OperationName, req *http.Request) error {
t, err := s.sec.BearerAuth(ctx, operationName)
if err != nil {
return errors.Wrap(err, "security source \"BearerAuth\"")
}
req.Header.Set("Authorization", "Bearer "+t.Token)
return nil
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,67 @@
// Package disabled provides the lab provisioner for an unset
// LAB_PROVISIONER_URL.
package disabled
import (
"context"
"fmt"
"github.com/google/uuid"
"lincodex/backend/internal/port/outbound"
)
// Provisioner creates nothing. Every valid call is reported as
// outbound.ErrLabProvisionerDisabled, never as a lab, a busy pool, or a check
// result, so a caller cannot start or score a lab while labs are off.
type Provisioner struct{}
var _ outbound.LabProvisioner = (*Provisioner)(nil)
func NewProvisioner() *Provisioner {
return &Provisioner{}
}
// Create validates the request first so that local runs without a
// provisioner still expose invalid task content, then reports the
// provisioner as disabled. It keeps no copy of the seed.
func (provisioner *Provisioner) Create(_ context.Context, request outbound.LabRequest) (outbound.LabStatus, error) {
if err := request.Validate(); err != nil {
return outbound.LabStatus{}, fmt.Errorf("Provisioner.Create - validate request: %w", err)
}
return outbound.LabStatus{}, disabled("Provisioner.Create")
}
// Status reports the provisioner as disabled.
func (provisioner *Provisioner) Status(_ context.Context, key outbound.LabKey) (outbound.LabStatus, error) {
return outbound.LabStatus{}, refuse("Provisioner.Status", key)
}
// Delete reports the provisioner as disabled.
func (provisioner *Provisioner) Delete(_ context.Context, key outbound.LabKey) (outbound.LabStatus, error) {
return outbound.LabStatus{}, refuse("Provisioner.Delete", key)
}
// ConsoleToken reports the provisioner as disabled.
func (provisioner *Provisioner) ConsoleToken(_ context.Context, key outbound.LabKey, node string) (outbound.LabConsoleToken, error) {
if err := outbound.ValidateLabNodeName(node); err != nil {
return outbound.LabConsoleToken{}, fmt.Errorf("Provisioner.ConsoleToken - validate node: %w", err)
}
return outbound.LabConsoleToken{}, refuse("Provisioner.ConsoleToken", key)
}
// Check reports the provisioner as disabled. It is never a failed check.
func (provisioner *Provisioner) Check(_ context.Context, key outbound.LabKey) (outbound.LabCheckResult, error) {
return outbound.LabCheckResult{}, refuse("Provisioner.Check", key)
}
func refuse(location string, key outbound.LabKey) error {
if key.AttemptItemID == uuid.Nil {
return fmt.Errorf("%s - key must name the attempt item: %w", location, outbound.ErrInvalidLabRequest)
}
return disabled(location)
}
func disabled(location string) error {
return fmt.Errorf("%s - LAB_PROVISIONER_URL is not set: %w", location, outbound.ErrLabProvisionerDisabled)
}
@@ -0,0 +1,64 @@
package disabled_test
import (
"context"
"errors"
"testing"
"time"
"github.com/google/uuid"
"lincodex/backend/internal/adapter/secondary/lab_provisioner/disabled"
"lincodex/backend/internal/port/outbound"
)
func TestDisabledProvisionerReportsUnavailableForEveryCall(t *testing.T) {
provisioner := disabled.NewProvisioner()
ctx := context.Background()
key := outbound.LabKey{AttemptItemID: uuid.New()}
request := outbound.LabRequest{
Key: key,
Template: outbound.LabTemplateRef{ID: "ubuntu-dns", Version: 1},
Seed: outbound.LabSeed{1},
Lifetime: 30 * time.Minute,
}
status, err := provisioner.Create(ctx, request)
assertDisabled(t, "Create", err)
if status.State != "" {
t.Fatalf("Create() state = %q, want none", status.State)
}
_, err = provisioner.Status(ctx, key)
assertDisabled(t, "Status", err)
_, err = provisioner.Delete(ctx, key)
assertDisabled(t, "Delete", err)
_, err = provisioner.ConsoleToken(ctx, key, "r1")
assertDisabled(t, "ConsoleToken", err)
result, err := provisioner.Check(ctx, key)
assertDisabled(t, "Check", err)
if result.MaxScore != 0 || len(result.Criteria) != 0 {
t.Fatal("Check() returned a result while disabled")
}
}
func TestDisabledProvisionerStillRejectsInvalidInput(t *testing.T) {
provisioner := disabled.NewProvisioner()
ctx := context.Background()
if _, err := provisioner.Create(ctx, outbound.LabRequest{}); !errors.Is(err, outbound.ErrInvalidLabRequest) {
t.Fatalf("Create() error = %v, want ErrInvalidLabRequest", err)
}
if _, err := provisioner.Status(ctx, outbound.LabKey{}); !errors.Is(err, outbound.ErrInvalidLabRequest) {
t.Fatalf("Status() error = %v, want ErrInvalidLabRequest", err)
}
key := outbound.LabKey{AttemptItemID: uuid.New()}
if _, err := provisioner.ConsoleToken(ctx, key, "Router 1"); !errors.Is(err, outbound.ErrInvalidLabRequest) {
t.Fatalf("ConsoleToken() error = %v, want ErrInvalidLabRequest", err)
}
}
func assertDisabled(t *testing.T, method string, err error) {
t.Helper()
if !errors.Is(err, outbound.ErrLabProvisionerDisabled) || !errors.Is(err, outbound.ErrLabProvisionerUnavailable) {
t.Fatalf("%s() error = %v, want ErrLabProvisionerDisabled", method, err)
}
}
@@ -0,0 +1,374 @@
package outbound
import (
"context"
"encoding/hex"
"errors"
"fmt"
"log/slog"
"regexp"
"time"
"github.com/google/uuid"
)
// Bounds of the lab provisioner contract (api/labd). They are checked before
// a request leaves the process, so a task family that breaks one fails in the
// caller's tests instead of as a provisioner rejection in production.
const (
// MaxLabNodes and MaxLabCriteria also bound a response.
MaxLabNodes = 8
MaxLabCriteria = 50
// MinLabLifetime and MaxLabLifetime bound LabRequest.Lifetime. The
// provisioner may configure a lower maximum.
MinLabLifetime = 5 * time.Minute
MaxLabLifetime = 4 * time.Hour
// LabSeedBytes is the size of a variant seed.
LabSeedBytes = 32
maxLabTemplateVersion = 10000
redactedLabRequest = "[redacted lab request]"
redactedLabSeed = "[redacted lab seed]"
redactedConsoleAccess = "[redacted lab console token]"
redactedLabCheckResult = "[lab check result]"
)
var (
// ErrLabProvisionerUnavailable is the umbrella of every failure that
// leaves a lab operation without an answer although the candidate did
// nothing wrong: the provisioner is disabled, unreachable, too slow,
// refuses the service token, fails with a server error, answers outside
// the contract, or reports that LXD or a node could not be reached. A
// check that ends with it evaluated nothing: the caller must never score
// it as a failed check, and it reports the service as unavailable. Check
// it with errors.Is before the specific errors below.
//
// A busy lab pool is not this error: Create reports it as LabBusy.
ErrLabProvisionerUnavailable = errors.New("lab provisioner unavailable")
// ErrLabProvisionerDisabled means LAB_PROVISIONER_URL is not set, so no
// request was made.
ErrLabProvisionerDisabled = fmt.Errorf("lab provisioner is disabled: %w", ErrLabProvisionerUnavailable)
// ErrLabProvisionerUnauthorized means the provisioner refused the
// service token (401). It points at deployment configuration and needs an
// operator, not a retry.
ErrLabProvisionerUnauthorized = fmt.Errorf("lab provisioner refused the service token: %w", ErrLabProvisionerUnavailable)
// ErrLabProvisionerBadResponse means the provisioner answered, but not as
// the contract says: a malformed body, an unexpected status, or a status
// that contradicts the request or itself.
ErrLabProvisionerBadResponse = fmt.Errorf("lab provisioner answered outside its contract: %w", ErrLabProvisionerUnavailable)
// ErrInvalidLabRequest reports a request that fails LabRequest.Validate,
// or that the provisioner rejected as invalid (400), for example an
// unknown template version. It is a caller or task content bug; nothing
// was created.
ErrInvalidLabRequest = errors.New("invalid lab request")
// ErrLabNotFound means the provisioner does not hold the lab: it was
// never created, or its deleted record outlived the retention time.
ErrLabNotFound = errors.New("lab not found")
// ErrLabKeyReused means the provisioner already holds a lab under this
// key with a different payload (422). The caller bumps LabKey.Generation
// for a new lab.
ErrLabKeyReused = errors.New("lab key reused with another payload")
// ErrLabNotReady means the lab is not ready for a console token or a
// check (409): it is still provisioning, or it is being deleted, deleted,
// or failed. Read its status.
ErrLabNotReady = errors.New("lab is not ready")
)
var (
labTemplateIDPattern = regexp.MustCompile(`^[a-z0-9][a-z0-9-]{0,47}$`)
labNodeNamePattern = regexp.MustCompile(`^[a-z][a-z0-9-]{0,14}$`)
)
// LabKey identifies one lab of an attempt item. The adapter turns it into
// the opaque lab ID that the provisioner stores, so the provisioner never sees
// these values and every retry of the same key reaches the same lab.
type LabKey struct {
// AttemptItemID is the attempt item whose lab this is.
AttemptItemID uuid.UUID
// Generation is 0 for the first lab of the item. After a failed lab the
// caller increments it; the provisioner would return the failed lab for
// the old key.
Generation uint32
}
func (key LabKey) validate() error {
if key.AttemptItemID == uuid.Nil {
return invalidLabRequest("key must name the attempt item")
}
return nil
}
// LabTemplateRef names a template of the provisioner build.
type LabTemplateRef struct {
ID string
Version int32
}
// LabSeed is the variant seed of an item instance. The template renders the
// node configuration and the checker criteria of the variant from it, so it
// is as secret as an answer key: String, GoString, Format, and LogValue
// redact it. Hex returns the wire form.
type LabSeed [LabSeedBytes]byte
func (seed LabSeed) Hex() string { return hex.EncodeToString(seed[:]) }
func (seed LabSeed) String() string { return redactedLabSeed }
func (seed LabSeed) GoString() string { return redactedLabSeed }
// Format redacts every verb; without it %x would print the bytes.
func (seed LabSeed) Format(state fmt.State, _ rune) {
_, _ = state.Write([]byte(redactedLabSeed))
}
func (seed LabSeed) LogValue() slog.Value { return slog.StringValue(redactedLabSeed) }
// LabRequest asks for one lab of a template variant. It carries nothing about
// the candidate: the provisioner receives only a template reference, a seed,
// and a lifetime. The whole request is redacted when printed or logged
// because it holds the seed.
type LabRequest struct {
Key LabKey
Template LabTemplateRef
Seed LabSeed
// Lifetime counts from the creation of the lab. The provisioner deletes
// the lab when it ends, also across its own restarts.
Lifetime time.Duration
}
func (request LabRequest) String() string { return redactedLabRequest }
func (request LabRequest) GoString() string { return redactedLabRequest }
// Format redacts every verb; without it %+v would print the fields.
func (request LabRequest) Format(state fmt.State, _ rune) {
_, _ = state.Write([]byte(redactedLabRequest))
}
func (request LabRequest) LogValue() slog.Value { return slog.StringValue(redactedLabRequest) }
// Validate reports a request that the provisioner would reject by its
// contract. Errors wrap ErrInvalidLabRequest and never include the seed.
func (request LabRequest) Validate() error {
if err := request.Key.validate(); err != nil {
return err
}
switch {
case !labTemplateIDPattern.MatchString(request.Template.ID):
return invalidLabRequest("template ID must match [a-z0-9][a-z0-9-]{0,47}")
case request.Template.Version < 1 || request.Template.Version > maxLabTemplateVersion:
return invalidLabRequest("template version must be 1 to 10000")
case request.Seed == (LabSeed{}):
return invalidLabRequest("seed must not be zero")
case request.Lifetime < MinLabLifetime || request.Lifetime > MaxLabLifetime:
return invalidLabRequest("lifetime must be 5 minutes to 4 hours")
case request.Lifetime%time.Second != 0:
return invalidLabRequest("lifetime must be whole seconds")
}
return nil
}
// ValidateLabNodeName reports a node name that the contract does not allow.
func ValidateLabNodeName(name string) error {
if !labNodeNamePattern.MatchString(name) {
return fmt.Errorf("outbound.ValidateLabNodeName - node name must match [a-z][a-z0-9-]{0,14}: %w", ErrInvalidLabRequest)
}
return nil
}
func invalidLabRequest(reason string) error {
return fmt.Errorf("LabRequest.Validate - %s: %w", reason, ErrInvalidLabRequest)
}
// LabState is what a provisioner call established about a lab. The zero
// value is not a state and must never be read as readiness.
type LabState string
const (
// LabProvisioning means capacity is reserved and the nodes are being
// prepared. Poll Status later.
LabProvisioning LabState = "provisioning"
// LabReady means every node answers; console tokens and checks work.
LabReady LabState = "ready"
// LabDeleting means the lab ended and its resources are being removed.
LabDeleting LabState = "deleting"
// LabDeleted means every resource of the lab is gone.
LabDeleted LabState = "deleted"
// LabFailed means the provisioning failed for an infrastructure reason;
// FailureReason says which. It never depends on the candidate. Its
// resources are removed; the caller starts a new lab with the next
// LabKey.Generation.
LabFailed LabState = "failed"
// LabBusy means the lab does not fit the capacity of the provisioner, or
// the provisioner is draining. Nothing was stored and nothing of the
// attempt is consumed; create again with the same key after RetryAfter.
// Only Create reports it, and it is a capacity signal, never an
// infrastructure failure.
LabBusy LabState = "busy"
)
// LabFailureReason says why a lab failed.
type LabFailureReason string
const (
LabFailureProvisioning LabFailureReason = "provisioning_failed"
LabFailureTimedOut LabFailureReason = "provisioning_timed_out"
LabFailureInterrupted LabFailureReason = "interrupted"
)
// LabNodeKind is the guest system of a node.
type LabNodeKind string
const (
LabNodeMikroTik LabNodeKind = "mikrotik"
LabNodeUbuntu LabNodeKind = "ubuntu"
)
// LabNode is a node of a lab by its template name. It never carries an
// address or a credential: the backend reaches a node only through a console
// token, and the provisioner checks it itself.
type LabNode struct {
Name string
Kind LabNodeKind
}
// LabStatus is the state of a lab after one provisioner call.
type LabStatus struct {
State LabState
// LabID is the opaque ID the provisioner holds the lab under. It
// identifies no user, attempt, or task; it is safe to log and matches the
// provisioner's logs.
LabID string
// RetryAfter is the provisioner's wait hint for LabBusy only.
RetryAfter time.Duration
// The fields below are set for every state except LabBusy. ReadyAt,
// DeletedAt, and FailureReason are zero until they apply.
Template LabTemplateRef
CreatedAt time.Time
ReadyAt time.Time
ExpiresAt time.Time
DeletedAt time.Time
FailureReason LabFailureReason
Nodes []LabNode
}
// Active reports whether the lab holds or is about to hold resources that a
// candidate can use.
func (status LabStatus) Active() bool {
return status.State == LabProvisioning || status.State == LabReady
}
// LabConsoleToken lets the console gateway attach to the serial console of
// one node once. The token is a secret of the gateway: String, GoString,
// Format, and LogValue redact it, and it must never reach a browser or a log.
type LabConsoleToken struct {
Token string
Node string
ExpiresAt time.Time
AttachPath string
}
func (token LabConsoleToken) String() string { return redactedConsoleAccess }
func (token LabConsoleToken) GoString() string { return redactedConsoleAccess }
// Format redacts every verb; without it %+v would print the token.
func (token LabConsoleToken) Format(state fmt.State, _ rune) {
_, _ = state.Write([]byte(redactedConsoleAccess))
}
func (token LabConsoleToken) LogValue() slog.Value { return slog.StringValue(redactedConsoleAccess) }
// LabCriterionResult says whether one criterion of the variant holds.
type LabCriterionResult struct {
ID string
Passed bool
}
// LabCheckResult is a validated check of a ready lab. It is checker state for
// scoring only and must never reach the candidate.
type LabCheckResult struct {
CheckedAt time.Time
Score int
MaxScore int
Criteria []LabCriterionResult
}
// Validate reports a result that contradicts itself, so a malformed answer
// of the provisioner can never become a score.
func (result LabCheckResult) Validate() error {
if len(result.Criteria) < 1 || len(result.Criteria) > MaxLabCriteria {
return errors.New("LabCheckResult.Validate - criteria must have 1 to 50 entries")
}
passed := 0
seen := make(map[string]struct{}, len(result.Criteria))
for _, criterion := range result.Criteria {
if _, duplicate := seen[criterion.ID]; duplicate || criterion.ID == "" {
return errors.New("LabCheckResult.Validate - criterion IDs must be unique and not empty")
}
seen[criterion.ID] = struct{}{}
if criterion.Passed {
passed++
}
}
if result.MaxScore != len(result.Criteria) || result.Score != passed {
return errors.New("LabCheckResult.Validate - score must count the passed criteria")
}
if result.CheckedAt.IsZero() {
return errors.New("LabCheckResult.Validate - check time must be set")
}
return nil
}
// LogValue summarizes the result without criterion IDs, which describe the
// variant.
func (result LabCheckResult) LogValue() slog.Value {
return slog.GroupValue(slog.Int("score", result.Score), slog.Int("max_score", result.MaxScore))
}
func (result LabCheckResult) String() string { return redactedLabCheckResult }
// LabProvisioner creates, inspects, checks, and deletes practical labs
// through the lab provisioner service (api/labd). Only that service talks to
// LXD; the backend never holds the LXD socket or a node address.
//
// Every method makes exactly one provisioner call and never retries or
// sleeps; polling and backoff belong to the caller. Create is idempotent by
// request.Key: the same key with the same payload returns the current state
// of one lab and never creates a second one.
//
// A nil error from Create comes with provisioning, ready, deleting, deleted,
// failed, or busy. Busy holds RetryAfter, stores nothing, and is the only
// capacity outcome; it is never an error. An error means that nothing
// happened that the caller may rely on:
// - ErrInvalidLabRequest: the request is invalid or unknown to the
// provisioner; nothing was created.
// - ErrLabProvisionerUnavailable (including the disabled, unauthorized,
// and bad-response forms): no answer could be obtained. For Check it is
// never a failed check and never a reason to fail the candidate.
// - ErrLabNotFound: the provisioner does not hold the lab.
// - ErrLabKeyReused (Create): the key was used with another payload.
// - ErrLabNotReady (ConsoleToken, Check): the lab is not ready.
// - the context error when ctx ended.
//
// The returned values are zero when err is not nil. Errors and logs never
// include the seed, a console token, or the service token.
type LabProvisioner interface {
Create(ctx context.Context, request LabRequest) (LabStatus, error)
Status(ctx context.Context, key LabKey) (LabStatus, error)
Delete(ctx context.Context, key LabKey) (LabStatus, error)
ConsoleToken(ctx context.Context, key LabKey, node string) (LabConsoleToken, error)
Check(ctx context.Context, key LabKey) (LabCheckResult, error)
}
@@ -0,0 +1,172 @@
package outbound_test
import (
"errors"
"fmt"
"log/slog"
"strings"
"testing"
"time"
"github.com/google/uuid"
"lincodex/backend/internal/port/outbound"
)
func validLabRequest() outbound.LabRequest {
var seed outbound.LabSeed
for index := range seed {
seed[index] = byte(0xa0 + index%16)
}
return outbound.LabRequest{
Key: outbound.LabKey{AttemptItemID: uuid.New()},
Template: outbound.LabTemplateRef{ID: "mikrotik-ospf-pair", Version: 1},
Seed: seed,
Lifetime: 45 * time.Minute,
}
}
func TestLabRequestValidateAcceptsAContractRequest(t *testing.T) {
if err := validLabRequest().Validate(); err != nil {
t.Fatalf("Validate() error = %v", err)
}
}
func TestLabRequestValidateRejectsWhatTheProvisionerRejects(t *testing.T) {
tests := []struct {
name string
change func(*outbound.LabRequest)
}{
{"no attempt item", func(r *outbound.LabRequest) { r.Key.AttemptItemID = uuid.Nil }},
{"empty template", func(r *outbound.LabRequest) { r.Template.ID = "" }},
{"template with capitals", func(r *outbound.LabRequest) { r.Template.ID = "MikroTik" }},
{"template too long", func(r *outbound.LabRequest) { r.Template.ID = strings.Repeat("a", 49) }},
{"template version zero", func(r *outbound.LabRequest) { r.Template.Version = 0 }},
{"template version above range", func(r *outbound.LabRequest) { r.Template.Version = 10001 }},
{"zero seed", func(r *outbound.LabRequest) { r.Seed = outbound.LabSeed{} }},
{"lifetime below range", func(r *outbound.LabRequest) { r.Lifetime = 4 * time.Minute }},
{"lifetime above range", func(r *outbound.LabRequest) { r.Lifetime = 4*time.Hour + time.Second }},
{"lifetime with a fraction of a second", func(r *outbound.LabRequest) { r.Lifetime = 10*time.Minute + time.Millisecond }},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
request := validLabRequest()
test.change(&request)
err := request.Validate()
if !errors.Is(err, outbound.ErrInvalidLabRequest) {
t.Fatalf("Validate() error = %v, want ErrInvalidLabRequest", err)
}
})
}
}
func TestLabRequestAndSeedNeverPrintTheSeed(t *testing.T) {
request := validLabRequest()
seedHex := request.Seed.Hex()
if len(seedHex) != 2*outbound.LabSeedBytes {
t.Fatalf("Hex() length = %d", len(seedHex))
}
var logged strings.Builder
logger := slog.New(slog.NewJSONHandler(&logged, nil))
logger.Info("lab", slog.Any("request", request), slog.Any("seed", request.Seed))
printed := []string{
fmt.Sprint(request), fmt.Sprintf("%+v", request), fmt.Sprintf("%#v", request),
fmt.Sprintf("%x", request.Seed), fmt.Sprintf("%v", request.Seed), logged.String(),
}
for _, text := range printed {
if strings.Contains(text, seedHex) || strings.Contains(text, "mikrotik-ospf-pair") {
t.Fatalf("printed form leaks the request: %q", text)
}
}
}
func TestLabConsoleTokenIsRedacted(t *testing.T) {
token := outbound.LabConsoleToken{Token: "console-token-marker", Node: "r1", AttachPath: "/v1/labs/x/console"}
var logged strings.Builder
slog.New(slog.NewJSONHandler(&logged, nil)).Info("token", slog.Any("token", token))
for _, text := range []string{fmt.Sprint(token), fmt.Sprintf("%+v", token), fmt.Sprintf("%#v", token), logged.String()} {
if strings.Contains(text, "console-token-marker") {
t.Fatalf("printed form leaks the token: %q", text)
}
}
}
func TestBusyIsACapacityStateAndNotAnInfrastructureError(t *testing.T) {
busy := outbound.LabStatus{State: outbound.LabBusy, RetryAfter: 30 * time.Second}
if busy.Active() {
t.Fatal("a busy answer holds no lab")
}
for _, err := range []error{
outbound.ErrLabProvisionerDisabled,
outbound.ErrLabProvisionerUnauthorized,
outbound.ErrLabProvisionerBadResponse,
} {
if !errors.Is(err, outbound.ErrLabProvisionerUnavailable) {
t.Fatalf("%v must be an unavailable provisioner", err)
}
}
for _, err := range []error{
outbound.ErrInvalidLabRequest, outbound.ErrLabNotFound,
outbound.ErrLabKeyReused, outbound.ErrLabNotReady,
} {
if errors.Is(err, outbound.ErrLabProvisionerUnavailable) {
t.Fatalf("%v must not be an unavailable provisioner", err)
}
}
}
func TestLabStatusActive(t *testing.T) {
for state, active := range map[outbound.LabState]bool{
outbound.LabProvisioning: true, outbound.LabReady: true,
outbound.LabDeleting: false, outbound.LabDeleted: false, outbound.LabFailed: false, outbound.LabBusy: false,
} {
if got := (outbound.LabStatus{State: state}).Active(); got != active {
t.Fatalf("Active() for %s = %v, want %v", state, got, active)
}
}
}
func TestValidateLabNodeName(t *testing.T) {
if err := outbound.ValidateLabNodeName("r1"); err != nil {
t.Fatalf("ValidateLabNodeName(r1) error = %v", err)
}
for _, name := range []string{"", "R1", "1r", "r_1", strings.Repeat("a", 16)} {
if err := outbound.ValidateLabNodeName(name); !errors.Is(err, outbound.ErrInvalidLabRequest) {
t.Fatalf("ValidateLabNodeName(%q) error = %v", name, err)
}
}
}
func TestLabCheckResultValidate(t *testing.T) {
valid := outbound.LabCheckResult{
CheckedAt: time.Date(2026, 10, 11, 9, 0, 0, 0, time.UTC),
Score: 1, MaxScore: 2,
Criteria: []outbound.LabCriterionResult{{ID: "ospf", Passed: true}, {ID: "ping", Passed: false}},
}
if err := valid.Validate(); err != nil {
t.Fatalf("Validate() error = %v", err)
}
tests := []struct {
name string
change func(*outbound.LabCheckResult)
}{
{"no criteria", func(r *outbound.LabCheckResult) { r.Criteria, r.Score, r.MaxScore = nil, 0, 0 }},
{"score above passed", func(r *outbound.LabCheckResult) { r.Score = 2 }},
{"max score not the count", func(r *outbound.LabCheckResult) { r.MaxScore = 3 }},
{"duplicate criterion", func(r *outbound.LabCheckResult) { r.Criteria[1].ID = "ospf" }},
{"no check time", func(r *outbound.LabCheckResult) { r.CheckedAt = time.Time{} }},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
result := valid
result.Criteria = append([]outbound.LabCriterionResult(nil), valid.Criteria...)
test.change(&result)
if err := result.Validate(); err == nil {
t.Fatal("Validate() accepted a contradictory result")
}
})
}
if text := fmt.Sprint(valid); strings.Contains(text, "ospf") {
t.Fatalf("printed result leaks a criterion: %q", text)
}
}