database

package
v0.0.0-...-35ac193 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2019 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAttemptCount

func GetAttemptCount(challenge *Challenge, userID string) (int, error)

GetAttemptCount gets amount of live attempts for a challenge and user

Types

type APIClient

type APIClient struct {
	ID           string   `bson:"id"`
	Name         string   `bson:"name"`
	Trusted      bool     `bson:"trusted"`
	Scopes       []string `bson:"scopes"`
	RedirectURLs []string `bson:"redirect_urls"`
	Secret       string   `bson:"secret"`
}

APIClient is the data stored about an api client in the database

func GetAPIClientByID

func GetAPIClientByID(id string) (*APIClient, error)

GetAPIClientByID an api client from the database by id

func (*APIClient) Save

func (client *APIClient) Save() error

Save api client data to the database

type Attempt

type Attempt struct {
	ID        string `bson:"id"`
	User      string `bson:"user"`
	Challenge string `bson:"challenge"`

	CreationDate   time.Time `bson:"creation_date"`
	TimeoutDate    time.Time `bson:"timeout_date"`
	SubmissionDate time.Time `bson:"submission_date"`

	Input          *AttemptInput  `bson:"input"`
	ExpectedOutput *AttemptOutput `bson:"expected_output"`
	RecievedOutput *AttemptOutput `bson:"recieved_output"`
}

Attempt is the data stored about an attempt in the database

func GetAttemptByID

func GetAttemptByID(id string) (*Attempt, error)

GetAttemptByID an attempt from the database by id

func GetAttemptsByUser

func GetAttemptsByUser(userID string, onlyForChallenge string, limit int, skip int) ([]*Attempt, error)

GetAttemptsByUser gets all attempts by a certain user

func (*Attempt) Save

func (attempt *Attempt) Save() error

Save user data to the database

type AttemptInput

type AttemptInput struct {
	Arguments []string `json:"arguments"`
	Stdin     string   `json:"stdin"`
}

AttemptInput is the input data for a specifc attempt

type AttemptOutput

type AttemptOutput struct {
	Stdout string `json:"stdout"`
	Stderr string `json:"stderr"`
}

AttemptOutput is the output data for a specifc attempt

type Challenge

type Challenge struct {
	ID              string        `bson:"id"`
	Name            string        `bson:"name"`
	Description     string        `bson:"description"`
	Generator       string        `bson:"generator"`
	MaxLiveAttempts int           `bson:"max_live_attempts"`
	Timeout         time.Duration `bson:"timeout"`
	PublishDate     time.Time     `bson:"publish_date"`
	ResultsDate     time.Time     `bson:"results_date"`
}

Challenge is the data stored about a challenge in the database

func GetChallengeByID

func GetChallengeByID(id string) (*Challenge, error)

GetChallengeByID a challenge from the database by id

func GetChallenges

func GetChallenges(onlyPublished bool, limit int, skip int) ([]*Challenge, error)

GetChallenges all challenges from the database

func (*Challenge) Save

func (challenge *Challenge) Save() error

Save user data to the database

type RootTrustClient

type RootTrustClient struct {
	ID     string `bson:"id"`
	Name   string `bson:"name"`
	Secret string `bson:"secret"`
}

RootTrustClient is a client that can talk to the authentication endpoints

func GetRootTrustClientByID

func GetRootTrustClientByID(id string) (*RootTrustClient, error)

GetRootTrustClientByID a root trust client from the database by id

func (*RootTrustClient) Save

func (client *RootTrustClient) Save() error

Save api client data to the database

type User

type User struct {
	ID         string   `bson:"id"`
	FullName   string   `bson:"full_name"`
	Email      string   `bson:"email"`
	AvatarURL  string   `bson:"avatar_url"`
	OTPEnabled bool     `bson:"otp_enabled"`
	Password   string   `bson:"password"`
	OTPSecret  string   `bson:"otp_secret"`
	Scopes     []string `bson:"scopes"`
}

User is the data stored about a single user in the database

func GetUserByEmail

func GetUserByEmail(email string) (*User, error)

GetUserByEmail a user from the database by email

func GetUserByID

func GetUserByID(id string) (*User, error)

GetUserByID a user from the database by id

func (*User) Save

func (user *User) Save() error

Save user data to the database

Jump to

Keyboard shortcuts

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