1871 lines
49 KiB
Go
1871 lines
49 KiB
Go
// Code generated by ogen, DO NOT EDIT.
|
|
|
|
package api
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/go-faster/errors"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
func (s *ProblemStatusCode) Error() string {
|
|
return fmt.Sprintf("code %d: %+v", s.StatusCode, s.Response)
|
|
}
|
|
|
|
type BearerAuth struct {
|
|
Token string
|
|
Roles []string
|
|
}
|
|
|
|
// GetToken returns the value of Token.
|
|
func (s *BearerAuth) GetToken() string {
|
|
return s.Token
|
|
}
|
|
|
|
// GetRoles returns the value of Roles.
|
|
func (s *BearerAuth) GetRoles() []string {
|
|
return s.Roles
|
|
}
|
|
|
|
// SetToken sets the value of Token.
|
|
func (s *BearerAuth) SetToken(val string) {
|
|
s.Token = val
|
|
}
|
|
|
|
// SetRoles sets the value of Roles.
|
|
func (s *BearerAuth) SetRoles(val []string) {
|
|
s.Roles = val
|
|
}
|
|
|
|
// How the standard output of a test is compared with `expected_output`. `numbers` requires
|
|
// `abs_tolerance`, `rel_tolerance`, or both; `custom` requires `program`. Other kinds take no
|
|
// parameter. New kinds add a `kind` value and their own optional parameters.
|
|
// Ref: #/components/schemas/Checker
|
|
type Checker struct {
|
|
Kind CheckerKind `json:"kind"`
|
|
// Largest accepted absolute difference of two numeric tokens.
|
|
AbsTolerance OptFloat64 `json:"abs_tolerance"`
|
|
// Largest accepted difference of two numeric tokens relative to the expected value.
|
|
RelTolerance OptFloat64 `json:"rel_tolerance"`
|
|
Program OptCheckerProgram `json:"program"`
|
|
}
|
|
|
|
// GetKind returns the value of Kind.
|
|
func (s *Checker) GetKind() CheckerKind {
|
|
return s.Kind
|
|
}
|
|
|
|
// GetAbsTolerance returns the value of AbsTolerance.
|
|
func (s *Checker) GetAbsTolerance() OptFloat64 {
|
|
return s.AbsTolerance
|
|
}
|
|
|
|
// GetRelTolerance returns the value of RelTolerance.
|
|
func (s *Checker) GetRelTolerance() OptFloat64 {
|
|
return s.RelTolerance
|
|
}
|
|
|
|
// GetProgram returns the value of Program.
|
|
func (s *Checker) GetProgram() OptCheckerProgram {
|
|
return s.Program
|
|
}
|
|
|
|
// SetKind sets the value of Kind.
|
|
func (s *Checker) SetKind(val CheckerKind) {
|
|
s.Kind = val
|
|
}
|
|
|
|
// SetAbsTolerance sets the value of AbsTolerance.
|
|
func (s *Checker) SetAbsTolerance(val OptFloat64) {
|
|
s.AbsTolerance = val
|
|
}
|
|
|
|
// SetRelTolerance sets the value of RelTolerance.
|
|
func (s *Checker) SetRelTolerance(val OptFloat64) {
|
|
s.RelTolerance = val
|
|
}
|
|
|
|
// SetProgram sets the value of Program.
|
|
func (s *Checker) SetProgram(val OptCheckerProgram) {
|
|
s.Program = val
|
|
}
|
|
|
|
// - exact: both texts are equal after replacing CRLF with LF, removing trailing spaces and tabs at
|
|
// the end of each line, and removing trailing empty lines.
|
|
// - tokens: both texts split on ASCII whitespace give the same sequence of tokens.
|
|
// - numbers: like tokens, but two finite numeric tokens are equal when their difference is within
|
|
// abs_tolerance or within rel_tolerance times the expected value; other tokens must be equal.
|
|
// - custom: the checker program of the task family decides in the sandbox.
|
|
//
|
|
// Ref: #/components/schemas/CheckerKind
|
|
type CheckerKind string
|
|
|
|
const (
|
|
CheckerKindExact CheckerKind = "exact"
|
|
CheckerKindTokens CheckerKind = "tokens"
|
|
CheckerKindNumbers CheckerKind = "numbers"
|
|
CheckerKindCustom CheckerKind = "custom"
|
|
)
|
|
|
|
// AllValues returns all CheckerKind values.
|
|
func (CheckerKind) AllValues() []CheckerKind {
|
|
return []CheckerKind{
|
|
CheckerKindExact,
|
|
CheckerKindTokens,
|
|
CheckerKindNumbers,
|
|
CheckerKindCustom,
|
|
}
|
|
}
|
|
|
|
// MarshalText implements encoding.TextMarshaler.
|
|
func (s CheckerKind) MarshalText() ([]byte, error) {
|
|
switch s {
|
|
case CheckerKindExact:
|
|
return []byte(s), nil
|
|
case CheckerKindTokens:
|
|
return []byte(s), nil
|
|
case CheckerKindNumbers:
|
|
return []byte(s), nil
|
|
case CheckerKindCustom:
|
|
return []byte(s), nil
|
|
default:
|
|
return nil, errors.Errorf("invalid value: %q", s)
|
|
}
|
|
}
|
|
|
|
// UnmarshalText implements encoding.TextUnmarshaler.
|
|
func (s *CheckerKind) UnmarshalText(data []byte) error {
|
|
switch CheckerKind(data) {
|
|
case CheckerKindExact:
|
|
*s = CheckerKindExact
|
|
return nil
|
|
case CheckerKindTokens:
|
|
*s = CheckerKindTokens
|
|
return nil
|
|
case CheckerKindNumbers:
|
|
*s = CheckerKindNumbers
|
|
return nil
|
|
case CheckerKindCustom:
|
|
*s = CheckerKindCustom
|
|
return nil
|
|
default:
|
|
return errors.Errorf("invalid value: %q", data)
|
|
}
|
|
}
|
|
|
|
// Checker program of the task family. It runs in the sandbox with the same isolation as the solution
|
|
// and fixed limits of its own (5 s CPU, 256 MiB). Its arguments are the paths of three read-only
|
|
// files: the test input, the expected output, and the actual output. Exit status 0 accepts, 1 rejects,
|
|
// and anything else, a signal, or a limit is a checker failure, which makes the run
|
|
// infrastructure_failure. Its own output is discarded and never returned.
|
|
// Ref: #/components/schemas/CheckerProgram
|
|
type CheckerProgram struct {
|
|
Language RunLanguage `json:"language"`
|
|
Source string `json:"source"`
|
|
}
|
|
|
|
// GetLanguage returns the value of Language.
|
|
func (s *CheckerProgram) GetLanguage() RunLanguage {
|
|
return s.Language
|
|
}
|
|
|
|
// GetSource returns the value of Source.
|
|
func (s *CheckerProgram) GetSource() string {
|
|
return s.Source
|
|
}
|
|
|
|
// SetLanguage sets the value of Language.
|
|
func (s *CheckerProgram) SetLanguage(val RunLanguage) {
|
|
s.Language = val
|
|
}
|
|
|
|
// SetSource sets the value of Source.
|
|
func (s *CheckerProgram) SetSource(val string) {
|
|
s.Source = val
|
|
}
|
|
|
|
// Ref: #/components/schemas/CompileResult
|
|
type CompileResult struct {
|
|
Outcome RunOutcome `json:"outcome"`
|
|
// Compiler or syntax checker message for compile_error, truncated to the limit. It can quote the
|
|
// source, never test data.
|
|
Diagnostic OptString `json:"diagnostic"`
|
|
}
|
|
|
|
// GetOutcome returns the value of Outcome.
|
|
func (s *CompileResult) GetOutcome() RunOutcome {
|
|
return s.Outcome
|
|
}
|
|
|
|
// GetDiagnostic returns the value of Diagnostic.
|
|
func (s *CompileResult) GetDiagnostic() OptString {
|
|
return s.Diagnostic
|
|
}
|
|
|
|
// SetOutcome sets the value of Outcome.
|
|
func (s *CompileResult) SetOutcome(val RunOutcome) {
|
|
s.Outcome = val
|
|
}
|
|
|
|
// SetDiagnostic sets the value of Diagnostic.
|
|
func (s *CompileResult) SetDiagnostic(val OptString) {
|
|
s.Diagnostic = val
|
|
}
|
|
|
|
type GetRunnerReadyzOK RunnerReadinessResponse
|
|
|
|
func (*GetRunnerReadyzOK) getRunnerReadyzRes() {}
|
|
|
|
type GetRunnerReadyzServiceUnavailable RunnerReadinessResponse
|
|
|
|
func (*GetRunnerReadyzServiceUnavailable) getRunnerReadyzRes() {}
|
|
|
|
// Ref: #/components/schemas/GroupResult
|
|
type GroupResult struct {
|
|
ID TestKey `json:"id"`
|
|
Visibility TestVisibility `json:"visibility"`
|
|
Outcome RunOutcome `json:"outcome"`
|
|
PassedTests int32 `json:"passed_tests"`
|
|
TotalTests int32 `json:"total_tests"`
|
|
// Largest CPU time of an evaluated test of the group.
|
|
MaxTimeMs OptInt64 `json:"max_time_ms"`
|
|
// Largest peak memory of an evaluated test of the group.
|
|
MaxMemoryKB OptInt64 `json:"max_memory_kb"`
|
|
// Results of the evaluated tests in order. Tests after the first failed one are not run and not
|
|
// listed.
|
|
Tests []TestResult `json:"tests"`
|
|
}
|
|
|
|
// GetID returns the value of ID.
|
|
func (s *GroupResult) GetID() TestKey {
|
|
return s.ID
|
|
}
|
|
|
|
// GetVisibility returns the value of Visibility.
|
|
func (s *GroupResult) GetVisibility() TestVisibility {
|
|
return s.Visibility
|
|
}
|
|
|
|
// GetOutcome returns the value of Outcome.
|
|
func (s *GroupResult) GetOutcome() RunOutcome {
|
|
return s.Outcome
|
|
}
|
|
|
|
// GetPassedTests returns the value of PassedTests.
|
|
func (s *GroupResult) GetPassedTests() int32 {
|
|
return s.PassedTests
|
|
}
|
|
|
|
// GetTotalTests returns the value of TotalTests.
|
|
func (s *GroupResult) GetTotalTests() int32 {
|
|
return s.TotalTests
|
|
}
|
|
|
|
// GetMaxTimeMs returns the value of MaxTimeMs.
|
|
func (s *GroupResult) GetMaxTimeMs() OptInt64 {
|
|
return s.MaxTimeMs
|
|
}
|
|
|
|
// GetMaxMemoryKB returns the value of MaxMemoryKB.
|
|
func (s *GroupResult) GetMaxMemoryKB() OptInt64 {
|
|
return s.MaxMemoryKB
|
|
}
|
|
|
|
// GetTests returns the value of Tests.
|
|
func (s *GroupResult) GetTests() []TestResult {
|
|
return s.Tests
|
|
}
|
|
|
|
// SetID sets the value of ID.
|
|
func (s *GroupResult) SetID(val TestKey) {
|
|
s.ID = val
|
|
}
|
|
|
|
// SetVisibility sets the value of Visibility.
|
|
func (s *GroupResult) SetVisibility(val TestVisibility) {
|
|
s.Visibility = val
|
|
}
|
|
|
|
// SetOutcome sets the value of Outcome.
|
|
func (s *GroupResult) SetOutcome(val RunOutcome) {
|
|
s.Outcome = val
|
|
}
|
|
|
|
// SetPassedTests sets the value of PassedTests.
|
|
func (s *GroupResult) SetPassedTests(val int32) {
|
|
s.PassedTests = val
|
|
}
|
|
|
|
// SetTotalTests sets the value of TotalTests.
|
|
func (s *GroupResult) SetTotalTests(val int32) {
|
|
s.TotalTests = val
|
|
}
|
|
|
|
// SetMaxTimeMs sets the value of MaxTimeMs.
|
|
func (s *GroupResult) SetMaxTimeMs(val OptInt64) {
|
|
s.MaxTimeMs = val
|
|
}
|
|
|
|
// SetMaxMemoryKB sets the value of MaxMemoryKB.
|
|
func (s *GroupResult) SetMaxMemoryKB(val OptInt64) {
|
|
s.MaxMemoryKB = val
|
|
}
|
|
|
|
// SetTests sets the value of Tests.
|
|
func (s *GroupResult) SetTests(val []TestResult) {
|
|
s.Tests = val
|
|
}
|
|
|
|
// NewOptCheckerProgram returns new OptCheckerProgram with value set to v.
|
|
func NewOptCheckerProgram(v CheckerProgram) OptCheckerProgram {
|
|
return OptCheckerProgram{
|
|
Value: v,
|
|
Set: true,
|
|
}
|
|
}
|
|
|
|
// OptCheckerProgram is optional CheckerProgram.
|
|
type OptCheckerProgram struct {
|
|
Value CheckerProgram
|
|
Set bool
|
|
}
|
|
|
|
// IsSet returns true if OptCheckerProgram was set.
|
|
func (o OptCheckerProgram) IsSet() bool { return o.Set }
|
|
|
|
// Reset unsets value.
|
|
func (o *OptCheckerProgram) Reset() {
|
|
var v CheckerProgram
|
|
o.Value = v
|
|
o.Set = false
|
|
}
|
|
|
|
// SetTo sets value to v.
|
|
func (o *OptCheckerProgram) SetTo(v CheckerProgram) {
|
|
o.Set = true
|
|
o.Value = v
|
|
}
|
|
|
|
// Get returns value and boolean that denotes whether value was set.
|
|
func (o OptCheckerProgram) Get() (v CheckerProgram, ok bool) {
|
|
if !o.Set {
|
|
return v, false
|
|
}
|
|
return o.Value, true
|
|
}
|
|
|
|
// Or returns value if set, or given parameter if does not.
|
|
func (o OptCheckerProgram) Or(d CheckerProgram) CheckerProgram {
|
|
if v, ok := o.Get(); ok {
|
|
return v
|
|
}
|
|
return d
|
|
}
|
|
|
|
// NewOptCompileResult returns new OptCompileResult with value set to v.
|
|
func NewOptCompileResult(v CompileResult) OptCompileResult {
|
|
return OptCompileResult{
|
|
Value: v,
|
|
Set: true,
|
|
}
|
|
}
|
|
|
|
// OptCompileResult is optional CompileResult.
|
|
type OptCompileResult struct {
|
|
Value CompileResult
|
|
Set bool
|
|
}
|
|
|
|
// IsSet returns true if OptCompileResult was set.
|
|
func (o OptCompileResult) IsSet() bool { return o.Set }
|
|
|
|
// Reset unsets value.
|
|
func (o *OptCompileResult) Reset() {
|
|
var v CompileResult
|
|
o.Value = v
|
|
o.Set = false
|
|
}
|
|
|
|
// SetTo sets value to v.
|
|
func (o *OptCompileResult) SetTo(v CompileResult) {
|
|
o.Set = true
|
|
o.Value = v
|
|
}
|
|
|
|
// Get returns value and boolean that denotes whether value was set.
|
|
func (o OptCompileResult) Get() (v CompileResult, ok bool) {
|
|
if !o.Set {
|
|
return v, false
|
|
}
|
|
return o.Value, true
|
|
}
|
|
|
|
// Or returns value if set, or given parameter if does not.
|
|
func (o OptCompileResult) Or(d CompileResult) CompileResult {
|
|
if v, ok := o.Get(); ok {
|
|
return v
|
|
}
|
|
return d
|
|
}
|
|
|
|
// NewOptFloat64 returns new OptFloat64 with value set to v.
|
|
func NewOptFloat64(v float64) OptFloat64 {
|
|
return OptFloat64{
|
|
Value: v,
|
|
Set: true,
|
|
}
|
|
}
|
|
|
|
// OptFloat64 is optional float64.
|
|
type OptFloat64 struct {
|
|
Value float64
|
|
Set bool
|
|
}
|
|
|
|
// IsSet returns true if OptFloat64 was set.
|
|
func (o OptFloat64) IsSet() bool { return o.Set }
|
|
|
|
// Reset unsets value.
|
|
func (o *OptFloat64) Reset() {
|
|
var v float64
|
|
o.Value = v
|
|
o.Set = false
|
|
}
|
|
|
|
// SetTo sets value to v.
|
|
func (o *OptFloat64) SetTo(v float64) {
|
|
o.Set = true
|
|
o.Value = v
|
|
}
|
|
|
|
// Get returns value and boolean that denotes whether value was set.
|
|
func (o OptFloat64) Get() (v float64, ok bool) {
|
|
if !o.Set {
|
|
return v, false
|
|
}
|
|
return o.Value, true
|
|
}
|
|
|
|
// Or returns value if set, or given parameter if does not.
|
|
func (o OptFloat64) Or(d float64) float64 {
|
|
if v, ok := o.Get(); ok {
|
|
return v
|
|
}
|
|
return d
|
|
}
|
|
|
|
// NewOptInt32 returns new OptInt32 with value set to v.
|
|
func NewOptInt32(v int32) OptInt32 {
|
|
return OptInt32{
|
|
Value: v,
|
|
Set: true,
|
|
}
|
|
}
|
|
|
|
// OptInt32 is optional int32.
|
|
type OptInt32 struct {
|
|
Value int32
|
|
Set bool
|
|
}
|
|
|
|
// IsSet returns true if OptInt32 was set.
|
|
func (o OptInt32) IsSet() bool { return o.Set }
|
|
|
|
// Reset unsets value.
|
|
func (o *OptInt32) Reset() {
|
|
var v int32
|
|
o.Value = v
|
|
o.Set = false
|
|
}
|
|
|
|
// SetTo sets value to v.
|
|
func (o *OptInt32) SetTo(v int32) {
|
|
o.Set = true
|
|
o.Value = v
|
|
}
|
|
|
|
// Get returns value and boolean that denotes whether value was set.
|
|
func (o OptInt32) Get() (v int32, ok bool) {
|
|
if !o.Set {
|
|
return v, false
|
|
}
|
|
return o.Value, true
|
|
}
|
|
|
|
// Or returns value if set, or given parameter if does not.
|
|
func (o OptInt32) Or(d int32) int32 {
|
|
if v, ok := o.Get(); ok {
|
|
return v
|
|
}
|
|
return d
|
|
}
|
|
|
|
// NewOptInt64 returns new OptInt64 with value set to v.
|
|
func NewOptInt64(v int64) OptInt64 {
|
|
return OptInt64{
|
|
Value: v,
|
|
Set: true,
|
|
}
|
|
}
|
|
|
|
// OptInt64 is optional int64.
|
|
type OptInt64 struct {
|
|
Value int64
|
|
Set bool
|
|
}
|
|
|
|
// IsSet returns true if OptInt64 was set.
|
|
func (o OptInt64) IsSet() bool { return o.Set }
|
|
|
|
// Reset unsets value.
|
|
func (o *OptInt64) Reset() {
|
|
var v int64
|
|
o.Value = v
|
|
o.Set = false
|
|
}
|
|
|
|
// SetTo sets value to v.
|
|
func (o *OptInt64) SetTo(v int64) {
|
|
o.Set = true
|
|
o.Value = v
|
|
}
|
|
|
|
// Get returns value and boolean that denotes whether value was set.
|
|
func (o OptInt64) Get() (v int64, ok bool) {
|
|
if !o.Set {
|
|
return v, false
|
|
}
|
|
return o.Value, true
|
|
}
|
|
|
|
// Or returns value if set, or given parameter if does not.
|
|
func (o OptInt64) Or(d int64) int64 {
|
|
if v, ok := o.Get(); ok {
|
|
return v
|
|
}
|
|
return d
|
|
}
|
|
|
|
// NewOptRunResult returns new OptRunResult with value set to v.
|
|
func NewOptRunResult(v RunResult) OptRunResult {
|
|
return OptRunResult{
|
|
Value: v,
|
|
Set: true,
|
|
}
|
|
}
|
|
|
|
// OptRunResult is optional RunResult.
|
|
type OptRunResult struct {
|
|
Value RunResult
|
|
Set bool
|
|
}
|
|
|
|
// IsSet returns true if OptRunResult was set.
|
|
func (o OptRunResult) IsSet() bool { return o.Set }
|
|
|
|
// Reset unsets value.
|
|
func (o *OptRunResult) Reset() {
|
|
var v RunResult
|
|
o.Value = v
|
|
o.Set = false
|
|
}
|
|
|
|
// SetTo sets value to v.
|
|
func (o *OptRunResult) SetTo(v RunResult) {
|
|
o.Set = true
|
|
o.Value = v
|
|
}
|
|
|
|
// Get returns value and boolean that denotes whether value was set.
|
|
func (o OptRunResult) Get() (v RunResult, ok bool) {
|
|
if !o.Set {
|
|
return v, false
|
|
}
|
|
return o.Value, true
|
|
}
|
|
|
|
// Or returns value if set, or given parameter if does not.
|
|
func (o OptRunResult) Or(d RunResult) RunResult {
|
|
if v, ok := o.Get(); ok {
|
|
return v
|
|
}
|
|
return d
|
|
}
|
|
|
|
// NewOptString returns new OptString with value set to v.
|
|
func NewOptString(v string) OptString {
|
|
return OptString{
|
|
Value: v,
|
|
Set: true,
|
|
}
|
|
}
|
|
|
|
// OptString is optional string.
|
|
type OptString struct {
|
|
Value string
|
|
Set bool
|
|
}
|
|
|
|
// IsSet returns true if OptString was set.
|
|
func (o OptString) IsSet() bool { return o.Set }
|
|
|
|
// Reset unsets value.
|
|
func (o *OptString) Reset() {
|
|
var v string
|
|
o.Value = v
|
|
o.Set = false
|
|
}
|
|
|
|
// SetTo sets value to v.
|
|
func (o *OptString) SetTo(v string) {
|
|
o.Set = true
|
|
o.Value = v
|
|
}
|
|
|
|
// Get returns value and boolean that denotes whether value was set.
|
|
func (o OptString) Get() (v string, ok bool) {
|
|
if !o.Set {
|
|
return v, false
|
|
}
|
|
return o.Value, true
|
|
}
|
|
|
|
// Or returns value if set, or given parameter if does not.
|
|
func (o OptString) Or(d string) string {
|
|
if v, ok := o.Get(); ok {
|
|
return v
|
|
}
|
|
return d
|
|
}
|
|
|
|
// NewOptTerminationLimit returns new OptTerminationLimit with value set to v.
|
|
func NewOptTerminationLimit(v TerminationLimit) OptTerminationLimit {
|
|
return OptTerminationLimit{
|
|
Value: v,
|
|
Set: true,
|
|
}
|
|
}
|
|
|
|
// OptTerminationLimit is optional TerminationLimit.
|
|
type OptTerminationLimit struct {
|
|
Value TerminationLimit
|
|
Set bool
|
|
}
|
|
|
|
// IsSet returns true if OptTerminationLimit was set.
|
|
func (o OptTerminationLimit) IsSet() bool { return o.Set }
|
|
|
|
// Reset unsets value.
|
|
func (o *OptTerminationLimit) Reset() {
|
|
var v TerminationLimit
|
|
o.Value = v
|
|
o.Set = false
|
|
}
|
|
|
|
// SetTo sets value to v.
|
|
func (o *OptTerminationLimit) SetTo(v TerminationLimit) {
|
|
o.Set = true
|
|
o.Value = v
|
|
}
|
|
|
|
// Get returns value and boolean that denotes whether value was set.
|
|
func (o OptTerminationLimit) Get() (v TerminationLimit, ok bool) {
|
|
if !o.Set {
|
|
return v, false
|
|
}
|
|
return o.Value, true
|
|
}
|
|
|
|
// Or returns value if set, or given parameter if does not.
|
|
func (o OptTerminationLimit) Or(d TerminationLimit) TerminationLimit {
|
|
if v, ok := o.Get(); ok {
|
|
return v
|
|
}
|
|
return d
|
|
}
|
|
|
|
// Problem details (RFC 9457) returned with the application/problem+json media type for every error
|
|
// response. This is the runner copy of the public api/core Problem schema; keep both copies identical
|
|
// except for descriptions and the ProblemCode enum. `code` is the stable, machine-readable reason;
|
|
// clients branch on it rather than on `title`, `detail`, or the HTTP status alone. The body never
|
|
// contains internal error text, stack traces, SQL, file paths, credentials, contact data, or echoed
|
|
// request values.
|
|
// Ref: #/components/schemas/Problem
|
|
type Problem struct {
|
|
// URI that identifies the problem type. It has the form `urn:lincodex:problem:<code>` and is an
|
|
// identifier, not a link to dereference.
|
|
Type string `json:"type"`
|
|
// Short, fixed English summary of the problem type. It does not change between occurrences.
|
|
Title string `json:"title"`
|
|
// HTTP status code generated by the origin server.
|
|
Status int32 `json:"status"`
|
|
Code ProblemCode `json:"code"`
|
|
// Safe English explanation of this occurrence. It never contains internal error text or request
|
|
// values.
|
|
Detail OptString `json:"detail"`
|
|
// URI reference that identifies this occurrence, when one exists.
|
|
Instance OptString `json:"instance"`
|
|
// Request identifier of the call when the caller propagated one; it is not a secret.
|
|
TraceID OptString `json:"trace_id"`
|
|
// Field-level reasons for validation_failed. Other codes omit it.
|
|
Errors []ProblemFieldError `json:"errors"`
|
|
}
|
|
|
|
// GetType returns the value of Type.
|
|
func (s *Problem) GetType() string {
|
|
return s.Type
|
|
}
|
|
|
|
// GetTitle returns the value of Title.
|
|
func (s *Problem) GetTitle() string {
|
|
return s.Title
|
|
}
|
|
|
|
// GetStatus returns the value of Status.
|
|
func (s *Problem) GetStatus() int32 {
|
|
return s.Status
|
|
}
|
|
|
|
// GetCode returns the value of Code.
|
|
func (s *Problem) GetCode() ProblemCode {
|
|
return s.Code
|
|
}
|
|
|
|
// GetDetail returns the value of Detail.
|
|
func (s *Problem) GetDetail() OptString {
|
|
return s.Detail
|
|
}
|
|
|
|
// GetInstance returns the value of Instance.
|
|
func (s *Problem) GetInstance() OptString {
|
|
return s.Instance
|
|
}
|
|
|
|
// GetTraceID returns the value of TraceID.
|
|
func (s *Problem) GetTraceID() OptString {
|
|
return s.TraceID
|
|
}
|
|
|
|
// GetErrors returns the value of Errors.
|
|
func (s *Problem) GetErrors() []ProblemFieldError {
|
|
return s.Errors
|
|
}
|
|
|
|
// SetType sets the value of Type.
|
|
func (s *Problem) SetType(val string) {
|
|
s.Type = val
|
|
}
|
|
|
|
// SetTitle sets the value of Title.
|
|
func (s *Problem) SetTitle(val string) {
|
|
s.Title = val
|
|
}
|
|
|
|
// SetStatus sets the value of Status.
|
|
func (s *Problem) SetStatus(val int32) {
|
|
s.Status = val
|
|
}
|
|
|
|
// SetCode sets the value of Code.
|
|
func (s *Problem) SetCode(val ProblemCode) {
|
|
s.Code = val
|
|
}
|
|
|
|
// SetDetail sets the value of Detail.
|
|
func (s *Problem) SetDetail(val OptString) {
|
|
s.Detail = val
|
|
}
|
|
|
|
// SetInstance sets the value of Instance.
|
|
func (s *Problem) SetInstance(val OptString) {
|
|
s.Instance = val
|
|
}
|
|
|
|
// SetTraceID sets the value of TraceID.
|
|
func (s *Problem) SetTraceID(val OptString) {
|
|
s.TraceID = val
|
|
}
|
|
|
|
// SetErrors sets the value of Errors.
|
|
func (s *Problem) SetErrors(val []ProblemFieldError) {
|
|
s.Errors = val
|
|
}
|
|
|
|
// Stable error code of the runner API. Adding a code is a contract change; renaming or removing one is
|
|
// a breaking change. Clients must handle an unknown code by its HTTP status.
|
|
//
|
|
// - validation_failed (400): parameters or body do not match the contract or a semantic rule of
|
|
// SubmitRun; `errors` points at the fields.
|
|
// - unauthenticated (401): the bearer token is missing or wrong.
|
|
// - not_found (404): the route or the run does not exist.
|
|
// - method_not_allowed (405): the route does not support the method.
|
|
// - payload_too_large (413): the request body exceeds the limit.
|
|
// - unsupported_media_type (415): the request Content-Type is not accepted.
|
|
// - idempotency_key_reused (422): the run ID was already used with a different payload.
|
|
// - internal (500): unexpected server error.
|
|
// - runner_busy (503): every sandbox slot is busy or the runner is draining; see Retry-After.
|
|
//
|
|
// The Problem shape is the api/core shape; only this enum is specific to the runner.
|
|
// Ref: #/components/schemas/ProblemCode
|
|
type ProblemCode string
|
|
|
|
const (
|
|
ProblemCodeValidationFailed ProblemCode = "validation_failed"
|
|
ProblemCodeUnauthenticated ProblemCode = "unauthenticated"
|
|
ProblemCodeNotFound ProblemCode = "not_found"
|
|
ProblemCodeMethodNotAllowed ProblemCode = "method_not_allowed"
|
|
ProblemCodePayloadTooLarge ProblemCode = "payload_too_large"
|
|
ProblemCodeUnsupportedMediaType ProblemCode = "unsupported_media_type"
|
|
ProblemCodeIdempotencyKeyReused ProblemCode = "idempotency_key_reused"
|
|
ProblemCodeInternal ProblemCode = "internal"
|
|
ProblemCodeRunnerBusy ProblemCode = "runner_busy"
|
|
)
|
|
|
|
// AllValues returns all ProblemCode values.
|
|
func (ProblemCode) AllValues() []ProblemCode {
|
|
return []ProblemCode{
|
|
ProblemCodeValidationFailed,
|
|
ProblemCodeUnauthenticated,
|
|
ProblemCodeNotFound,
|
|
ProblemCodeMethodNotAllowed,
|
|
ProblemCodePayloadTooLarge,
|
|
ProblemCodeUnsupportedMediaType,
|
|
ProblemCodeIdempotencyKeyReused,
|
|
ProblemCodeInternal,
|
|
ProblemCodeRunnerBusy,
|
|
}
|
|
}
|
|
|
|
// MarshalText implements encoding.TextMarshaler.
|
|
func (s ProblemCode) MarshalText() ([]byte, error) {
|
|
switch s {
|
|
case ProblemCodeValidationFailed:
|
|
return []byte(s), nil
|
|
case ProblemCodeUnauthenticated:
|
|
return []byte(s), nil
|
|
case ProblemCodeNotFound:
|
|
return []byte(s), nil
|
|
case ProblemCodeMethodNotAllowed:
|
|
return []byte(s), nil
|
|
case ProblemCodePayloadTooLarge:
|
|
return []byte(s), nil
|
|
case ProblemCodeUnsupportedMediaType:
|
|
return []byte(s), nil
|
|
case ProblemCodeIdempotencyKeyReused:
|
|
return []byte(s), nil
|
|
case ProblemCodeInternal:
|
|
return []byte(s), nil
|
|
case ProblemCodeRunnerBusy:
|
|
return []byte(s), nil
|
|
default:
|
|
return nil, errors.Errorf("invalid value: %q", s)
|
|
}
|
|
}
|
|
|
|
// UnmarshalText implements encoding.TextUnmarshaler.
|
|
func (s *ProblemCode) UnmarshalText(data []byte) error {
|
|
switch ProblemCode(data) {
|
|
case ProblemCodeValidationFailed:
|
|
*s = ProblemCodeValidationFailed
|
|
return nil
|
|
case ProblemCodeUnauthenticated:
|
|
*s = ProblemCodeUnauthenticated
|
|
return nil
|
|
case ProblemCodeNotFound:
|
|
*s = ProblemCodeNotFound
|
|
return nil
|
|
case ProblemCodeMethodNotAllowed:
|
|
*s = ProblemCodeMethodNotAllowed
|
|
return nil
|
|
case ProblemCodePayloadTooLarge:
|
|
*s = ProblemCodePayloadTooLarge
|
|
return nil
|
|
case ProblemCodeUnsupportedMediaType:
|
|
*s = ProblemCodeUnsupportedMediaType
|
|
return nil
|
|
case ProblemCodeIdempotencyKeyReused:
|
|
*s = ProblemCodeIdempotencyKeyReused
|
|
return nil
|
|
case ProblemCodeInternal:
|
|
*s = ProblemCodeInternal
|
|
return nil
|
|
case ProblemCodeRunnerBusy:
|
|
*s = ProblemCodeRunnerBusy
|
|
return nil
|
|
default:
|
|
return errors.Errorf("invalid value: %q", data)
|
|
}
|
|
}
|
|
|
|
// One reason why a request field or parameter is invalid.
|
|
// Ref: #/components/schemas/ProblemFieldError
|
|
type ProblemFieldError struct {
|
|
In ProblemFieldLocation `json:"in"`
|
|
// JSON Pointer (RFC 6901). For `body` it points into the request body document, for example
|
|
// `/limits/time_limit_ms`; an empty string means the whole body. For a parameter it is `/` followed by
|
|
// the parameter name, for example `/run_id`.
|
|
Pointer string `json:"pointer"`
|
|
// Stable field reason. Current values are `required` (missing value) and `invalid` (malformed value or
|
|
// a value outside the schema). Clients must tolerate new values.
|
|
Code string `json:"code"`
|
|
// Fixed English message that never echoes the submitted value.
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
// GetIn returns the value of In.
|
|
func (s *ProblemFieldError) GetIn() ProblemFieldLocation {
|
|
return s.In
|
|
}
|
|
|
|
// GetPointer returns the value of Pointer.
|
|
func (s *ProblemFieldError) GetPointer() string {
|
|
return s.Pointer
|
|
}
|
|
|
|
// GetCode returns the value of Code.
|
|
func (s *ProblemFieldError) GetCode() string {
|
|
return s.Code
|
|
}
|
|
|
|
// GetMessage returns the value of Message.
|
|
func (s *ProblemFieldError) GetMessage() string {
|
|
return s.Message
|
|
}
|
|
|
|
// SetIn sets the value of In.
|
|
func (s *ProblemFieldError) SetIn(val ProblemFieldLocation) {
|
|
s.In = val
|
|
}
|
|
|
|
// SetPointer sets the value of Pointer.
|
|
func (s *ProblemFieldError) SetPointer(val string) {
|
|
s.Pointer = val
|
|
}
|
|
|
|
// SetCode sets the value of Code.
|
|
func (s *ProblemFieldError) SetCode(val string) {
|
|
s.Code = val
|
|
}
|
|
|
|
// SetMessage sets the value of Message.
|
|
func (s *ProblemFieldError) SetMessage(val string) {
|
|
s.Message = val
|
|
}
|
|
|
|
// Part of the request that contains the invalid field.
|
|
// Ref: #/components/schemas/ProblemFieldLocation
|
|
type ProblemFieldLocation string
|
|
|
|
const (
|
|
ProblemFieldLocationBody ProblemFieldLocation = "body"
|
|
ProblemFieldLocationQuery ProblemFieldLocation = "query"
|
|
ProblemFieldLocationPath ProblemFieldLocation = "path"
|
|
ProblemFieldLocationHeader ProblemFieldLocation = "header"
|
|
ProblemFieldLocationCookie ProblemFieldLocation = "cookie"
|
|
)
|
|
|
|
// AllValues returns all ProblemFieldLocation values.
|
|
func (ProblemFieldLocation) AllValues() []ProblemFieldLocation {
|
|
return []ProblemFieldLocation{
|
|
ProblemFieldLocationBody,
|
|
ProblemFieldLocationQuery,
|
|
ProblemFieldLocationPath,
|
|
ProblemFieldLocationHeader,
|
|
ProblemFieldLocationCookie,
|
|
}
|
|
}
|
|
|
|
// MarshalText implements encoding.TextMarshaler.
|
|
func (s ProblemFieldLocation) MarshalText() ([]byte, error) {
|
|
switch s {
|
|
case ProblemFieldLocationBody:
|
|
return []byte(s), nil
|
|
case ProblemFieldLocationQuery:
|
|
return []byte(s), nil
|
|
case ProblemFieldLocationPath:
|
|
return []byte(s), nil
|
|
case ProblemFieldLocationHeader:
|
|
return []byte(s), nil
|
|
case ProblemFieldLocationCookie:
|
|
return []byte(s), nil
|
|
default:
|
|
return nil, errors.Errorf("invalid value: %q", s)
|
|
}
|
|
}
|
|
|
|
// UnmarshalText implements encoding.TextUnmarshaler.
|
|
func (s *ProblemFieldLocation) UnmarshalText(data []byte) error {
|
|
switch ProblemFieldLocation(data) {
|
|
case ProblemFieldLocationBody:
|
|
*s = ProblemFieldLocationBody
|
|
return nil
|
|
case ProblemFieldLocationQuery:
|
|
*s = ProblemFieldLocationQuery
|
|
return nil
|
|
case ProblemFieldLocationPath:
|
|
*s = ProblemFieldLocationPath
|
|
return nil
|
|
case ProblemFieldLocationHeader:
|
|
*s = ProblemFieldLocationHeader
|
|
return nil
|
|
case ProblemFieldLocationCookie:
|
|
*s = ProblemFieldLocationCookie
|
|
return nil
|
|
default:
|
|
return errors.Errorf("invalid value: %q", data)
|
|
}
|
|
}
|
|
|
|
// ProblemStatusCode wraps Problem with StatusCode.
|
|
type ProblemStatusCode struct {
|
|
StatusCode int
|
|
Response Problem
|
|
}
|
|
|
|
// GetStatusCode returns the value of StatusCode.
|
|
func (s *ProblemStatusCode) GetStatusCode() int {
|
|
return s.StatusCode
|
|
}
|
|
|
|
// GetResponse returns the value of Response.
|
|
func (s *ProblemStatusCode) GetResponse() Problem {
|
|
return s.Response
|
|
}
|
|
|
|
// SetStatusCode sets the value of StatusCode.
|
|
func (s *ProblemStatusCode) SetStatusCode(val int) {
|
|
s.StatusCode = val
|
|
}
|
|
|
|
// SetResponse sets the value of Response.
|
|
func (s *ProblemStatusCode) SetResponse(val Problem) {
|
|
s.Response = val
|
|
}
|
|
|
|
// Language and runtime of the source. `python3` runs the Python 3 interpreter of the runner image with
|
|
// isolated mode and no bytecode writes; a syntax check runs first and fails with compile_error. `go`
|
|
// compiles one `package main` file with the Go toolchain of the runner image against a prebuilt
|
|
// standard library (no modules, no cgo, no network) in a separate compile phase with its own limits; a
|
|
// compile or link error is compile_error and no test runs.
|
|
// Ref: #/components/schemas/RunLanguage
|
|
type RunLanguage string
|
|
|
|
const (
|
|
RunLanguagePython3 RunLanguage = "python3"
|
|
RunLanguageGo RunLanguage = "go"
|
|
)
|
|
|
|
// AllValues returns all RunLanguage values.
|
|
func (RunLanguage) AllValues() []RunLanguage {
|
|
return []RunLanguage{
|
|
RunLanguagePython3,
|
|
RunLanguageGo,
|
|
}
|
|
}
|
|
|
|
// MarshalText implements encoding.TextMarshaler.
|
|
func (s RunLanguage) MarshalText() ([]byte, error) {
|
|
switch s {
|
|
case RunLanguagePython3:
|
|
return []byte(s), nil
|
|
case RunLanguageGo:
|
|
return []byte(s), nil
|
|
default:
|
|
return nil, errors.Errorf("invalid value: %q", s)
|
|
}
|
|
}
|
|
|
|
// UnmarshalText implements encoding.TextUnmarshaler.
|
|
func (s *RunLanguage) UnmarshalText(data []byte) error {
|
|
switch RunLanguage(data) {
|
|
case RunLanguagePython3:
|
|
*s = RunLanguagePython3
|
|
return nil
|
|
case RunLanguageGo:
|
|
*s = RunLanguageGo
|
|
return nil
|
|
default:
|
|
return errors.Errorf("invalid value: %q", data)
|
|
}
|
|
}
|
|
|
|
// Limits applied to every test of the run.
|
|
// Ref: #/components/schemas/RunLimits
|
|
type RunLimits struct {
|
|
// CPU time per test, including interpreter startup, summed over every process of the test. The
|
|
// wall-clock limit is twice this value plus a fixed startup allowance.
|
|
TimeLimitMs int32 `json:"time_limit_ms"`
|
|
// Memory of the test's processes in MiB, enforced by a cgroup v2 memory limit without swap. The limit
|
|
// also leaves a small fixed allowance for the sandbox supervisor process.
|
|
MemoryLimitMB int32 `json:"memory_limit_mb"`
|
|
// Standard output per test in KiB. The test is stopped as soon as it writes more.
|
|
OutputLimitKB int32 `json:"output_limit_kb"`
|
|
}
|
|
|
|
// GetTimeLimitMs returns the value of TimeLimitMs.
|
|
func (s *RunLimits) GetTimeLimitMs() int32 {
|
|
return s.TimeLimitMs
|
|
}
|
|
|
|
// GetMemoryLimitMB returns the value of MemoryLimitMB.
|
|
func (s *RunLimits) GetMemoryLimitMB() int32 {
|
|
return s.MemoryLimitMB
|
|
}
|
|
|
|
// GetOutputLimitKB returns the value of OutputLimitKB.
|
|
func (s *RunLimits) GetOutputLimitKB() int32 {
|
|
return s.OutputLimitKB
|
|
}
|
|
|
|
// SetTimeLimitMs sets the value of TimeLimitMs.
|
|
func (s *RunLimits) SetTimeLimitMs(val int32) {
|
|
s.TimeLimitMs = val
|
|
}
|
|
|
|
// SetMemoryLimitMB sets the value of MemoryLimitMB.
|
|
func (s *RunLimits) SetMemoryLimitMB(val int32) {
|
|
s.MemoryLimitMB = val
|
|
}
|
|
|
|
// SetOutputLimitKB sets the value of OutputLimitKB.
|
|
func (s *RunLimits) SetOutputLimitKB(val int32) {
|
|
s.OutputLimitKB = val
|
|
}
|
|
|
|
// Outcome of a test, a group, a compile step, or a whole run.
|
|
//
|
|
// - accepted: the program exited with status 0 within every limit and the checker accepted the
|
|
// output.
|
|
// - wrong_answer: the program exited with status 0 within every limit, but the checker rejected the
|
|
// output.
|
|
// - compile_error: the source was rejected before any test ran (for Python, a syntax error).
|
|
// - time_limit_exceeded: the CPU time limit or the wall-clock limit stopped the program.
|
|
// - memory_limit_exceeded: the cgroup memory limit stopped the program.
|
|
// - output_limit_exceeded: the program wrote more standard output than the limit.
|
|
// - runtime_error: the program exited with a non-zero status, was killed by a signal, or reached the
|
|
// process limit.
|
|
// - infrastructure_failure: the runner could not evaluate the source; the outcome says nothing about
|
|
// the program, and the caller may retry with a new run ID.
|
|
//
|
|
// A run's outcome is compile_error or infrastructure_failure when that happened, otherwise the outcome
|
|
// of the first failed test in request order, otherwise accepted. A group's outcome is the outcome of
|
|
// its first failed test, otherwise accepted.
|
|
// Ref: #/components/schemas/RunOutcome
|
|
type RunOutcome string
|
|
|
|
const (
|
|
RunOutcomeAccepted RunOutcome = "accepted"
|
|
RunOutcomeWrongAnswer RunOutcome = "wrong_answer"
|
|
RunOutcomeCompileError RunOutcome = "compile_error"
|
|
RunOutcomeTimeLimitExceeded RunOutcome = "time_limit_exceeded"
|
|
RunOutcomeMemoryLimitExceeded RunOutcome = "memory_limit_exceeded"
|
|
RunOutcomeOutputLimitExceeded RunOutcome = "output_limit_exceeded"
|
|
RunOutcomeRuntimeError RunOutcome = "runtime_error"
|
|
RunOutcomeInfrastructureFailure RunOutcome = "infrastructure_failure"
|
|
)
|
|
|
|
// AllValues returns all RunOutcome values.
|
|
func (RunOutcome) AllValues() []RunOutcome {
|
|
return []RunOutcome{
|
|
RunOutcomeAccepted,
|
|
RunOutcomeWrongAnswer,
|
|
RunOutcomeCompileError,
|
|
RunOutcomeTimeLimitExceeded,
|
|
RunOutcomeMemoryLimitExceeded,
|
|
RunOutcomeOutputLimitExceeded,
|
|
RunOutcomeRuntimeError,
|
|
RunOutcomeInfrastructureFailure,
|
|
}
|
|
}
|
|
|
|
// MarshalText implements encoding.TextMarshaler.
|
|
func (s RunOutcome) MarshalText() ([]byte, error) {
|
|
switch s {
|
|
case RunOutcomeAccepted:
|
|
return []byte(s), nil
|
|
case RunOutcomeWrongAnswer:
|
|
return []byte(s), nil
|
|
case RunOutcomeCompileError:
|
|
return []byte(s), nil
|
|
case RunOutcomeTimeLimitExceeded:
|
|
return []byte(s), nil
|
|
case RunOutcomeMemoryLimitExceeded:
|
|
return []byte(s), nil
|
|
case RunOutcomeOutputLimitExceeded:
|
|
return []byte(s), nil
|
|
case RunOutcomeRuntimeError:
|
|
return []byte(s), nil
|
|
case RunOutcomeInfrastructureFailure:
|
|
return []byte(s), nil
|
|
default:
|
|
return nil, errors.Errorf("invalid value: %q", s)
|
|
}
|
|
}
|
|
|
|
// UnmarshalText implements encoding.TextUnmarshaler.
|
|
func (s *RunOutcome) UnmarshalText(data []byte) error {
|
|
switch RunOutcome(data) {
|
|
case RunOutcomeAccepted:
|
|
*s = RunOutcomeAccepted
|
|
return nil
|
|
case RunOutcomeWrongAnswer:
|
|
*s = RunOutcomeWrongAnswer
|
|
return nil
|
|
case RunOutcomeCompileError:
|
|
*s = RunOutcomeCompileError
|
|
return nil
|
|
case RunOutcomeTimeLimitExceeded:
|
|
*s = RunOutcomeTimeLimitExceeded
|
|
return nil
|
|
case RunOutcomeMemoryLimitExceeded:
|
|
*s = RunOutcomeMemoryLimitExceeded
|
|
return nil
|
|
case RunOutcomeOutputLimitExceeded:
|
|
*s = RunOutcomeOutputLimitExceeded
|
|
return nil
|
|
case RunOutcomeRuntimeError:
|
|
*s = RunOutcomeRuntimeError
|
|
return nil
|
|
case RunOutcomeInfrastructureFailure:
|
|
*s = RunOutcomeInfrastructureFailure
|
|
return nil
|
|
default:
|
|
return errors.Errorf("invalid value: %q", data)
|
|
}
|
|
}
|
|
|
|
// One source and its test groups. The request has no field for a candidate, account, attempt, task, or
|
|
// company; the backend maps a run ID to its own records.
|
|
// Ref: #/components/schemas/RunRequest
|
|
type RunRequest struct {
|
|
Language RunLanguage `json:"language"`
|
|
// Complete program text in UTF-8. The runner writes it to a read-only file inside the sandbox and
|
|
// never logs it.
|
|
Source string `json:"source"`
|
|
Limits RunLimits `json:"limits"`
|
|
// Test groups in evaluation order, for example one public group and three hidden groups. Group IDs are
|
|
// unique in a run.
|
|
Groups []TestGroup `json:"groups"`
|
|
}
|
|
|
|
// GetLanguage returns the value of Language.
|
|
func (s *RunRequest) GetLanguage() RunLanguage {
|
|
return s.Language
|
|
}
|
|
|
|
// GetSource returns the value of Source.
|
|
func (s *RunRequest) GetSource() string {
|
|
return s.Source
|
|
}
|
|
|
|
// GetLimits returns the value of Limits.
|
|
func (s *RunRequest) GetLimits() RunLimits {
|
|
return s.Limits
|
|
}
|
|
|
|
// GetGroups returns the value of Groups.
|
|
func (s *RunRequest) GetGroups() []TestGroup {
|
|
return s.Groups
|
|
}
|
|
|
|
// SetLanguage sets the value of Language.
|
|
func (s *RunRequest) SetLanguage(val RunLanguage) {
|
|
s.Language = val
|
|
}
|
|
|
|
// SetSource sets the value of Source.
|
|
func (s *RunRequest) SetSource(val string) {
|
|
s.Source = val
|
|
}
|
|
|
|
// SetLimits sets the value of Limits.
|
|
func (s *RunRequest) SetLimits(val RunLimits) {
|
|
s.Limits = val
|
|
}
|
|
|
|
// SetGroups sets the value of Groups.
|
|
func (s *RunRequest) SetGroups(val []TestGroup) {
|
|
s.Groups = val
|
|
}
|
|
|
|
// Ref: #/components/schemas/RunResult
|
|
type RunResult struct {
|
|
Outcome RunOutcome `json:"outcome"`
|
|
Compile OptCompileResult `json:"compile"`
|
|
// One result per requested group in request order. After compile_error or infrastructure_failure every
|
|
// group has that outcome and no tests.
|
|
Groups []GroupResult `json:"groups"`
|
|
// Wall-clock time of the whole run in the runner.
|
|
DurationMs int64 `json:"duration_ms"`
|
|
}
|
|
|
|
// GetOutcome returns the value of Outcome.
|
|
func (s *RunResult) GetOutcome() RunOutcome {
|
|
return s.Outcome
|
|
}
|
|
|
|
// GetCompile returns the value of Compile.
|
|
func (s *RunResult) GetCompile() OptCompileResult {
|
|
return s.Compile
|
|
}
|
|
|
|
// GetGroups returns the value of Groups.
|
|
func (s *RunResult) GetGroups() []GroupResult {
|
|
return s.Groups
|
|
}
|
|
|
|
// GetDurationMs returns the value of DurationMs.
|
|
func (s *RunResult) GetDurationMs() int64 {
|
|
return s.DurationMs
|
|
}
|
|
|
|
// SetOutcome sets the value of Outcome.
|
|
func (s *RunResult) SetOutcome(val RunOutcome) {
|
|
s.Outcome = val
|
|
}
|
|
|
|
// SetCompile sets the value of Compile.
|
|
func (s *RunResult) SetCompile(val OptCompileResult) {
|
|
s.Compile = val
|
|
}
|
|
|
|
// SetGroups sets the value of Groups.
|
|
func (s *RunResult) SetGroups(val []GroupResult) {
|
|
s.Groups = val
|
|
}
|
|
|
|
// SetDurationMs sets the value of DurationMs.
|
|
func (s *RunResult) SetDurationMs(val int64) {
|
|
s.DurationMs = val
|
|
}
|
|
|
|
// `running` until every group was evaluated or the run failed; `finished` when `result` is final.
|
|
// Ref: #/components/schemas/RunState
|
|
type RunState string
|
|
|
|
const (
|
|
RunStateRunning RunState = "running"
|
|
RunStateFinished RunState = "finished"
|
|
)
|
|
|
|
// AllValues returns all RunState values.
|
|
func (RunState) AllValues() []RunState {
|
|
return []RunState{
|
|
RunStateRunning,
|
|
RunStateFinished,
|
|
}
|
|
}
|
|
|
|
// MarshalText implements encoding.TextMarshaler.
|
|
func (s RunState) MarshalText() ([]byte, error) {
|
|
switch s {
|
|
case RunStateRunning:
|
|
return []byte(s), nil
|
|
case RunStateFinished:
|
|
return []byte(s), nil
|
|
default:
|
|
return nil, errors.Errorf("invalid value: %q", s)
|
|
}
|
|
}
|
|
|
|
// UnmarshalText implements encoding.TextUnmarshaler.
|
|
func (s *RunState) UnmarshalText(data []byte) error {
|
|
switch RunState(data) {
|
|
case RunStateRunning:
|
|
*s = RunStateRunning
|
|
return nil
|
|
case RunStateFinished:
|
|
*s = RunStateFinished
|
|
return nil
|
|
default:
|
|
return errors.Errorf("invalid value: %q", data)
|
|
}
|
|
}
|
|
|
|
// Ref: #/components/schemas/RunStatus
|
|
type RunStatus struct {
|
|
RunID uuid.UUID `json:"run_id"`
|
|
State RunState `json:"state"`
|
|
Result OptRunResult `json:"result"`
|
|
}
|
|
|
|
// GetRunID returns the value of RunID.
|
|
func (s *RunStatus) GetRunID() uuid.UUID {
|
|
return s.RunID
|
|
}
|
|
|
|
// GetState returns the value of State.
|
|
func (s *RunStatus) GetState() RunState {
|
|
return s.State
|
|
}
|
|
|
|
// GetResult returns the value of Result.
|
|
func (s *RunStatus) GetResult() OptRunResult {
|
|
return s.Result
|
|
}
|
|
|
|
// SetRunID sets the value of RunID.
|
|
func (s *RunStatus) SetRunID(val uuid.UUID) {
|
|
s.RunID = val
|
|
}
|
|
|
|
// SetState sets the value of State.
|
|
func (s *RunStatus) SetState(val RunState) {
|
|
s.State = val
|
|
}
|
|
|
|
// SetResult sets the value of Result.
|
|
func (s *RunStatus) SetResult(val OptRunResult) {
|
|
s.Result = val
|
|
}
|
|
|
|
// RunnerBusyHeaders wraps Problem with response headers.
|
|
type RunnerBusyHeaders struct {
|
|
RetryAfter int32
|
|
Response Problem
|
|
}
|
|
|
|
// GetRetryAfter returns the value of RetryAfter.
|
|
func (s *RunnerBusyHeaders) GetRetryAfter() int32 {
|
|
return s.RetryAfter
|
|
}
|
|
|
|
// GetResponse returns the value of Response.
|
|
func (s *RunnerBusyHeaders) GetResponse() Problem {
|
|
return s.Response
|
|
}
|
|
|
|
// SetRetryAfter sets the value of RetryAfter.
|
|
func (s *RunnerBusyHeaders) SetRetryAfter(val int32) {
|
|
s.RetryAfter = val
|
|
}
|
|
|
|
// SetResponse sets the value of Response.
|
|
func (s *RunnerBusyHeaders) SetResponse(val Problem) {
|
|
s.Response = val
|
|
}
|
|
|
|
func (*RunnerBusyHeaders) submitRunRes() {}
|
|
|
|
// Ref: #/components/schemas/RunnerHealthResponse
|
|
type RunnerHealthResponse struct {
|
|
Status RunnerHealthResponseStatus `json:"status"`
|
|
}
|
|
|
|
// GetStatus returns the value of Status.
|
|
func (s *RunnerHealthResponse) GetStatus() RunnerHealthResponseStatus {
|
|
return s.Status
|
|
}
|
|
|
|
// SetStatus sets the value of Status.
|
|
func (s *RunnerHealthResponse) SetStatus(val RunnerHealthResponseStatus) {
|
|
s.Status = val
|
|
}
|
|
|
|
type RunnerHealthResponseStatus string
|
|
|
|
const (
|
|
RunnerHealthResponseStatusOk RunnerHealthResponseStatus = "ok"
|
|
)
|
|
|
|
// AllValues returns all RunnerHealthResponseStatus values.
|
|
func (RunnerHealthResponseStatus) AllValues() []RunnerHealthResponseStatus {
|
|
return []RunnerHealthResponseStatus{
|
|
RunnerHealthResponseStatusOk,
|
|
}
|
|
}
|
|
|
|
// MarshalText implements encoding.TextMarshaler.
|
|
func (s RunnerHealthResponseStatus) MarshalText() ([]byte, error) {
|
|
switch s {
|
|
case RunnerHealthResponseStatusOk:
|
|
return []byte(s), nil
|
|
default:
|
|
return nil, errors.Errorf("invalid value: %q", s)
|
|
}
|
|
}
|
|
|
|
// UnmarshalText implements encoding.TextUnmarshaler.
|
|
func (s *RunnerHealthResponseStatus) UnmarshalText(data []byte) error {
|
|
switch RunnerHealthResponseStatus(data) {
|
|
case RunnerHealthResponseStatusOk:
|
|
*s = RunnerHealthResponseStatusOk
|
|
return nil
|
|
default:
|
|
return errors.Errorf("invalid value: %q", data)
|
|
}
|
|
}
|
|
|
|
// Ref: #/components/schemas/RunnerReadinessResponse
|
|
type RunnerReadinessResponse struct {
|
|
Status RunnerReadinessResponseStatus `json:"status"`
|
|
}
|
|
|
|
// GetStatus returns the value of Status.
|
|
func (s *RunnerReadinessResponse) GetStatus() RunnerReadinessResponseStatus {
|
|
return s.Status
|
|
}
|
|
|
|
// SetStatus sets the value of Status.
|
|
func (s *RunnerReadinessResponse) SetStatus(val RunnerReadinessResponseStatus) {
|
|
s.Status = val
|
|
}
|
|
|
|
type RunnerReadinessResponseStatus string
|
|
|
|
const (
|
|
RunnerReadinessResponseStatusReady RunnerReadinessResponseStatus = "ready"
|
|
RunnerReadinessResponseStatusNotReady RunnerReadinessResponseStatus = "not_ready"
|
|
)
|
|
|
|
// AllValues returns all RunnerReadinessResponseStatus values.
|
|
func (RunnerReadinessResponseStatus) AllValues() []RunnerReadinessResponseStatus {
|
|
return []RunnerReadinessResponseStatus{
|
|
RunnerReadinessResponseStatusReady,
|
|
RunnerReadinessResponseStatusNotReady,
|
|
}
|
|
}
|
|
|
|
// MarshalText implements encoding.TextMarshaler.
|
|
func (s RunnerReadinessResponseStatus) MarshalText() ([]byte, error) {
|
|
switch s {
|
|
case RunnerReadinessResponseStatusReady:
|
|
return []byte(s), nil
|
|
case RunnerReadinessResponseStatusNotReady:
|
|
return []byte(s), nil
|
|
default:
|
|
return nil, errors.Errorf("invalid value: %q", s)
|
|
}
|
|
}
|
|
|
|
// UnmarshalText implements encoding.TextUnmarshaler.
|
|
func (s *RunnerReadinessResponseStatus) UnmarshalText(data []byte) error {
|
|
switch RunnerReadinessResponseStatus(data) {
|
|
case RunnerReadinessResponseStatusReady:
|
|
*s = RunnerReadinessResponseStatusReady
|
|
return nil
|
|
case RunnerReadinessResponseStatusNotReady:
|
|
*s = RunnerReadinessResponseStatusNotReady
|
|
return nil
|
|
default:
|
|
return errors.Errorf("invalid value: %q", data)
|
|
}
|
|
}
|
|
|
|
type SubmitRunAccepted RunStatus
|
|
|
|
func (*SubmitRunAccepted) submitRunRes() {}
|
|
|
|
type SubmitRunOK RunStatus
|
|
|
|
func (*SubmitRunOK) submitRunRes() {}
|
|
|
|
// The limit that stopped a test: CPU time, wall-clock time, memory, standard output, or the number of
|
|
// processes and threads.
|
|
// Ref: #/components/schemas/TerminationLimit
|
|
type TerminationLimit string
|
|
|
|
const (
|
|
TerminationLimitCPUTime TerminationLimit = "cpu_time"
|
|
TerminationLimitWallTime TerminationLimit = "wall_time"
|
|
TerminationLimitMemory TerminationLimit = "memory"
|
|
TerminationLimitOutput TerminationLimit = "output"
|
|
TerminationLimitProcesses TerminationLimit = "processes"
|
|
)
|
|
|
|
// AllValues returns all TerminationLimit values.
|
|
func (TerminationLimit) AllValues() []TerminationLimit {
|
|
return []TerminationLimit{
|
|
TerminationLimitCPUTime,
|
|
TerminationLimitWallTime,
|
|
TerminationLimitMemory,
|
|
TerminationLimitOutput,
|
|
TerminationLimitProcesses,
|
|
}
|
|
}
|
|
|
|
// MarshalText implements encoding.TextMarshaler.
|
|
func (s TerminationLimit) MarshalText() ([]byte, error) {
|
|
switch s {
|
|
case TerminationLimitCPUTime:
|
|
return []byte(s), nil
|
|
case TerminationLimitWallTime:
|
|
return []byte(s), nil
|
|
case TerminationLimitMemory:
|
|
return []byte(s), nil
|
|
case TerminationLimitOutput:
|
|
return []byte(s), nil
|
|
case TerminationLimitProcesses:
|
|
return []byte(s), nil
|
|
default:
|
|
return nil, errors.Errorf("invalid value: %q", s)
|
|
}
|
|
}
|
|
|
|
// UnmarshalText implements encoding.TextUnmarshaler.
|
|
func (s *TerminationLimit) UnmarshalText(data []byte) error {
|
|
switch TerminationLimit(data) {
|
|
case TerminationLimitCPUTime:
|
|
*s = TerminationLimitCPUTime
|
|
return nil
|
|
case TerminationLimitWallTime:
|
|
*s = TerminationLimitWallTime
|
|
return nil
|
|
case TerminationLimitMemory:
|
|
*s = TerminationLimitMemory
|
|
return nil
|
|
case TerminationLimitOutput:
|
|
*s = TerminationLimitOutput
|
|
return nil
|
|
case TerminationLimitProcesses:
|
|
*s = TerminationLimitProcesses
|
|
return nil
|
|
default:
|
|
return errors.Errorf("invalid value: %q", data)
|
|
}
|
|
}
|
|
|
|
// Ref: #/components/schemas/TestCase
|
|
type TestCase struct {
|
|
ID TestKey `json:"id"`
|
|
// UTF-8 text written to the standard input of the program.
|
|
Input string `json:"input"`
|
|
// UTF-8 text the checker compares with the standard output.
|
|
ExpectedOutput string `json:"expected_output"`
|
|
}
|
|
|
|
// GetID returns the value of ID.
|
|
func (s *TestCase) GetID() TestKey {
|
|
return s.ID
|
|
}
|
|
|
|
// GetInput returns the value of Input.
|
|
func (s *TestCase) GetInput() string {
|
|
return s.Input
|
|
}
|
|
|
|
// GetExpectedOutput returns the value of ExpectedOutput.
|
|
func (s *TestCase) GetExpectedOutput() string {
|
|
return s.ExpectedOutput
|
|
}
|
|
|
|
// SetID sets the value of ID.
|
|
func (s *TestCase) SetID(val TestKey) {
|
|
s.ID = val
|
|
}
|
|
|
|
// SetInput sets the value of Input.
|
|
func (s *TestCase) SetInput(val string) {
|
|
s.Input = val
|
|
}
|
|
|
|
// SetExpectedOutput sets the value of ExpectedOutput.
|
|
func (s *TestCase) SetExpectedOutput(val string) {
|
|
s.ExpectedOutput = val
|
|
}
|
|
|
|
// Ref: #/components/schemas/TestGroup
|
|
type TestGroup struct {
|
|
ID TestKey `json:"id"`
|
|
Visibility TestVisibility `json:"visibility"`
|
|
Checker Checker `json:"checker"`
|
|
// Tests in evaluation order. Test IDs are unique in a group. A group stops at its first failed test.
|
|
Tests []TestCase `json:"tests"`
|
|
}
|
|
|
|
// GetID returns the value of ID.
|
|
func (s *TestGroup) GetID() TestKey {
|
|
return s.ID
|
|
}
|
|
|
|
// GetVisibility returns the value of Visibility.
|
|
func (s *TestGroup) GetVisibility() TestVisibility {
|
|
return s.Visibility
|
|
}
|
|
|
|
// GetChecker returns the value of Checker.
|
|
func (s *TestGroup) GetChecker() Checker {
|
|
return s.Checker
|
|
}
|
|
|
|
// GetTests returns the value of Tests.
|
|
func (s *TestGroup) GetTests() []TestCase {
|
|
return s.Tests
|
|
}
|
|
|
|
// SetID sets the value of ID.
|
|
func (s *TestGroup) SetID(val TestKey) {
|
|
s.ID = val
|
|
}
|
|
|
|
// SetVisibility sets the value of Visibility.
|
|
func (s *TestGroup) SetVisibility(val TestVisibility) {
|
|
s.Visibility = val
|
|
}
|
|
|
|
// SetChecker sets the value of Checker.
|
|
func (s *TestGroup) SetChecker(val Checker) {
|
|
s.Checker = val
|
|
}
|
|
|
|
// SetTests sets the value of Tests.
|
|
func (s *TestGroup) SetTests(val []TestCase) {
|
|
s.Tests = val
|
|
}
|
|
|
|
type TestKey string
|
|
|
|
// Ref: #/components/schemas/TestResult
|
|
type TestResult struct {
|
|
ID TestKey `json:"id"`
|
|
Outcome RunOutcome `json:"outcome"`
|
|
// CPU time of every process of the test.
|
|
TimeMs int64 `json:"time_ms"`
|
|
WallTimeMs int64 `json:"wall_time_ms"`
|
|
// Peak memory of the test in KiB: the cgroup high-water mark of every process of the test, including
|
|
// the sandbox supervisor process and file cache charged to the test.
|
|
MemoryKB int64 `json:"memory_kb"`
|
|
// Exit status when the program exited normally.
|
|
ExitCode OptInt32 `json:"exit_code"`
|
|
// Signal number when the program was killed by a signal.
|
|
Signal OptInt32 `json:"signal"`
|
|
Limit OptTerminationLimit `json:"limit"`
|
|
// Truncated standard error of a failed public test. Hidden tests never carry it.
|
|
Diagnostic OptString `json:"diagnostic"`
|
|
}
|
|
|
|
// GetID returns the value of ID.
|
|
func (s *TestResult) GetID() TestKey {
|
|
return s.ID
|
|
}
|
|
|
|
// GetOutcome returns the value of Outcome.
|
|
func (s *TestResult) GetOutcome() RunOutcome {
|
|
return s.Outcome
|
|
}
|
|
|
|
// GetTimeMs returns the value of TimeMs.
|
|
func (s *TestResult) GetTimeMs() int64 {
|
|
return s.TimeMs
|
|
}
|
|
|
|
// GetWallTimeMs returns the value of WallTimeMs.
|
|
func (s *TestResult) GetWallTimeMs() int64 {
|
|
return s.WallTimeMs
|
|
}
|
|
|
|
// GetMemoryKB returns the value of MemoryKB.
|
|
func (s *TestResult) GetMemoryKB() int64 {
|
|
return s.MemoryKB
|
|
}
|
|
|
|
// GetExitCode returns the value of ExitCode.
|
|
func (s *TestResult) GetExitCode() OptInt32 {
|
|
return s.ExitCode
|
|
}
|
|
|
|
// GetSignal returns the value of Signal.
|
|
func (s *TestResult) GetSignal() OptInt32 {
|
|
return s.Signal
|
|
}
|
|
|
|
// GetLimit returns the value of Limit.
|
|
func (s *TestResult) GetLimit() OptTerminationLimit {
|
|
return s.Limit
|
|
}
|
|
|
|
// GetDiagnostic returns the value of Diagnostic.
|
|
func (s *TestResult) GetDiagnostic() OptString {
|
|
return s.Diagnostic
|
|
}
|
|
|
|
// SetID sets the value of ID.
|
|
func (s *TestResult) SetID(val TestKey) {
|
|
s.ID = val
|
|
}
|
|
|
|
// SetOutcome sets the value of Outcome.
|
|
func (s *TestResult) SetOutcome(val RunOutcome) {
|
|
s.Outcome = val
|
|
}
|
|
|
|
// SetTimeMs sets the value of TimeMs.
|
|
func (s *TestResult) SetTimeMs(val int64) {
|
|
s.TimeMs = val
|
|
}
|
|
|
|
// SetWallTimeMs sets the value of WallTimeMs.
|
|
func (s *TestResult) SetWallTimeMs(val int64) {
|
|
s.WallTimeMs = val
|
|
}
|
|
|
|
// SetMemoryKB sets the value of MemoryKB.
|
|
func (s *TestResult) SetMemoryKB(val int64) {
|
|
s.MemoryKB = val
|
|
}
|
|
|
|
// SetExitCode sets the value of ExitCode.
|
|
func (s *TestResult) SetExitCode(val OptInt32) {
|
|
s.ExitCode = val
|
|
}
|
|
|
|
// SetSignal sets the value of Signal.
|
|
func (s *TestResult) SetSignal(val OptInt32) {
|
|
s.Signal = val
|
|
}
|
|
|
|
// SetLimit sets the value of Limit.
|
|
func (s *TestResult) SetLimit(val OptTerminationLimit) {
|
|
s.Limit = val
|
|
}
|
|
|
|
// SetDiagnostic sets the value of Diagnostic.
|
|
func (s *TestResult) SetDiagnostic(val OptString) {
|
|
s.Diagnostic = val
|
|
}
|
|
|
|
// `public` tests may be shown to the person who wrote the source; their results may carry a diagnostic
|
|
// excerpt. `hidden` results never carry program output or diagnostics.
|
|
// Ref: #/components/schemas/TestVisibility
|
|
type TestVisibility string
|
|
|
|
const (
|
|
TestVisibilityPublic TestVisibility = "public"
|
|
TestVisibilityHidden TestVisibility = "hidden"
|
|
)
|
|
|
|
// AllValues returns all TestVisibility values.
|
|
func (TestVisibility) AllValues() []TestVisibility {
|
|
return []TestVisibility{
|
|
TestVisibilityPublic,
|
|
TestVisibilityHidden,
|
|
}
|
|
}
|
|
|
|
// MarshalText implements encoding.TextMarshaler.
|
|
func (s TestVisibility) MarshalText() ([]byte, error) {
|
|
switch s {
|
|
case TestVisibilityPublic:
|
|
return []byte(s), nil
|
|
case TestVisibilityHidden:
|
|
return []byte(s), nil
|
|
default:
|
|
return nil, errors.Errorf("invalid value: %q", s)
|
|
}
|
|
}
|
|
|
|
// UnmarshalText implements encoding.TextUnmarshaler.
|
|
func (s *TestVisibility) UnmarshalText(data []byte) error {
|
|
switch TestVisibility(data) {
|
|
case TestVisibilityPublic:
|
|
*s = TestVisibilityPublic
|
|
return nil
|
|
case TestVisibilityHidden:
|
|
*s = TestVisibilityHidden
|
|
return nil
|
|
default:
|
|
return errors.Errorf("invalid value: %q", data)
|
|
}
|
|
}
|