feat(practice): store code submissions and practice states apart from attempts

This commit is contained in:
shira committed 2026-10-11 14:58:04 +03:00
1 parent d5e169e71b
commit 51770eea6c
61 files changed
+8584 -135

No files matched your search

@@ -1482,6 +1482,270 @@ func (s *Server) handleCreateMyAssessmentAttemptRequest(args [0]string, argsEsca
}
}
// handleCreateMyAssessmentPracticeRunRequest handles CreateMyAssessmentPracticeRun 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 practice item of the attempt and
// carries the language, the source, and up to ten tests of the candidate.
//
// A debug run executes the solution in the isolated sandbox against the public examples of the task
// and the tests of the candidate only. It never runs, lists, or scores a hidden check, and it changes
// neither the practice state, the verdict, nor the attempt version; the graded solution is submitted
// with SubmitMyAssessmentAnswer. The run is stored with its own identifier and executed
// asynchronously: the response is 202 with the run `queued`, and the client polls
// GetMyAssessmentPracticeRun. The source is never echoed.
//
// The practice must be the current item: the attempt is in `practice_pending` for the main practice or
// `additional_practice_pending` for the additional one, and its deadline has not passed. Otherwise the
// server answers 409 state_conflict.
//
// Availability. When code practice is not enabled on this server, the server answers 503
// service_unavailable and stores nothing.
//
// Repeats. A retry with the same Idempotency-Key and body within 24 hours returns the stored run in
// its current state with 202, without starting another run. A different body with the same key answers
// 422 idempotency_key_reused. Refusals (400, 404, 409, 503) are not stored under the key and are
// evaluated again.
//
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
// account scenario (403 forbidden), the availability of code practice (503), the Idempotency-Key (422,
// replay), the attempt and the practice (404 not_found for an unknown attempt or item, or one of
// another candidate), the state (409), then the solution against the item (400 with a pointer such as
// `/language` or `/source_code`).
//
// POST /api/v1/me/assessment-attempts/{attempt_id}/practice-runs
func (s *Server) handleCreateMyAssessmentPracticeRunRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
statusWriter := &codeRecorder{ResponseWriter: w}
w = statusWriter
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("CreateMyAssessmentPracticeRun"),
semconv.HTTPRequestMethodKey.String("POST"),
semconv.HTTPRouteKey.String("/api/v1/me/assessment-attempts/{attempt_id}/practice-runs"),
}
// Add attributes from config.
otelAttrs = append(otelAttrs, s.cfg.Attributes...)
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), CreateMyAssessmentPracticeRunOperation,
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Add Labeler to context.
labeler := &Labeler{attrs: otelAttrs}
ctx = contextWithLabeler(ctx, labeler)
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
attrSet := labeler.AttributeSet()
attrs := attrSet.ToSlice()
code := statusWriter.status
if code != 0 {
codeAttr := semconv.HTTPResponseStatusCode(code)
attrs = append(attrs, codeAttr)
span.SetAttributes(attrs...)
}
attrOpt := metric.WithAttributes(attrs...)
// Increment request counter.
s.requests.Add(ctx, 1, attrOpt)
// Use floating point division here for higher precision (instead of Millisecond method).
s.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), attrOpt)
}()
var (
recordError = func(stage string, err error) {
span.RecordError(err)
// https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status
// Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges,
// unless there was another error (e.g., network error receiving the response body; or 3xx codes with
// max redirects exceeded), in which case status MUST be set to Error.
code := statusWriter.status
if code < 100 || code >= 500 {
span.SetStatus(codes.Error, stage)
}
attrSet := labeler.AttributeSet()
attrs := attrSet.ToSlice()
if code != 0 {
attrs = append(attrs, semconv.HTTPResponseStatusCode(code))
}
s.errors.Add(ctx, 1, metric.WithAttributes(attrs...))
}
err error
opErrContext = ogenerrors.OperationContext{
Name: CreateMyAssessmentPracticeRunOperation,
ID: "CreateMyAssessmentPracticeRun",
}
)
{
type bitset = [1]uint8
var satisfied bitset
{
sctx, ok, err := s.securitySessionCookie(ctx, CreateMyAssessmentPracticeRunOperation, r)
if err != nil {
err = &ogenerrors.SecurityError{
OperationContext: opErrContext,
Security: "SessionCookie",
Err: err,
}
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
defer recordError("Security:SessionCookie", err)
}
return
}
if ok {
satisfied[0] |= 1 << 0
ctx = sctx
}
}
{
sctx, ok, err := s.securitySessionCsrf(ctx, CreateMyAssessmentPracticeRunOperation, r)
if err != nil {
err = &ogenerrors.SecurityError{
OperationContext: opErrContext,
Security: "SessionCsrf",
Err: err,
}
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
defer recordError("Security:SessionCsrf", err)
}
return
}
if ok {
satisfied[0] |= 1 << 1
ctx = sctx
}
}
if ok := func() bool {
nextRequirement:
for _, requirement := range []bitset{
{0b00000011},
} {
for i, mask := range requirement {
if satisfied[i]&mask != mask {
continue nextRequirement
}
}
return true
}
return false
}(); !ok {
err = &ogenerrors.SecurityError{
OperationContext: opErrContext,
Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied,
}
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
defer recordError("Security", err)
}
return
}
}
params, err := decodeCreateMyAssessmentPracticeRunParams(args, argsEscaped, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
defer recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
var rawBody []byte
request, rawBody, close, err := s.decodeCreateMyAssessmentPracticeRunRequest(r)
if err != nil {
err = &ogenerrors.DecodeRequestError{
OperationContext: opErrContext,
Err: err,
}
defer recordError("DecodeRequest", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
defer func() {
if err := close(); err != nil {
recordError("CloseRequest", err)
}
}()
var response CreateMyAssessmentPracticeRunRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: CreateMyAssessmentPracticeRunOperation,
OperationSummary: "Start a debug run of a practice solution.",
OperationID: "CreateMyAssessmentPracticeRun",
Body: request,
RawBody: rawBody,
Params: middleware.Parameters{
{
Name: "attempt_id",
In: "path",
}: params.AttemptID,
{
Name: "Idempotency-Key",
In: "header",
}: params.IdempotencyKey,
},
Raw: r,
}
type (
Request = *PracticeRunCreate
Params = CreateMyAssessmentPracticeRunParams
Response = CreateMyAssessmentPracticeRunRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackCreateMyAssessmentPracticeRunParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.CreateMyAssessmentPracticeRun(ctx, request, params)
return response, err
},
)
} else {
response, err = s.h.CreateMyAssessmentPracticeRun(ctx, request, params)
}
if err != nil {
if errRes, ok := errors.Into[*ProblemStatusCode](err); ok {
if err := encodeErrorResponse(errRes, w, span); err != nil {
defer recordError("Internal", err)
}
return
}
if errors.Is(err, ht.ErrNotImplemented) {
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeErrorResponse(s.h.NewError(ctx, err), w, span); err != nil {
defer recordError("Internal", err)
}
return
}
if err := encodeCreateMyAssessmentPracticeRunResponse(response, w, span); err != nil {
defer recordError("EncodeResponse", err)
if !errors.Is(err, ht.ErrInternalServerErrorResponse) {
s.cfg.ErrorHandler(ctx, w, r, err)
}
return
}
}
// handleCreateMySupportCaseRequest handles CreateMySupportCase operation.
//
// Requires the session cookie, the CSRF token of that session in X-CSRF-Token, an allowed Origin, and
@@ -4265,6 +4529,217 @@ func (s *Server) handleGetMyAssessmentAvailabilityRequest(args [0]string, argsEs
}
}
// handleGetMyAssessmentPracticeRunRequest handles GetMyAssessmentPracticeRun operation.
//
// Requires the session cookie of a candidate account. Returns the state of a debug run started with
// CreateMyAssessmentPracticeRun and, once it is `finished`, the outcome of the public examples and of
// the tests of the candidate. It never contains a hidden check, its outcome, the score, or the source.
// This GET is read-only.
//
// A run of another candidate's attempt, a run of another attempt, and an unknown identifier all answer
// 404 not_found. The graded solution submitted with SubmitMyAssessmentAnswer is not a debug run and is
// not readable here.
//
// GET /api/v1/me/assessment-attempts/{attempt_id}/practice-runs/{run_id}
func (s *Server) handleGetMyAssessmentPracticeRunRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
statusWriter := &codeRecorder{ResponseWriter: w}
w = statusWriter
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("GetMyAssessmentPracticeRun"),
semconv.HTTPRequestMethodKey.String("GET"),
semconv.HTTPRouteKey.String("/api/v1/me/assessment-attempts/{attempt_id}/practice-runs/{run_id}"),
}
// Add attributes from config.
otelAttrs = append(otelAttrs, s.cfg.Attributes...)
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), GetMyAssessmentPracticeRunOperation,
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Add Labeler to context.
labeler := &Labeler{attrs: otelAttrs}
ctx = contextWithLabeler(ctx, labeler)
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
attrSet := labeler.AttributeSet()
attrs := attrSet.ToSlice()
code := statusWriter.status
if code != 0 {
codeAttr := semconv.HTTPResponseStatusCode(code)
attrs = append(attrs, codeAttr)
span.SetAttributes(attrs...)
}
attrOpt := metric.WithAttributes(attrs...)
// Increment request counter.
s.requests.Add(ctx, 1, attrOpt)
// Use floating point division here for higher precision (instead of Millisecond method).
s.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), attrOpt)
}()
var (
recordError = func(stage string, err error) {
span.RecordError(err)
// https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status
// Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges,
// unless there was another error (e.g., network error receiving the response body; or 3xx codes with
// max redirects exceeded), in which case status MUST be set to Error.
code := statusWriter.status
if code < 100 || code >= 500 {
span.SetStatus(codes.Error, stage)
}
attrSet := labeler.AttributeSet()
attrs := attrSet.ToSlice()
if code != 0 {
attrs = append(attrs, semconv.HTTPResponseStatusCode(code))
}
s.errors.Add(ctx, 1, metric.WithAttributes(attrs...))
}
err error
opErrContext = ogenerrors.OperationContext{
Name: GetMyAssessmentPracticeRunOperation,
ID: "GetMyAssessmentPracticeRun",
}
)
{
type bitset = [1]uint8
var satisfied bitset
{
sctx, ok, err := s.securitySessionCookie(ctx, GetMyAssessmentPracticeRunOperation, r)
if err != nil {
err = &ogenerrors.SecurityError{
OperationContext: opErrContext,
Security: "SessionCookie",
Err: err,
}
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
defer recordError("Security:SessionCookie", err)
}
return
}
if ok {
satisfied[0] |= 1 << 0
ctx = sctx
}
}
if ok := func() bool {
nextRequirement:
for _, requirement := range []bitset{
{0b00000001},
} {
for i, mask := range requirement {
if satisfied[i]&mask != mask {
continue nextRequirement
}
}
return true
}
return false
}(); !ok {
err = &ogenerrors.SecurityError{
OperationContext: opErrContext,
Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied,
}
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
defer recordError("Security", err)
}
return
}
}
params, err := decodeGetMyAssessmentPracticeRunParams(args, argsEscaped, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
defer recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
var rawBody []byte
var response GetMyAssessmentPracticeRunRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: GetMyAssessmentPracticeRunOperation,
OperationSummary: "Read a debug run of a practice solution.",
OperationID: "GetMyAssessmentPracticeRun",
Body: nil,
RawBody: rawBody,
Params: middleware.Parameters{
{
Name: "attempt_id",
In: "path",
}: params.AttemptID,
{
Name: "run_id",
In: "path",
}: params.RunID,
},
Raw: r,
}
type (
Request = struct{}
Params = GetMyAssessmentPracticeRunParams
Response = GetMyAssessmentPracticeRunRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackGetMyAssessmentPracticeRunParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.GetMyAssessmentPracticeRun(ctx, params)
return response, err
},
)
} else {
response, err = s.h.GetMyAssessmentPracticeRun(ctx, params)
}
if err != nil {
if errRes, ok := errors.Into[*ProblemStatusCode](err); ok {
if err := encodeErrorResponse(errRes, w, span); err != nil {
defer recordError("Internal", err)
}
return
}
if errors.Is(err, ht.ErrNotImplemented) {
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeErrorResponse(s.h.NewError(ctx, err), w, span); err != nil {
defer recordError("Internal", err)
}
return
}
if err := encodeGetMyAssessmentPracticeRunResponse(response, w, span); err != nil {
defer recordError("EncodeResponse", err)
if !errors.Is(err, ht.ErrInternalServerErrorResponse) {
s.cfg.ErrorHandler(ctx, w, r, err)
}
return
}
}
// handleGetMyAssessmentResultRequest handles GetMyAssessmentResult operation.
//
// Requires the session cookie of a candidate account. Returns the immutable result of a terminal
@@ -25,6 +25,10 @@ type CreateMyAssessmentAttemptRes interface {
createMyAssessmentAttemptRes()
}
type CreateMyAssessmentPracticeRunRes interface {
createMyAssessmentPracticeRunRes()
}
type CreateMySupportCaseRes interface {
createMySupportCaseRes()
}
@@ -69,6 +73,10 @@ type GetMyAssessmentAvailabilityRes interface {
getMyAssessmentAvailabilityRes()
}
type GetMyAssessmentPracticeRunRes interface {
getMyAssessmentPracticeRunRes()
}
type GetMyAssessmentResultRes interface {
getMyAssessmentResultRes()
}
File diff suppressed because it is too large. Load diff
@@ -12,6 +12,7 @@ const (
ConfirmEmailOperation OperationName = "ConfirmEmail"
ConfirmEmailByCodeOperation OperationName = "ConfirmEmailByCode"
CreateMyAssessmentAttemptOperation OperationName = "CreateMyAssessmentAttempt"
CreateMyAssessmentPracticeRunOperation OperationName = "CreateMyAssessmentPracticeRun"
CreateMySupportCaseOperation OperationName = "CreateMySupportCase"
CreateOrganizationOperation OperationName = "CreateOrganization"
CreateOrganizationInvitationOperation OperationName = "CreateOrganizationInvitation"
@@ -24,6 +25,7 @@ const (
GetHealthzOperation OperationName = "GetHealthz"
GetMyAssessmentAttemptOperation OperationName = "GetMyAssessmentAttempt"
GetMyAssessmentAvailabilityOperation OperationName = "GetMyAssessmentAvailability"
GetMyAssessmentPracticeRunOperation OperationName = "GetMyAssessmentPracticeRun"
GetMyAssessmentResultOperation OperationName = "GetMyAssessmentResult"
GetMyAssessmentSignalNoticeOperation OperationName = "GetMyAssessmentSignalNotice"
GetMyCardPreviewOperation OperationName = "GetMyCardPreview"
@@ -593,6 +593,155 @@ func decodeCreateMyAssessmentAttemptParams(args [0]string, argsEscaped bool, r *
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
// 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 unpackCreateMyAssessmentPracticeRunParams(packed middleware.Parameters) (params CreateMyAssessmentPracticeRunParams) {
{
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 decodeCreateMyAssessmentPracticeRunParams(args [1]string, argsEscaped bool, r *http.Request) (params CreateMyAssessmentPracticeRunParams, _ 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
}
// CreateMySupportCaseParams is parameters of CreateMySupportCase operation.
type CreateMySupportCaseParams struct {
// Client-generated key that makes a retried mutating command safe; a UUID v4 is recommended. The value
@@ -1523,6 +1672,127 @@ func decodeGetMyAssessmentAttemptParams(args [1]string, argsEscaped bool, r *htt
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
// unknown identifier both answer 404 not_found, so identifiers cannot be enumerated.
AttemptID uuid.UUID
// Identifier of a debug run of this attempt.
RunID uuid.UUID
}
func unpackGetMyAssessmentPracticeRunParams(packed middleware.Parameters) (params GetMyAssessmentPracticeRunParams) {
{
key := middleware.ParameterKey{
Name: "attempt_id",
In: "path",
}
params.AttemptID = packed[key].(uuid.UUID)
}
{
key := middleware.ParameterKey{
Name: "run_id",
In: "path",
}
params.RunID = packed[key].(uuid.UUID)
}
return params
}
func decodeGetMyAssessmentPracticeRunParams(args [2]string, argsEscaped bool, r *http.Request) (params GetMyAssessmentPracticeRunParams, _ 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: run_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: "run_id",
Value: param,
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
val, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToUUID(val)
if err != nil {
return err
}
params.RunID = c
return nil
}(); err != nil {
return err
}
} else {
return validate.ErrFieldRequired
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "run_id",
In: "path",
Err: err,
}
}
return params, nil
}
// GetMyAssessmentResultParams is parameters of GetMyAssessmentResult operation.
type GetMyAssessmentResultParams struct {
// Identifier of an assessment attempt of the current candidate. An attempt of another candidate and an
@@ -488,6 +488,85 @@ func (s *Server) decodeCreateMyAssessmentAttemptRequest(r *http.Request) (
}
}
func (s *Server) decodeCreateMyAssessmentPracticeRunRequest(r *http.Request) (
req *PracticeRunCreate,
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 PracticeRunCreate
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) decodeCreateMySupportCaseRequest(r *http.Request) (
req SupportCaseCreate,
rawBody []byte,
@@ -676,6 +676,146 @@ func encodeCreateMyAssessmentAttemptResponse(response CreateMyAssessmentAttemptR
}
}
func encodeCreateMyAssessmentPracticeRunResponse(response CreateMyAssessmentPracticeRunRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *PracticeRunHeaders:
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 *CreateMyAssessmentPracticeRunBadRequest:
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 *CreateMyAssessmentPracticeRunUnauthorized:
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 *CreateMyAssessmentPracticeRunForbidden:
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 *CreateMyAssessmentPracticeRunNotFound:
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 *CreateMyAssessmentPracticeRunConflict:
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 *CreateMyAssessmentPracticeRunUnprocessableEntity:
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 *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 encodeCreateMySupportCaseResponse(response CreateMySupportCaseRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *SupportCaseHeaders:
@@ -1758,6 +1898,77 @@ func encodeGetMyAssessmentAvailabilityResponse(response GetMyAssessmentAvailabil
}
}
func encodeGetMyAssessmentPracticeRunResponse(response GetMyAssessmentPracticeRunRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *PracticeRunHeaders:
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 *GetMyAssessmentPracticeRunUnauthorized:
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 *GetMyAssessmentPracticeRunForbidden:
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 *GetMyAssessmentPracticeRunNotFound:
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 encodeGetMyAssessmentResultResponse(response GetMyAssessmentResultRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *AssessmentResultHeaders:
@@ -11,7 +11,7 @@ import (
)
var (
rn86AllowedHeaders = map[string]string{
rn89AllowedHeaders = map[string]string{
"POST": "Content-Type",
}
rn9AllowedHeaders = map[string]string{
@@ -20,44 +20,47 @@ var (
rn10AllowedHeaders = map[string]string{
"POST": "Content-Type,Origin",
}
rn81AllowedHeaders = map[string]string{
rn84AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key",
}
rn71AllowedHeaders = map[string]string{
rn74AllowedHeaders = map[string]string{
"POST": "Content-Type",
}
rn28AllowedHeaders = map[string]string{
rn30AllowedHeaders = map[string]string{
"DELETE": "X-Csrf-Token",
}
rn83AllowedHeaders = map[string]string{
rn86AllowedHeaders = map[string]string{
"POST": "X-Csrf-Token",
}
rn12AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn97AllowedHeaders = map[string]string{
rn100AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Attempt-Client,X-Csrf-Token",
}
rn23AllowedHeaders = map[string]string{
rn25AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn96AllowedHeaders = map[string]string{
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",
}
rn80AllowedHeaders = map[string]string{
rn83AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn58AllowedHeaders = map[string]string{
rn61AllowedHeaders = 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",
}
rn88AllowedHeaders = map[string]string{
rn91AllowedHeaders = map[string]string{
"DELETE": "X-Csrf-Token",
}
rn54AllowedHeaders = map[string]string{
rn57AllowedHeaders = map[string]string{
"DELETE": "X-Csrf-Token",
"PUT": "Content-Type,X-Csrf-Token",
}
@@ -67,68 +70,68 @@ var (
rn7AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn20AllowedHeaders = map[string]string{
rn23AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn98AllowedHeaders = map[string]string{
rn101AllowedHeaders = map[string]string{
"POST": "X-Csrf-Token",
}
rn74AllowedHeaders = map[string]string{
rn77AllowedHeaders = map[string]string{
"POST": "X-Csrf-Token",
}
rn57AllowedHeaders = map[string]string{
rn60AllowedHeaders = map[string]string{
"DELETE": "X-Csrf-Token",
"PUT": "X-Csrf-Token",
}
rn93AllowedHeaders = map[string]string{
rn96AllowedHeaders = map[string]string{
"PUT": "Content-Type,X-Csrf-Token",
}
rn94AllowedHeaders = map[string]string{
rn97AllowedHeaders = map[string]string{
"PUT": "Content-Type,X-Csrf-Token",
}
rn39AllowedHeaders = map[string]string{
rn42AllowedHeaders = map[string]string{
"PUT": "Content-Type,X-Csrf-Token",
}
rn84AllowedHeaders = map[string]string{
rn87AllowedHeaders = map[string]string{
"POST": "X-Csrf-Token",
}
rn40AllowedHeaders = map[string]string{
rn43AllowedHeaders = map[string]string{
"PUT": "Content-Type,X-Csrf-Token",
}
rn13AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn14AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn16AllowedHeaders = map[string]string{
"PATCH": "Content-Type,X-Csrf-Token",
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn17AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn47AllowedHeaders = map[string]string{
rn19AllowedHeaders = map[string]string{
"PATCH": "Content-Type,X-Csrf-Token",
}
rn79AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn91AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn99AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn89AllowedHeaders = map[string]string{
"POST": "Content-Type,X-Csrf-Token",
}
rn19AllowedHeaders = map[string]string{
rn20AllowedHeaders = map[string]string{
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
}
rn50AllowedHeaders = map[string]string{
"PATCH": "Content-Type,X-Csrf-Token",
}
rn77AllowedHeaders = map[string]string{
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{
"PATCH": "Content-Type,X-Csrf-Token",
}
rn80AllowedHeaders = map[string]string{
"POST": "X-Csrf-Token",
}
)
@@ -285,7 +288,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn86AllowedHeaders,
allowedHeaders: rn89AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -388,7 +391,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn81AllowedHeaders,
allowedHeaders: rn84AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -412,7 +415,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn71AllowedHeaders,
allowedHeaders: rn74AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -439,7 +442,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "DELETE,GET",
allowedHeaders: rn28AllowedHeaders,
allowedHeaders: rn30AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -492,7 +495,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn83AllowedHeaders,
allowedHeaders: rn86AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -614,7 +617,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn97AllowedHeaders,
allowedHeaders: rn100AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -641,7 +644,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn23AllowedHeaders,
allowedHeaders: rn25AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -650,6 +653,71 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
case 'p': // Prefix: "practice-runs"
if l := len("practice-runs"); len(elem) >= l && elem[0:l] == "practice-runs" {
elem = elem[l:]
} else {
break
}
if len(elem) == 0 {
switch r.Method {
case "POST":
s.handleCreateMyAssessmentPracticeRunRequest([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: "run_id"
// Leaf parameter, slashes are prohibited
idx := strings.IndexByte(elem, '/')
if idx >= 0 {
break
}
args[1] = elem
elem = ""
if len(elem) == 0 {
// Leaf node.
switch r.Method {
case "GET":
s.handleGetMyAssessmentPracticeRunRequest([2]string{
args[0],
args[1],
}, elemIsEscaped, w, r)
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "GET",
allowedHeaders: nil,
acceptPost: "",
acceptPatch: "",
})
}
return
}
}
case 'r': // Prefix: "result"
if l := len("result"); len(elem) >= l && elem[0:l] == "result" {
@@ -707,7 +775,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn96AllowedHeaders,
allowedHeaders: rn99AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -734,7 +802,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn80AllowedHeaders,
allowedHeaders: rn83AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -767,7 +835,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "DELETE,PUT",
allowedHeaders: rn58AllowedHeaders,
allowedHeaders: rn61AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -976,7 +1044,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "DELETE",
allowedHeaders: rn88AllowedHeaders,
allowedHeaders: rn91AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -1010,7 +1078,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "DELETE,PUT",
allowedHeaders: rn54AllowedHeaders,
allowedHeaders: rn57AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -1191,7 +1259,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn20AllowedHeaders,
allowedHeaders: rn23AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -1218,7 +1286,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn98AllowedHeaders,
allowedHeaders: rn101AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -1296,7 +1364,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn74AllowedHeaders,
allowedHeaders: rn77AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -1474,7 +1542,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "DELETE,PUT",
allowedHeaders: rn57AllowedHeaders,
allowedHeaders: rn60AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -1565,7 +1633,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "PUT",
allowedHeaders: rn93AllowedHeaders,
allowedHeaders: rn96AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -1592,7 +1660,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "PUT",
allowedHeaders: rn94AllowedHeaders,
allowedHeaders: rn97AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -1622,7 +1690,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "GET,PUT",
allowedHeaders: rn39AllowedHeaders,
allowedHeaders: rn42AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -1647,7 +1715,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn84AllowedHeaders,
allowedHeaders: rn87AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -1678,7 +1746,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "GET,PUT",
allowedHeaders: rn40AllowedHeaders,
allowedHeaders: rn43AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -1704,7 +1772,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "GET,POST",
allowedHeaders: rn13AllowedHeaders,
allowedHeaders: rn16AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -1768,7 +1836,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn14AllowedHeaders,
allowedHeaders: rn17AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -1807,7 +1875,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "GET,PATCH",
allowedHeaders: rn16AllowedHeaders,
allowedHeaders: rn19AllowedHeaders,
acceptPost: "",
acceptPatch: "application/json",
})
@@ -1915,7 +1983,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "GET,POST",
allowedHeaders: rn17AllowedHeaders,
allowedHeaders: rn20AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -1956,7 +2024,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "GET,PATCH",
allowedHeaders: rn47AllowedHeaders,
allowedHeaders: rn50AllowedHeaders,
acceptPost: "",
acceptPatch: "application/json",
})
@@ -2036,7 +2104,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn79AllowedHeaders,
allowedHeaders: rn82AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -2064,7 +2132,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn91AllowedHeaders,
allowedHeaders: rn94AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -2094,7 +2162,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn99AllowedHeaders,
allowedHeaders: rn102AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -2127,7 +2195,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn89AllowedHeaders,
allowedHeaders: rn92AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -2169,7 +2237,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "GET,POST",
allowedHeaders: rn19AllowedHeaders,
allowedHeaders: rn22AllowedHeaders,
acceptPost: "application/json",
acceptPatch: "",
})
@@ -2211,7 +2279,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "GET,PATCH",
allowedHeaders: rn50AllowedHeaders,
allowedHeaders: rn53AllowedHeaders,
acceptPost: "",
acceptPatch: "application/json",
})
@@ -2288,7 +2356,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
default:
s.notAllowed(w, r, notAllowedParams{
allowedMethods: "POST",
allowedHeaders: rn77AllowedHeaders,
allowedHeaders: rn80AllowedHeaders,
acceptPost: "",
acceptPatch: "",
})
@@ -2899,6 +2967,66 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
}
}
case 'p': // Prefix: "practice-runs"
if l := len("practice-runs"); len(elem) >= l && elem[0:l] == "practice-runs" {
elem = elem[l:]
} else {
break
}
if len(elem) == 0 {
switch method {
case "POST":
r.name = CreateMyAssessmentPracticeRunOperation
r.summary = "Start a debug run of a practice solution."
r.operationID = "CreateMyAssessmentPracticeRun"
r.operationGroup = ""
r.pathPattern = "/api/v1/me/assessment-attempts/{attempt_id}/practice-runs"
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: "run_id"
// Leaf parameter, slashes are prohibited
idx := strings.IndexByte(elem, '/')
if idx >= 0 {
break
}
args[1] = elem
elem = ""
if len(elem) == 0 {
// Leaf node.
switch method {
case "GET":
r.name = GetMyAssessmentPracticeRunOperation
r.summary = "Read a debug run of a practice solution."
r.operationID = "GetMyAssessmentPracticeRun"
r.operationGroup = ""
r.pathPattern = "/api/v1/me/assessment-attempts/{attempt_id}/practice-runs/{run_id}"
r.args = args
r.count = 2
return r, true
default:
return
}
}
}
case 'r': // Prefix: "result"
if l := len("result"); len(elem) >= l && elem[0:l] == "result" {
@@ -9746,6 +9746,30 @@ type CreateMyAssessmentAttemptUnprocessableEntity Problem
func (*CreateMyAssessmentAttemptUnprocessableEntity) createMyAssessmentAttemptRes() {}
type CreateMyAssessmentPracticeRunBadRequest Problem
func (*CreateMyAssessmentPracticeRunBadRequest) createMyAssessmentPracticeRunRes() {}
type CreateMyAssessmentPracticeRunConflict Problem
func (*CreateMyAssessmentPracticeRunConflict) createMyAssessmentPracticeRunRes() {}
type CreateMyAssessmentPracticeRunForbidden Problem
func (*CreateMyAssessmentPracticeRunForbidden) createMyAssessmentPracticeRunRes() {}
type CreateMyAssessmentPracticeRunNotFound Problem
func (*CreateMyAssessmentPracticeRunNotFound) createMyAssessmentPracticeRunRes() {}
type CreateMyAssessmentPracticeRunUnauthorized Problem
func (*CreateMyAssessmentPracticeRunUnauthorized) createMyAssessmentPracticeRunRes() {}
type CreateMyAssessmentPracticeRunUnprocessableEntity Problem
func (*CreateMyAssessmentPracticeRunUnprocessableEntity) createMyAssessmentPracticeRunRes() {}
type CreateMySupportCaseBadRequest Problem
func (*CreateMySupportCaseBadRequest) createMySupportCaseRes() {}
@@ -10991,6 +11015,18 @@ type GetMyAssessmentAvailabilityUnauthorized Problem
func (*GetMyAssessmentAvailabilityUnauthorized) getMyAssessmentAvailabilityRes() {}
type GetMyAssessmentPracticeRunForbidden Problem
func (*GetMyAssessmentPracticeRunForbidden) getMyAssessmentPracticeRunRes() {}
type GetMyAssessmentPracticeRunNotFound Problem
func (*GetMyAssessmentPracticeRunNotFound) getMyAssessmentPracticeRunRes() {}
type GetMyAssessmentPracticeRunUnauthorized Problem
func (*GetMyAssessmentPracticeRunUnauthorized) getMyAssessmentPracticeRunRes() {}
type GetMyAssessmentResultConflict Problem
func (*GetMyAssessmentResultConflict) getMyAssessmentResultRes() {}
@@ -19952,6 +19988,51 @@ func (o NilPracticeFailureReason) Or(d PracticeFailureReason) PracticeFailureRea
return d
}
// NewNilPracticeRunResult returns new NilPracticeRunResult with value set to v.
func NewNilPracticeRunResult(v PracticeRunResult) NilPracticeRunResult {
return NilPracticeRunResult{
Value: v,
}
}
// NilPracticeRunResult is nullable PracticeRunResult.
type NilPracticeRunResult struct {
Value PracticeRunResult
Null bool
}
// SetTo sets value to v.
func (o *NilPracticeRunResult) SetTo(v PracticeRunResult) {
o.Null = false
o.Value = v
}
// IsNull returns true if value is Null.
func (o NilPracticeRunResult) IsNull() bool { return o.Null }
// SetToNull sets value to null.
func (o *NilPracticeRunResult) SetToNull() {
o.Null = true
var v PracticeRunResult
o.Value = v
}
// Get returns value and boolean that denotes whether value was set.
func (o NilPracticeRunResult) Get() (v PracticeRunResult, 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 NilPracticeRunResult) Or(d PracticeRunResult) PracticeRunResult {
if v, ok := o.Get(); ok {
return v
}
return d
}
// NewNilPracticeVerdict returns new NilPracticeVerdict with value set to v.
func NewNilPracticeVerdict(v PracticeVerdict) NilPracticeVerdict {
return NilPracticeVerdict{
@@ -25883,6 +25964,505 @@ func (s *PracticeKind) UnmarshalText(data []byte) error {
}
}
// Debug run of a practice solution. It shows only the public examples and the tests of the candidate;
// hidden checks are never run, listed, or scored by a debug run.
// Ref: #/components/schemas/PracticeRun
type PracticeRun struct {
// Identifier of the run.
ID uuid.UUID `json:"id"`
ItemID AssessmentItemId `json:"item_id"`
State PracticeRunState `json:"state"`
CreatedAt Timestamp `json:"created_at"`
// Time the run reached `finished` or `failed`, or null.
FinishedAt NilTimestamp `json:"finished_at"`
// `sandbox_error` when `state` is `failed`, otherwise null.
FailureReason NilPracticeFailureReason `json:"failure_reason"`
// The result when `state` is `finished`, otherwise null.
Result NilPracticeRunResult `json:"result"`
}
// GetID returns the value of ID.
func (s *PracticeRun) GetID() uuid.UUID {
return s.ID
}
// GetItemID returns the value of ItemID.
func (s *PracticeRun) GetItemID() AssessmentItemId {
return s.ItemID
}
// GetState returns the value of State.
func (s *PracticeRun) GetState() PracticeRunState {
return s.State
}
// GetCreatedAt returns the value of CreatedAt.
func (s *PracticeRun) GetCreatedAt() Timestamp {
return s.CreatedAt
}
// GetFinishedAt returns the value of FinishedAt.
func (s *PracticeRun) GetFinishedAt() NilTimestamp {
return s.FinishedAt
}
// GetFailureReason returns the value of FailureReason.
func (s *PracticeRun) GetFailureReason() NilPracticeFailureReason {
return s.FailureReason
}
// GetResult returns the value of Result.
func (s *PracticeRun) GetResult() NilPracticeRunResult {
return s.Result
}
// SetID sets the value of ID.
func (s *PracticeRun) SetID(val uuid.UUID) {
s.ID = val
}
// SetItemID sets the value of ItemID.
func (s *PracticeRun) SetItemID(val AssessmentItemId) {
s.ItemID = val
}
// SetState sets the value of State.
func (s *PracticeRun) SetState(val PracticeRunState) {
s.State = val
}
// SetCreatedAt sets the value of CreatedAt.
func (s *PracticeRun) SetCreatedAt(val Timestamp) {
s.CreatedAt = val
}
// SetFinishedAt sets the value of FinishedAt.
func (s *PracticeRun) SetFinishedAt(val NilTimestamp) {
s.FinishedAt = val
}
// SetFailureReason sets the value of FailureReason.
func (s *PracticeRun) SetFailureReason(val NilPracticeFailureReason) {
s.FailureReason = val
}
// SetResult sets the value of Result.
func (s *PracticeRun) SetResult(val NilPracticeRunResult) {
s.Result = val
}
// Debug run of a practice solution against the public examples of the task and up to ten tests of the
// candidate. It never runs a hidden check and never changes the practice state, the verdict, or the
// attempt version. Unknown fields are rejected.
// Ref: #/components/schemas/PracticeRunCreate
type PracticeRunCreate struct {
ItemID AssessmentItemId `json:"item_id"`
// One of the `languages` of the practice item, or null when the item offers none.
Language NilTaskLanguage `json:"language"`
SourceCode string `json:"source_code"`
// Tests of the candidate, run after the public examples.
Tests []PracticeRunTest `json:"tests"`
}
// GetItemID returns the value of ItemID.
func (s *PracticeRunCreate) GetItemID() AssessmentItemId {
return s.ItemID
}
// GetLanguage returns the value of Language.
func (s *PracticeRunCreate) GetLanguage() NilTaskLanguage {
return s.Language
}
// GetSourceCode returns the value of SourceCode.
func (s *PracticeRunCreate) GetSourceCode() string {
return s.SourceCode
}
// GetTests returns the value of Tests.
func (s *PracticeRunCreate) GetTests() []PracticeRunTest {
return s.Tests
}
// SetItemID sets the value of ItemID.
func (s *PracticeRunCreate) SetItemID(val AssessmentItemId) {
s.ItemID = val
}
// SetLanguage sets the value of Language.
func (s *PracticeRunCreate) SetLanguage(val NilTaskLanguage) {
s.Language = val
}
// SetSourceCode sets the value of SourceCode.
func (s *PracticeRunCreate) SetSourceCode(val string) {
s.SourceCode = val
}
// SetTests sets the value of Tests.
func (s *PracticeRunCreate) SetTests(val []PracticeRunTest) {
s.Tests = val
}
// PracticeRunHeaders wraps PracticeRun with response headers.
type PracticeRunHeaders struct {
CacheControl CacheControlNoStore
Response PracticeRun
}
// GetCacheControl returns the value of CacheControl.
func (s *PracticeRunHeaders) GetCacheControl() CacheControlNoStore {
return s.CacheControl
}
// GetResponse returns the value of Response.
func (s *PracticeRunHeaders) GetResponse() PracticeRun {
return s.Response
}
// SetCacheControl sets the value of CacheControl.
func (s *PracticeRunHeaders) SetCacheControl(val CacheControlNoStore) {
s.CacheControl = val
}
// SetResponse sets the value of Response.
func (s *PracticeRunHeaders) SetResponse(val PracticeRun) {
s.Response = val
}
func (*PracticeRunHeaders) createMyAssessmentPracticeRunRes() {}
func (*PracticeRunHeaders) getMyAssessmentPracticeRunRes() {}
// Outcome of a run or one of its tests. Every outcome caused by the solution, such as a compilation
// error, a crash, or a limit, is a finished run with this outcome; an infrastructure failure is a
// failed run instead.
// Ref: #/components/schemas/PracticeRunOutcome
type PracticeRunOutcome string
const (
PracticeRunOutcomeAccepted PracticeRunOutcome = "accepted"
PracticeRunOutcomeWrongAnswer PracticeRunOutcome = "wrong_answer"
PracticeRunOutcomeCompileError PracticeRunOutcome = "compile_error"
PracticeRunOutcomeTimeLimitExceeded PracticeRunOutcome = "time_limit_exceeded"
PracticeRunOutcomeMemoryLimitExceeded PracticeRunOutcome = "memory_limit_exceeded"
PracticeRunOutcomeOutputLimitExceeded PracticeRunOutcome = "output_limit_exceeded"
PracticeRunOutcomeRuntimeError PracticeRunOutcome = "runtime_error"
)
// AllValues returns all PracticeRunOutcome values.
func (PracticeRunOutcome) AllValues() []PracticeRunOutcome {
return []PracticeRunOutcome{
PracticeRunOutcomeAccepted,
PracticeRunOutcomeWrongAnswer,
PracticeRunOutcomeCompileError,
PracticeRunOutcomeTimeLimitExceeded,
PracticeRunOutcomeMemoryLimitExceeded,
PracticeRunOutcomeOutputLimitExceeded,
PracticeRunOutcomeRuntimeError,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s PracticeRunOutcome) MarshalText() ([]byte, error) {
switch s {
case PracticeRunOutcomeAccepted:
return []byte(s), nil
case PracticeRunOutcomeWrongAnswer:
return []byte(s), nil
case PracticeRunOutcomeCompileError:
return []byte(s), nil
case PracticeRunOutcomeTimeLimitExceeded:
return []byte(s), nil
case PracticeRunOutcomeMemoryLimitExceeded:
return []byte(s), nil
case PracticeRunOutcomeOutputLimitExceeded:
return []byte(s), nil
case PracticeRunOutcomeRuntimeError:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *PracticeRunOutcome) UnmarshalText(data []byte) error {
switch PracticeRunOutcome(data) {
case PracticeRunOutcomeAccepted:
*s = PracticeRunOutcomeAccepted
return nil
case PracticeRunOutcomeWrongAnswer:
*s = PracticeRunOutcomeWrongAnswer
return nil
case PracticeRunOutcomeCompileError:
*s = PracticeRunOutcomeCompileError
return nil
case PracticeRunOutcomeTimeLimitExceeded:
*s = PracticeRunOutcomeTimeLimitExceeded
return nil
case PracticeRunOutcomeMemoryLimitExceeded:
*s = PracticeRunOutcomeMemoryLimitExceeded
return nil
case PracticeRunOutcomeOutputLimitExceeded:
*s = PracticeRunOutcomeOutputLimitExceeded
return nil
case PracticeRunOutcomeRuntimeError:
*s = PracticeRunOutcomeRuntimeError
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
// Result of a debug run on the public examples and the tests of the candidate. It never contains a
// hidden check, its outcome, or the score.
// Ref: #/components/schemas/PracticeRunResult
type PracticeRunResult struct {
Outcome PracticeRunOutcome `json:"outcome"`
// The compiler message when `outcome` is `compile_error`, otherwise null.
CompileDiagnostic NilString `json:"compile_diagnostic"`
Tests []PracticeRunTestResult `json:"tests"`
}
// GetOutcome returns the value of Outcome.
func (s *PracticeRunResult) GetOutcome() PracticeRunOutcome {
return s.Outcome
}
// GetCompileDiagnostic returns the value of CompileDiagnostic.
func (s *PracticeRunResult) GetCompileDiagnostic() NilString {
return s.CompileDiagnostic
}
// GetTests returns the value of Tests.
func (s *PracticeRunResult) GetTests() []PracticeRunTestResult {
return s.Tests
}
// SetOutcome sets the value of Outcome.
func (s *PracticeRunResult) SetOutcome(val PracticeRunOutcome) {
s.Outcome = val
}
// SetCompileDiagnostic sets the value of CompileDiagnostic.
func (s *PracticeRunResult) SetCompileDiagnostic(val NilString) {
s.CompileDiagnostic = val
}
// SetTests sets the value of Tests.
func (s *PracticeRunResult) SetTests(val []PracticeRunTestResult) {
s.Tests = val
}
// State of a debug run.
//
// - queued: the run waits in the sandbox queue.
// - running: the sandbox runs it.
// - finished: `result` holds the outcome of the public examples and the tests of the candidate.
// - failed: the sandbox infrastructure could not run it, independently of the solution;
// `failure_reason` is `sandbox_error`. Start a new run.
//
// Adding a value is a contract change.
// Ref: #/components/schemas/PracticeRunState
type PracticeRunState string
const (
PracticeRunStateQueued PracticeRunState = "queued"
PracticeRunStateRunning PracticeRunState = "running"
PracticeRunStateFinished PracticeRunState = "finished"
PracticeRunStateFailed PracticeRunState = "failed"
)
// AllValues returns all PracticeRunState values.
func (PracticeRunState) AllValues() []PracticeRunState {
return []PracticeRunState{
PracticeRunStateQueued,
PracticeRunStateRunning,
PracticeRunStateFinished,
PracticeRunStateFailed,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s PracticeRunState) MarshalText() ([]byte, error) {
switch s {
case PracticeRunStateQueued:
return []byte(s), nil
case PracticeRunStateRunning:
return []byte(s), nil
case PracticeRunStateFinished:
return []byte(s), nil
case PracticeRunStateFailed:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *PracticeRunState) UnmarshalText(data []byte) error {
switch PracticeRunState(data) {
case PracticeRunStateQueued:
*s = PracticeRunStateQueued
return nil
case PracticeRunStateRunning:
*s = PracticeRunStateRunning
return nil
case PracticeRunStateFinished:
*s = PracticeRunStateFinished
return nil
case PracticeRunStateFailed:
*s = PracticeRunStateFailed
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
// One test of the candidate for a debug run: an input and the output the candidate expects. It is
// compared with the checker of the task.
// Ref: #/components/schemas/PracticeRunTest
type PracticeRunTest struct {
Input string `json:"input"`
ExpectedOutput string `json:"expected_output"`
}
// GetInput returns the value of Input.
func (s *PracticeRunTest) GetInput() string {
return s.Input
}
// GetExpectedOutput returns the value of ExpectedOutput.
func (s *PracticeRunTest) GetExpectedOutput() string {
return s.ExpectedOutput
}
// SetInput sets the value of Input.
func (s *PracticeRunTest) SetInput(val string) {
s.Input = val
}
// SetExpectedOutput sets the value of ExpectedOutput.
func (s *PracticeRunTest) SetExpectedOutput(val string) {
s.ExpectedOutput = val
}
// Outcome of one evaluated test. The tests of a source stop at the first failed one, so later tests of
// that source are not listed.
// Ref: #/components/schemas/PracticeRunTestResult
type PracticeRunTestResult struct {
Source PracticeRunTestSource `json:"source"`
// Position of the test in its source, from 1.
Index int32 `json:"index"`
Outcome PracticeRunOutcome `json:"outcome"`
TimeMs int64 `json:"time_ms"`
MemoryKB int64 `json:"memory_kb"`
// Truncated error output of a failed test, or null.
Diagnostic NilString `json:"diagnostic"`
}
// GetSource returns the value of Source.
func (s *PracticeRunTestResult) GetSource() PracticeRunTestSource {
return s.Source
}
// GetIndex returns the value of Index.
func (s *PracticeRunTestResult) GetIndex() int32 {
return s.Index
}
// GetOutcome returns the value of Outcome.
func (s *PracticeRunTestResult) GetOutcome() PracticeRunOutcome {
return s.Outcome
}
// GetTimeMs returns the value of TimeMs.
func (s *PracticeRunTestResult) GetTimeMs() int64 {
return s.TimeMs
}
// GetMemoryKB returns the value of MemoryKB.
func (s *PracticeRunTestResult) GetMemoryKB() int64 {
return s.MemoryKB
}
// GetDiagnostic returns the value of Diagnostic.
func (s *PracticeRunTestResult) GetDiagnostic() NilString {
return s.Diagnostic
}
// SetSource sets the value of Source.
func (s *PracticeRunTestResult) SetSource(val PracticeRunTestSource) {
s.Source = val
}
// SetIndex sets the value of Index.
func (s *PracticeRunTestResult) SetIndex(val int32) {
s.Index = val
}
// SetOutcome sets the value of Outcome.
func (s *PracticeRunTestResult) SetOutcome(val PracticeRunOutcome) {
s.Outcome = val
}
// SetTimeMs sets the value of TimeMs.
func (s *PracticeRunTestResult) SetTimeMs(val int64) {
s.TimeMs = val
}
// SetMemoryKB sets the value of MemoryKB.
func (s *PracticeRunTestResult) SetMemoryKB(val int64) {
s.MemoryKB = val
}
// SetDiagnostic sets the value of Diagnostic.
func (s *PracticeRunTestResult) SetDiagnostic(val NilString) {
s.Diagnostic = val
}
// Where a test of a debug run comes from: a public example of the task or a test of the candidate.
// Ref: #/components/schemas/PracticeRunTestSource
type PracticeRunTestSource string
const (
PracticeRunTestSourceExample PracticeRunTestSource = "example"
PracticeRunTestSourceCandidate PracticeRunTestSource = "candidate"
)
// AllValues returns all PracticeRunTestSource values.
func (PracticeRunTestSource) AllValues() []PracticeRunTestSource {
return []PracticeRunTestSource{
PracticeRunTestSourceExample,
PracticeRunTestSourceCandidate,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s PracticeRunTestSource) MarshalText() ([]byte, error) {
switch s {
case PracticeRunTestSourceExample:
return []byte(s), nil
case PracticeRunTestSourceCandidate:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *PracticeRunTestSource) UnmarshalText(data []byte) error {
switch PracticeRunTestSource(data) {
case PracticeRunTestSourceExample:
*s = PracticeRunTestSourceExample
return nil
case PracticeRunTestSourceCandidate:
*s = PracticeRunTestSourceCandidate
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
// State of a practice.
//
// - not_started: no solution was submitted yet.
@@ -29631,6 +30211,34 @@ type SendOrganizationInvitationUnprocessableEntity Problem
func (*SendOrganizationInvitationUnprocessableEntity) sendOrganizationInvitationRes() {}
// ServiceUnavailableHeaders wraps Problem with response headers.
type ServiceUnavailableHeaders struct {
RetryAfter OptInt32
Response Problem
}
// GetRetryAfter returns the value of RetryAfter.
func (s *ServiceUnavailableHeaders) GetRetryAfter() OptInt32 {
return s.RetryAfter
}
// GetResponse returns the value of Response.
func (s *ServiceUnavailableHeaders) GetResponse() Problem {
return s.Response
}
// SetRetryAfter sets the value of RetryAfter.
func (s *ServiceUnavailableHeaders) SetRetryAfter(val OptInt32) {
s.RetryAfter = val
}
// SetResponse sets the value of Response.
func (s *ServiceUnavailableHeaders) SetResponse(val Problem) {
s.Response = val
}
func (*ServiceUnavailableHeaders) createMyAssessmentPracticeRunRes() {}
// 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.
// Ref: #/components/schemas/Session
@@ -60,6 +60,7 @@ var operationRolesSessionCookie = map[string][]string{
AcknowledgeMyAssessmentSignalNoticeOperation: []string{},
CancelMyInvitationOperation: []string{},
CreateMyAssessmentAttemptOperation: []string{},
CreateMyAssessmentPracticeRunOperation: []string{},
CreateMySupportCaseOperation: []string{},
CreateOrganizationOperation: []string{},
CreateOrganizationInvitationOperation: []string{},
@@ -70,6 +71,7 @@ var operationRolesSessionCookie = map[string][]string{
GetCurrentSessionOperation: []string{},
GetMyAssessmentAttemptOperation: []string{},
GetMyAssessmentAvailabilityOperation: []string{},
GetMyAssessmentPracticeRunOperation: []string{},
GetMyAssessmentResultOperation: []string{},
GetMyAssessmentSignalNoticeOperation: []string{},
GetMyCardPreviewOperation: []string{},
@@ -154,6 +156,7 @@ var operationRolesSessionCsrf = map[string][]string{
AcknowledgeMyAssessmentSignalNoticeOperation: []string{},
CancelMyInvitationOperation: []string{},
CreateMyAssessmentAttemptOperation: []string{},
CreateMyAssessmentPracticeRunOperation: []string{},
CreateMySupportCaseOperation: []string{},
CreateOrganizationOperation: []string{},
CreateOrganizationInvitationOperation: []string{},
@@ -230,6 +230,39 @@ type Handler interface {
//
// POST /api/v1/me/assessment-attempts
CreateMyAssessmentAttempt(ctx context.Context, req AssessmentAttemptCreate, params CreateMyAssessmentAttemptParams) (CreateMyAssessmentAttemptRes, error)
// CreateMyAssessmentPracticeRun implements CreateMyAssessmentPracticeRun 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 practice item of the attempt and
// carries the language, the source, and up to ten tests of the candidate.
//
// A debug run executes the solution in the isolated sandbox against the public examples of the task
// and the tests of the candidate only. It never runs, lists, or scores a hidden check, and it changes
// neither the practice state, the verdict, nor the attempt version; the graded solution is submitted
// with SubmitMyAssessmentAnswer. The run is stored with its own identifier and executed
// asynchronously: the response is 202 with the run `queued`, and the client polls
// GetMyAssessmentPracticeRun. The source is never echoed.
//
// The practice must be the current item: the attempt is in `practice_pending` for the main practice or
// `additional_practice_pending` for the additional one, and its deadline has not passed. Otherwise the
// server answers 409 state_conflict.
//
// Availability. When code practice is not enabled on this server, the server answers 503
// service_unavailable and stores nothing.
//
// Repeats. A retry with the same Idempotency-Key and body within 24 hours returns the stored run in
// its current state with 202, without starting another run. A different body with the same key answers
// 422 idempotency_key_reused. Refusals (400, 404, 409, 503) are not stored under the key and are
// evaluated again.
//
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
// account scenario (403 forbidden), the availability of code practice (503), the Idempotency-Key (422,
// replay), the attempt and the practice (404 not_found for an unknown attempt or item, or one of
// another candidate), the state (409), then the solution against the item (400 with a pointer such as
// `/language` or `/source_code`).
//
// POST /api/v1/me/assessment-attempts/{attempt_id}/practice-runs
CreateMyAssessmentPracticeRun(ctx context.Context, req *PracticeRunCreate, params CreateMyAssessmentPracticeRunParams) (CreateMyAssessmentPracticeRunRes, error)
// CreateMySupportCase implements CreateMySupportCase operation.
//
// Requires the session cookie, the CSRF token of that session in X-CSRF-Token, an allowed Origin, and
@@ -627,6 +660,19 @@ type Handler interface {
//
// GET /api/v1/me/assessment-availability
GetMyAssessmentAvailability(ctx context.Context) (GetMyAssessmentAvailabilityRes, error)
// GetMyAssessmentPracticeRun implements GetMyAssessmentPracticeRun operation.
//
// Requires the session cookie of a candidate account. Returns the state of a debug run started with
// CreateMyAssessmentPracticeRun and, once it is `finished`, the outcome of the public examples and of
// the tests of the candidate. It never contains a hidden check, its outcome, the score, or the source.
// This GET is read-only.
//
// A run of another candidate's attempt, a run of another attempt, and an unknown identifier all answer
// 404 not_found. The graded solution submitted with SubmitMyAssessmentAnswer is not a debug run and is
// not readable here.
//
// GET /api/v1/me/assessment-attempts/{attempt_id}/practice-runs/{run_id}
GetMyAssessmentPracticeRun(ctx context.Context, params GetMyAssessmentPracticeRunParams) (GetMyAssessmentPracticeRunRes, error)
// GetMyAssessmentResult implements GetMyAssessmentResult operation.
//
// Requires the session cookie of a candidate account. Returns the immutable result of a terminal
@@ -253,6 +253,42 @@ func (UnimplementedHandler) CreateMyAssessmentAttempt(ctx context.Context, req A
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,
// an allowed Origin, and an Idempotency-Key. The body names the practice item of the attempt and
// carries the language, the source, and up to ten tests of the candidate.
//
// A debug run executes the solution in the isolated sandbox against the public examples of the task
// and the tests of the candidate only. It never runs, lists, or scores a hidden check, and it changes
// neither the practice state, the verdict, nor the attempt version; the graded solution is submitted
// with SubmitMyAssessmentAnswer. The run is stored with its own identifier and executed
// asynchronously: the response is 202 with the run `queued`, and the client polls
// GetMyAssessmentPracticeRun. The source is never echoed.
//
// The practice must be the current item: the attempt is in `practice_pending` for the main practice or
// `additional_practice_pending` for the additional one, and its deadline has not passed. Otherwise the
// server answers 409 state_conflict.
//
// Availability. When code practice is not enabled on this server, the server answers 503
// service_unavailable and stores nothing.
//
// Repeats. A retry with the same Idempotency-Key and body within 24 hours returns the stored run in
// its current state with 202, without starting another run. A different body with the same key answers
// 422 idempotency_key_reused. Refusals (400, 404, 409, 503) are not stored under the key and are
// evaluated again.
//
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
// account scenario (403 forbidden), the availability of code practice (503), the Idempotency-Key (422,
// replay), the attempt and the practice (404 not_found for an unknown attempt or item, or one of
// another candidate), the state (409), then the solution against the item (400 with a pointer such as
// `/language` or `/source_code`).
//
// POST /api/v1/me/assessment-attempts/{attempt_id}/practice-runs
func (UnimplementedHandler) CreateMyAssessmentPracticeRun(ctx context.Context, req *PracticeRunCreate, params CreateMyAssessmentPracticeRunParams) (r CreateMyAssessmentPracticeRunRes, _ error) {
return r, ht.ErrNotImplemented
}
// CreateMySupportCase implements CreateMySupportCase operation.
//
// Requires the session cookie, the CSRF token of that session in X-CSRF-Token, an allowed Origin, and
@@ -686,6 +722,22 @@ func (UnimplementedHandler) GetMyAssessmentAvailability(ctx context.Context) (r
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
// CreateMyAssessmentPracticeRun and, once it is `finished`, the outcome of the public examples and of
// the tests of the candidate. It never contains a hidden check, its outcome, the score, or the source.
// This GET is read-only.
//
// A run of another candidate's attempt, a run of another attempt, and an unknown identifier all answer
// 404 not_found. The graded solution submitted with SubmitMyAssessmentAnswer is not a debug run and is
// not readable here.
//
// GET /api/v1/me/assessment-attempts/{attempt_id}/practice-runs/{run_id}
func (UnimplementedHandler) GetMyAssessmentPracticeRun(ctx context.Context, params GetMyAssessmentPracticeRunParams) (r GetMyAssessmentPracticeRunRes, _ error) {
return r, ht.ErrNotImplemented
}
// GetMyAssessmentResult implements GetMyAssessmentResult operation.
//
// Requires the session cookie of a candidate account. Returns the immutable result of a terminal
@@ -8873,6 +8873,54 @@ func (s *CreateMyAssessmentAttemptUnprocessableEntity) Validate() error {
return nil
}
func (s *CreateMyAssessmentPracticeRunBadRequest) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *CreateMyAssessmentPracticeRunConflict) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *CreateMyAssessmentPracticeRunForbidden) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *CreateMyAssessmentPracticeRunNotFound) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *CreateMyAssessmentPracticeRunUnauthorized) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *CreateMyAssessmentPracticeRunUnprocessableEntity) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *CreateMySupportCaseBadRequest) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
@@ -10072,6 +10120,30 @@ func (s *GetMyAssessmentAvailabilityUnauthorized) Validate() error {
return nil
}
func (s *GetMyAssessmentPracticeRunForbidden) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *GetMyAssessmentPracticeRunNotFound) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *GetMyAssessmentPracticeRunUnauthorized) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *GetMyAssessmentResultConflict) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
@@ -19468,6 +19540,509 @@ func (s PracticeKind) Validate() error {
}
}
func (s *PracticeRun) 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 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 err := func() error {
if value, ok := s.Result.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: "result",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *PracticeRunCreate) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if value, ok := s.Language.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: "language",
Error: err,
})
}
if err := func() error {
if err := (validate.String{
MinLength: 1,
MinLengthSet: true,
MaxLength: 65536,
MaxLengthSet: true,
Email: false,
Hostname: false,
Regex: nil,
MinNumeric: 0,
MinNumericSet: false,
MaxNumeric: 0,
MaxNumericSet: false,
}).Validate(string(s.SourceCode)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "source_code",
Error: err,
})
}
if err := func() error {
if s.Tests == nil {
return nil // optional
}
if err := (validate.Array{
MinLength: 0,
MinLengthSet: false,
MaxLength: 10,
MaxLengthSet: true,
}).ValidateLength(len(s.Tests)); err != nil {
return errors.Wrap(err, "array")
}
var failures []validate.FieldError
for i, elem := range s.Tests {
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: "tests",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *PracticeRunHeaders) 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 PracticeRunOutcome) Validate() error {
switch s {
case "accepted":
return nil
case "wrong_answer":
return nil
case "compile_error":
return nil
case "time_limit_exceeded":
return nil
case "memory_limit_exceeded":
return nil
case "output_limit_exceeded":
return nil
case "runtime_error":
return nil
default:
return errors.Errorf("invalid value: %v", s)
}
}
func (s *PracticeRunResult) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if err := s.Outcome.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "outcome",
Error: err,
})
}
if err := func() error {
if value, ok := s.CompileDiagnostic.Get(); ok {
if err := func() error {
if err := (validate.String{
MinLength: 0,
MinLengthSet: false,
MaxLength: 4096,
MaxLengthSet: true,
Email: false,
Hostname: false,
Regex: nil,
MinNumeric: 0,
MinNumericSet: false,
MaxNumeric: 0,
MaxNumericSet: false,
}).Validate(string(value)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "compile_diagnostic",
Error: err,
})
}
if err := func() error {
if s.Tests == nil {
return errors.New("nil is invalid value")
}
if err := (validate.Array{
MinLength: 0,
MinLengthSet: false,
MaxLength: 20,
MaxLengthSet: true,
}).ValidateLength(len(s.Tests)); err != nil {
return errors.Wrap(err, "array")
}
var failures []validate.FieldError
for i, elem := range s.Tests {
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: "tests",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s PracticeRunState) Validate() error {
switch s {
case "queued":
return nil
case "running":
return nil
case "finished":
return nil
case "failed":
return nil
default:
return errors.Errorf("invalid value: %v", s)
}
}
func (s *PracticeRunTest) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if err := (validate.String{
MinLength: 0,
MinLengthSet: false,
MaxLength: 10000,
MaxLengthSet: true,
Email: false,
Hostname: false,
Regex: nil,
MinNumeric: 0,
MinNumericSet: false,
MaxNumeric: 0,
MaxNumericSet: false,
}).Validate(string(s.Input)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "input",
Error: err,
})
}
if err := func() error {
if err := (validate.String{
MinLength: 0,
MinLengthSet: false,
MaxLength: 10000,
MaxLengthSet: true,
Email: false,
Hostname: false,
Regex: nil,
MinNumeric: 0,
MinNumericSet: false,
MaxNumeric: 0,
MaxNumericSet: false,
}).Validate(string(s.ExpectedOutput)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "expected_output",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *PracticeRunTestResult) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if err := s.Source.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "source",
Error: err,
})
}
if err := func() error {
if err := (validate.Int{
MinSet: true,
Min: 1,
MaxSet: true,
Max: 10,
MinExclusive: false,
MaxExclusive: false,
MultipleOfSet: false,
MultipleOf: 0,
Pattern: nil,
}).Validate(int64(s.Index)); err != nil {
return errors.Wrap(err, "int")
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "index",
Error: err,
})
}
if err := func() error {
if err := s.Outcome.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "outcome",
Error: err,
})
}
if err := func() error {
if err := (validate.Int{
MinSet: true,
Min: 0,
MaxSet: false,
Max: 0,
MinExclusive: false,
MaxExclusive: false,
MultipleOfSet: false,
MultipleOf: 0,
Pattern: nil,
}).Validate(int64(s.TimeMs)); err != nil {
return errors.Wrap(err, "int")
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "time_ms",
Error: err,
})
}
if err := func() error {
if err := (validate.Int{
MinSet: true,
Min: 0,
MaxSet: false,
Max: 0,
MinExclusive: false,
MaxExclusive: false,
MultipleOfSet: false,
MultipleOf: 0,
Pattern: nil,
}).Validate(int64(s.MemoryKB)); err != nil {
return errors.Wrap(err, "int")
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "memory_kb",
Error: err,
})
}
if err := func() error {
if value, ok := s.Diagnostic.Get(); ok {
if err := func() error {
if err := (validate.String{
MinLength: 0,
MinLengthSet: false,
MaxLength: 2048,
MaxLengthSet: true,
Email: false,
Hostname: false,
Regex: nil,
MinNumeric: 0,
MinNumericSet: false,
MaxNumeric: 0,
MaxNumericSet: false,
}).Validate(string(value)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "diagnostic",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s PracticeRunTestSource) Validate() error {
switch s {
case "example":
return nil
case "candidate":
return nil
default:
return errors.Errorf("invalid value: %v", s)
}
}
func (s PracticeStatus) Validate() error {
switch s {
case "not_started":
@@ -23633,6 +24208,57 @@ func (s *SendOrganizationInvitationUnprocessableEntity) Validate() error {
return nil
}
func (s *ServiceUnavailableHeaders) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if value, ok := s.RetryAfter.Get(); ok {
if err := func() error {
if err := (validate.Int{
MinSet: true,
Min: 0,
MaxSet: true,
Max: 86400,
MinExclusive: false,
MaxExclusive: false,
MultipleOfSet: false,
MultipleOf: 0,
Pattern: nil,
}).Validate(int64(value)); err != nil {
return errors.Wrap(err, "int")
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "RetryAfter",
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 *Session) Validate() error {
if s == nil {
return validate.ErrNilPointer