api

package
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Headers map[string]string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(endpoint string, options ...ClientOption) *Client

NewClient returns new API client.

func (*Client) CreateCompiler

func (c *Client) CreateCompiler(ctx context.Context, form CreateCompilerForm) (Compiler, error)

func (*Client) CreateContestParticipant

func (c *Client) CreateContestParticipant(
	ctx context.Context,
	contest int64,
	form CreateContestParticipantForm,
) (ContestParticipant, error)

func (*Client) CreateProblem

func (c *Client) CreateProblem(ctx context.Context, form CreateProblemForm) (Problem, error)

func (*Client) CreateRole

func (c *Client) CreateRole(
	ctx context.Context, name string,
) (Role, error)

func (*Client) CreateSetting

func (c *Client) CreateSetting(ctx context.Context, form CreateSettingForm) (Setting, error)

func (*Client) CreateUserRole

func (c *Client) CreateUserRole(
	ctx context.Context, login string, role string,
) (Role, error)

func (*Client) DeleteCompiler

func (c *Client) DeleteCompiler(ctx context.Context, id int64) (Compiler, error)

func (*Client) DeleteProblem

func (c *Client) DeleteProblem(ctx context.Context, id int64) (Problem, error)

func (*Client) DeleteRole

func (c *Client) DeleteRole(
	ctx context.Context, name any,
) (Role, error)

func (*Client) DeleteUserRole

func (c *Client) DeleteUserRole(
	ctx context.Context, login string, role string,
) (Role, error)

func (*Client) Health

func (c *Client) Health(ctx context.Context) error

func (*Client) Locale

func (c *Client) Locale(ctx context.Context) (Locale, error)

func (*Client) Login

func (c *Client) Login(ctx context.Context, login, password string) (Session, error)

func (*Client) Logout

func (c *Client) Logout(ctx context.Context) error

func (*Client) ObserveCompilers

func (c *Client) ObserveCompilers(ctx context.Context) (Compilers, error)

func (*Client) ObserveContest

func (c *Client) ObserveContest(
	ctx context.Context, id int64,
) (Contest, error)

func (*Client) ObserveContestSolution

func (c *Client) ObserveContestSolution(
	ctx context.Context, id int64, solutionID int64,
) (ContestSolution, error)

func (*Client) ObserveContestSolutions

func (c *Client) ObserveContestSolutions(
	ctx context.Context, id int64,
) (ContestSolutions, error)

func (*Client) ObserveContestStandings

func (c *Client) ObserveContestStandings(
	ctx context.Context, id int64,
) (ContestStandings, error)

func (*Client) ObserveRoles

func (c *Client) ObserveRoles(ctx context.Context) (Roles, error)

func (*Client) ObserveScopeUsers

func (c *Client) ObserveScopeUsers(ctx context.Context, scope int64) (ScopeUsers, error)

func (*Client) ObserveSettings

func (c *Client) ObserveSettings(ctx context.Context) (Settings, error)

func (*Client) ObserveUserRoles

func (c *Client) ObserveUserRoles(
	ctx context.Context, login string,
) (Roles, error)

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) error

func (*Client) Register

func (c *Client) Register(
	ctx context.Context, form RegisterUserForm,
) (User, error)

func (*Client) SubmitContestSolution

func (c *Client) SubmitContestSolution(
	ctx context.Context, contest int64, problem string, form SubmitSolutionForm,
) (ContestSolution, error)

func (*Client) UpdateCompiler

func (c *Client) UpdateCompiler(ctx context.Context, id int64, form UpdateCompilerForm) (Compiler, error)

func (*Client) UpdateProblem

func (c *Client) UpdateProblem(ctx context.Context, id int64, form UpdateProblemForm) (Problem, error)

func (*Client) UpdateSetting

func (c *Client) UpdateSetting(ctx context.Context, id int64, form UpdateSettingForm) (Setting, error)

type ClientOption

type ClientOption func(*Client)

func WithSessionCookie

func WithSessionCookie(value string) ClientOption

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOption

func WithTransport

func WithTransport(transport *http.Transport) ClientOption

type Compiler

type Compiler struct {
	ID     int64  `json:"id"`
	Name   string `json:"name"`
	Config JSON   `json:"config"`
}

type Compilers

type Compilers struct {
	Compilers []Compiler `json:"compilers"`
}

type Contest

type Contest struct {
	ID                  int64                `json:"id"`
	Title               string               `json:"title"`
	BeginTime           NInt64               `json:"begin_time,omitempty"`
	Duration            int                  `json:"duration,omitempty"`
	Permissions         []string             `json:"permissions,omitempty"`
	EnableRegistration  bool                 `json:"enable_registration"`
	EnableUpsolving     bool                 `json:"enable_upsolving"`
	EnableObserving     bool                 `json:"enable_observing,omitempty"`
	FreezeBeginDuration int                  `json:"freeze_begin_duration,omitempty"`
	FreezeEndTime       NInt64               `json:"freeze_end_time,omitempty"`
	StandingsKind       models.StandingsKind `json:"standings_kind,omitempty"`
	State               *ContestState        `json:"state,omitempty"`
}

type ContestMessage

type ContestMessage struct {
	ID          int64               `json:"id"`
	ParentID    int64               `json:"parent_id,omitempty"`
	Kind        string              `json:"kind"`
	Title       string              `json:"title,omitempty"`
	Description string              `json:"description,omitempty"`
	Participant *ContestParticipant `json:"participant,omitempty"`
}

type ContestMessages

type ContestMessages struct {
	Messages []ContestMessage `json:"messages"`
}

type ContestParticipant

type ContestParticipant struct {
	ID        int64      `json:"id,omitempty"`
	User      *User      `json:"user,omitempty"`
	ScopeUser *ScopeUser `json:"scope_user,omitempty"`
	Scope     *Scope     `json:"scope,omitempty"`
	ContestID int64      `json:"contest_id,omitempty"`
	// Kind contains kind.
	Kind models.ParticipantKind `json:"kind"`
}

type ContestParticipants

type ContestParticipants struct {
	Participants []ContestParticipant `json:"participants"`
}

type ContestProblem

type ContestProblem struct {
	ID        int64    `json:"id"`
	ContestID int64    `json:"contest_id"`
	Code      string   `json:"code"`
	Problem   Problem  `json:"problem"`
	Points    *int     `json:"points,omitempty"`
	Locales   []string `json:"locales,omitempty"`
	Solved    *bool    `json:"solved,omitempty"`
}

type ContestProblems

type ContestProblems struct {
	Problems []ContestProblem `json:"problems"`
}

type ContestSolution

type ContestSolution struct {
	ID          int64               `json:"id"`
	ContestID   int64               `json:"contest_id"`
	Solution    Solution            `json:"solution"`
	Problem     *ContestProblem     `json:"problem,omitempty"`
	Participant *ContestParticipant `json:"participant,omitempty"`
}

type ContestSolutions

type ContestSolutions struct {
	Solutions   []ContestSolution `json:"solutions"`
	NextBeginID int64             `json:"next_begin_id,omitempty"`
}

ContestSolutions represents contest solutions response.

type ContestStandings

type ContestStandings struct {
	Kind    string                   `json:"kind"`
	Columns []ContestStandingsColumn `json:"columns,omitempty"`
	Rows    []ContestStandingsRow    `json:"rows,omitempty"`
	Frozen  bool                     `json:"frozen,omitempty"`
}

type ContestStandingsCell

type ContestStandingsCell struct {
	Column  int     `json:"column"`
	Verdict string  `json:"verdict"`
	Points  float64 `json:"points,omitempty"`
	Attempt int     `json:"attempt"`
	Time    *int64  `json:"time,omitempty"`
}

type ContestStandingsColumn

type ContestStandingsColumn struct {
	Code              string `json:"code"`
	Points            *int   `json:"points,omitempty"`
	TotalSolutions    int    `json:"total_solutions,omitempty"`
	AcceptedSolutions int    `json:"accepted_solutions,omitempty"`
}

type ContestStandingsRow

type ContestStandingsRow struct {
	Participant ContestParticipant     `json:"participant,omitempty"`
	Score       float64                `json:"score"`
	Penalty     *int64                 `json:"penalty,omitempty"`
	Place       int                    `json:"place,omitempty"`
	Cells       []ContestStandingsCell `json:"cells,omitempty"`
}

type ContestState

type ContestState struct {
	Stage string `json:"stage"`
	// Participant contains effective participant.
	Participant *ContestParticipant `json:"participant,omitempty"`
}

type Contests

type Contests struct {
	Contests []Contest `json:"contests"`
}

type CreateCompilerForm

type CreateCompilerForm struct {
	UpdateCompilerForm
}

func (*CreateCompilerForm) Update

func (f *CreateCompilerForm) Update(c echo.Context, compiler *models.Compiler) error

type CreateContestMessageForm

type CreateContestMessageForm struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	ParentID    *int64 `json:"parent_id"`
}

func (*CreateContestMessageForm) Update

func (f *CreateContestMessageForm) Update(
	c echo.Context, o *models.ContestMessage,
	messages models.ContestMessageStore,
) error

type CreateContestParticipantForm

type CreateContestParticipantForm struct {
	UserID      *int64                 `json:"user_id"`
	UserLogin   *string                `json:"user_login"`
	ScopeUserID *int64                 `json:"scope_user_id"`
	ScopeID     *int64                 `json:"scope_id"`
	GroupID     *int64                 `json:"group_id"`
	Kind        models.ParticipantKind `json:"kind"`
}

func (CreateContestParticipantForm) Update

func (f CreateContestParticipantForm) Update(
	c echo.Context, participant *models.ContestParticipant, core *core.Core,
) *errorResponse

type CreateProblemForm

type CreateProblemForm struct {
	UpdateProblemForm
}

func (*CreateProblemForm) Update

func (f *CreateProblemForm) Update(c echo.Context, problem *models.Problem) error

type CreateSettingForm

type CreateSettingForm struct {
	UpdateSettingForm
}

func (*CreateSettingForm) Update

func (f *CreateSettingForm) Update(c echo.Context, o *models.Setting) error

type FileReader

type FileReader = managers.FileReader

type JSON

type JSON struct {
	models.JSON
}

func (*JSON) UnmarshalParam

func (v *JSON) UnmarshalParam(data string) error

type Locale

type Locale struct {
	Name          string         `json:"name,omitempty"`
	Localizations []Localization `json:"localizations,omitempty"`
}

type Localization

type Localization struct {
	Key  string `json:"key"`
	Text string `json:"text"`
}

type NInt64

type NInt64 = models.NInt64

type NString

type NString = models.NString

type ObserveContestStandingsForm

type ObserveContestStandingsForm struct {
	IgnoreFreeze bool `query:"ignore_freeze"`
	OnlyOfficial bool `query:"only_official"`
}

type Problem

type Problem struct {
	ID          int64                 `json:"id"`
	Title       string                `json:"title"`
	Statement   *ProblemStatement     `json:"statement,omitempty"`
	Config      *models.ProblemConfig `json:"config,omitempty"`
	Permissions []string              `json:"permissions,omitempty"`
	LastTask    *ProblemTask          `json:"last_task,omitempty"`
}

type ProblemStatement

type ProblemStatement = models.ProblemStatementConfig

type ProblemTask

type ProblemTask struct {
	Status string `json:"status"`
	Error  string `json:"error,omitempty"`
}

type Problems

type Problems struct {
	Problems []Problem `json:"problems"`
}

type RebuildProblemForm

type RebuildProblemForm struct {
	Compile bool `json:"compile"`
}

type RegisterUserForm

type RegisterUserForm struct {
	Login      string `json:"login" form:"login"`
	Email      string `json:"email" form:"email"`
	Password   string `json:"password" form:"password"`
	FirstName  string `json:"first_name" form:"first_name"`
	LastName   string `json:"last_name" form:"last_name"`
	MiddleName string `json:"middle_name" form:"middle_name"`
}

RegisterUserForm represents form for register new user.

func (RegisterUserForm) Update

func (f RegisterUserForm) Update(
	c echo.Context, user *models.User, store *models.UserStore,
) error

type Role

type Role struct {
	// ID contains role ID.
	ID int64 `json:"id"`
	// Name contains role name.
	Name string `json:"name"`
	//
	BuiltIn bool `json:"built_in,omitempty"`
}

Role represents role.

type Roles

type Roles struct {
	Roles []Role `json:"roles"`
}

Roles represents roles response.

type Scope

type Scope struct {
	ID    int64  `json:"id"`
	Title string `json:"title"`
}

type ScopeUser

type ScopeUser struct {
	ID       int64  `json:"id"`
	Login    string `json:"login"`
	Title    string `json:"title,omitempty"`
	Password string `json:"password,omitempty"`
}

type ScopeUsers

type ScopeUsers struct {
	Users []ScopeUser `json:"users"`
}

type Scopes

type Scopes struct {
	Scopes []Scope `json:"scopes"`
}

type Session

type Session struct {
	// ID contains session ID.
	ID int64 `json:"id"`
	// CreateTime contains session create time.
	CreateTime int64 `json:"create_time,omitempty"`
	// ExpireTime contains session expire time.
	ExpireTime int64 `json:"expire_time,omitempty"`
}

Session represents session.

type Sessions

type Sessions struct {
	Sessions []Session `json:"sessions"`
}

Sessions represents sessions response.

type Setting

type Setting struct {
	ID    int64  `json:"id"`
	Key   string `json:"key"`
	Value string `json:"value"`
}

type Settings

type Settings struct {
	Settings []Setting `json:"settings"`
}

type Solution

type Solution struct {
	ID         int64           `json:"id"`
	Problem    *Problem        `json:"problem"`
	Compiler   *Compiler       `json:"compiler"`
	User       *User           `json:"user,omitempty"`
	ScopeUser  *ScopeUser      `json:"scope_user,omitempty"`
	Content    string          `json:"content,omitempty"`
	Report     *SolutionReport `json:"report"`
	CreateTime int64           `json:"create_time"`
}

type SolutionReport

type SolutionReport struct {
	Verdict    string       `json:"verdict"`
	Points     *float64     `json:"points,omitempty"`
	UsedTime   int64        `json:"used_time,omitempty"`
	UsedMemory int64        `json:"used_memory,omitempty"`
	Tests      []TestReport `json:"tests,omitempty"`
	TestNumber int          `json:"test_number,omitempty"`
	CompileLog string       `json:"compile_log,omitempty"`
}

type Solutions

type Solutions struct {
	Solutions   []Solution `json:"solutions"`
	NextBeginID int64      `json:"next_begin_id,omitempty"`
}

type Status

type Status struct {
	User        *User      `json:"user,omitempty"`
	ScopeUser   *ScopeUser `json:"scope_user,omitempty"`
	Session     *Session   `json:"session,omitempty"`
	Permissions []string   `json:"permissions"`
	Locale      string     `json:"locale,omitempty"`
}

Status represents current authorization status.

type SubmitContestQuestionForm

type SubmitContestQuestionForm struct {
	Title       string `json:"title"`
	Description string `json:"description"`
}

func (SubmitContestQuestionForm) Update

func (f SubmitContestQuestionForm) Update(
	c echo.Context, o *models.ContestMessage,
) error

type SubmitSolutionForm

type SubmitSolutionForm struct {
	CompilerID int64   `form:"compiler_id" json:"compiler_id"`
	Content    *string `form:"content" json:"content,omitempty"`
	// ContentFile will be initialized with the content if it is provided.
	ContentFile *FileReader `json:"-"`
}

func (*SubmitSolutionForm) Parse

func (f *SubmitSolutionForm) Parse(c echo.Context) error

type TestReport

type TestReport struct {
	Verdict    models.Verdict `json:"verdict"`
	UsedTime   int64          `json:"used_time,omitempty"`
	UsedMemory int64          `json:"used_memory,omitempty"`
	CheckLog   string         `json:"check_log,omitempty"`
	Input      string         `json:"input,omitempty"`
	Output     string         `json:"output,omitempty"`
}

type UpdateCompilerForm

type UpdateCompilerForm struct {
	Name      *string     `form:"name" json:"name"`
	Config    JSON        `form:"config" json:"config"`
	ImageFile *FileReader `json:"-"`
}

func (*UpdateCompilerForm) Close

func (f *UpdateCompilerForm) Close() error

func (*UpdateCompilerForm) Parse

func (f *UpdateCompilerForm) Parse(c echo.Context) error

func (*UpdateCompilerForm) Update

func (f *UpdateCompilerForm) Update(c echo.Context, compiler *models.Compiler) error

type UpdateProblemForm

type UpdateProblemForm struct {
	Title       *string     `json:"title" form:"title"`
	OwnerID     *int64      `json:"owner_id" form:"owner_id"`
	PackageFile *FileReader `json:"-"`
}

func (*UpdateProblemForm) Close

func (f *UpdateProblemForm) Close() error

func (*UpdateProblemForm) Parse

func (f *UpdateProblemForm) Parse(c echo.Context) error

func (*UpdateProblemForm) Update

func (f *UpdateProblemForm) Update(c echo.Context, problem *models.Problem) error

type UpdateSettingForm

type UpdateSettingForm struct {
	Key   *string `json:"key"`
	Value *string `json:"value"`
}

func (*UpdateSettingForm) Update

func (f *UpdateSettingForm) Update(c echo.Context, o *models.Setting) error

type User

type User struct {
	// ID contains user ID.
	ID int64 `json:"id"`
	// Login contains user login.
	Login string `json:"login"`
	// Email contains user email.
	Email string `json:"email,omitempty"`
	// Status contains user status.
	Status string `json:"status,omitempty"`
	// FirstName contains first name.
	FirstName string `json:"first_name,omitempty"`
	// LastName contains last name.
	LastName string `json:"last_name,omitempty"`
	// MiddleName contains middle name.
	MiddleName string `json:"middle_name,omitempty"`
	// UnconfirmedEmail contains email address that currently unconfirmed.
	UnconfirmedEmail string `json:"unconfirmed_email,omitempty"`
}

User represents user.

type View

type View struct {
	// contains filtered or unexported fields
}

View represents API view.

func NewView

func NewView(core *core.Core) *View

NewView returns a new instance of view.

func (*View) ObserveCompilers

func (v *View) ObserveCompilers(c echo.Context) error

ObserveCompilers returns list of available compilers.

func (*View) Register

func (v *View) Register(g *echo.Group)

Register registers handlers in specified group.

func (*View) RegisterSocket

func (v *View) RegisterSocket(g *echo.Group)

func (*View) StartDaemons

func (v *View) StartDaemons()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL