types

package
v0.0.0-...-9f60fe2 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserIDCtxKey     = "userID"
	AccountIDCtxKey  = "accountID"
	BuildIDCtxKey    = "buildID"
	ProjectIDCtxKey  = "projectID"
	EndpointIDCtxKey = "endpointID"
	ExecIDCtxKey     = "execID"
	VersionIDCtxKey  = "versionID"
	ExecStatusCtxKey = "execStatus"
	ObserverCtxKey   = "observer"
	ProviderCtxKey   = "provider"
)

Context Keys are used to store and retrieve values from the context. These can be used for adding contextual information to logs, or for passing values between middleware. If using in middleware, you should be careful to only use keys in the until the last handler in the chain *at-most* and not rely on the context being passed further down the stack.

Variables

View Source
var NewErrLogHook = func() zerolog.Hook { return NoOpLogHook{} }

Functions

func ErrHTTPBadRequest

func ErrHTTPBadRequest(err error, fallbackMessage string) render.Renderer

func ErrHTTPError

func ErrHTTPError(err error, fallbackMessage string) render.Renderer

func ErrInternalServer

func ErrInternalServer(err error, msg string) render.Renderer

Types

type AccessTokenCreateParams

type AccessTokenCreateParams struct {
	Name string `json:"name"`
}

func (*AccessTokenCreateParams) Bind

type AccessTokenCreateResponse

type AccessTokenCreateResponse struct {
	ID        string    `json:"id"`
	Token     string    `json:"token"`
	Name      string    `json:"name"`
	ExpiresAt time.Time `json:"expiresAt"`
}

type AccessTokensDeleteResponse

type AccessTokensDeleteResponse struct {
	Success bool `json:"success"`
}

type Account

type Account struct {
	UserID         string    `json:"userID"`
	Email          string    `json:"email"`
	GithubID       int32     `json:"githubID"`
	GithubUsername string    `json:"githubUsername"`
	DateJoined     time.Time `json:"dateJoined"`
	Credit         string    `json:"credit"`
	FirstName      string    `json:"firstName"`
	LastName       string    `json:"lastName"`
	Providers      []string  `json:"providers"`
}

type AccountGetResponse

type AccountGetResponse struct {
	Account Account `json:"account"`
}

type Build

type Build struct {
	BuildID     string     `json:"buildID"`
	Name        string     `json:"name"`
	ProjectID   string     `json:"projectID"`
	Status      string     `json:"status"`
	BuilderType string     `json:"builderType"`
	CreatedAt   time.Time  `json:"createdAt"`
	StartedAt   *time.Time `json:"startedAt,omitempty"`
	FinishedAt  *time.Time `json:"finishedAt,omitempty"`
}

type BuildsCreateParams

type BuildsCreateParams struct {
	Builder      string        `json:"builder"`
	Name         *string       `json:"name,omitempty"`
	BuildContext io.ReadCloser `json:"-"`
}

func (*BuildsCreateParams) Bind

func (i *BuildsCreateParams) Bind(r *http.Request) error

type BuildsCreateResponse

type BuildsCreateResponse struct {
	BuildID string `json:"buildID"`
}

type BuildsGetResponse

type BuildsGetResponse struct {
	Build
	UsedBySessions []Exec      `json:"usedBySessions,omitempty"`
	Logs           *[]LogEntry `json:"logs,omitempty"`
}

type CPU

type CPU struct {
	Type string `json:"type,omitempty"`
	HardwareRequestRange
}

type CheckConclusion

type CheckConclusion string
var (
	CheckSuccess CheckConclusion = "success"
	CheckFailure CheckConclusion = "failure"
	CheckError   CheckConclusion = "error"
)

func (CheckConclusion) String

func (c CheckConclusion) String() string

type CheckStatus

type CheckStatus string
var (
	CheckPending    CheckStatus = "pending"
	CheckInProgress CheckStatus = "in_progress"
	CheckCompleted  CheckStatus = "completed"
)

type ConnectionInfo

type ConnectionInfo struct {
	Host string `json:"host"`
	Port int    `json:"port"`
	User string `json:"user"`
}

type ConnectionInfoV1

type ConnectionInfoV1 struct {
	Version int    `json:"version"`
	Host    string `json:"host"`
	Port    int    `json:"port"`
	User    string `json:"user"`
}

func (ConnectionInfoV1) GetConnectionInfo

func (c ConnectionInfoV1) GetConnectionInfo() *ConnectionInfo

type Endpoint

type Endpoint struct {
	ID          string            `json:"id"`
	Name        string            `json:"name"`
	Icon        string            `json:"icon"`
	ProjectID   string            `json:"projectID"`
	HTTPAddress string            `json:"httpAddress"`
	EvalIDs     []string          `json:"evalIDs"`
	Status      EndpointStatus    `json:"status"`
	Versions    []EndpointVersion `json:"versions"`
	CreatedAt   time.Time         `json:"createdAt"`
}

type EndpointCheck

type EndpointCheck struct {
	CheckID    string
	Steps      []EndpointCheckStep
	Status     CheckStatus
	Conclusion *CheckConclusion `json:"conclusion,omitempty"`
}

type EndpointCheckRun

type EndpointCheckRun struct {
	CheckID string `json:"checkID"`
}

type EndpointCheckStep

type EndpointCheckStep struct {
	StepID     string
	EvalID     string
	Input      json.RawMessage
	Output     json.RawMessage
	Assertion  string
	Status     CheckStatus
	Conclusion *CheckConclusion `json:"conclusion,omitempty"`
}

type EndpointCreateParams

type EndpointCreateParams struct {
	Name   string `json:"name"`
	ExecID string `json:"execID"`
}

func (*EndpointCreateParams) Bind

func (e *EndpointCreateParams) Bind(_ *http.Request) error

type EndpointEvalAttach

type EndpointEvalAttach struct {
	EvalID string `json:"evalId"`
}

type EndpointGetResponse

type EndpointGetResponse struct {
	Endpoint Endpoint `json:"endpoint"`
}

type EndpointList

type EndpointList struct {
	Endpoints []EndpointListItem `json:"endpoints"`
}

type EndpointListItem

type EndpointListItem struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	Icon        string    `json:"icon"`
	ProjectID   string    `json:"projectID"`
	HTTPAddress string    `json:"httpAddress"`
	CreatedAt   time.Time `json:"createdAt"`
}

type EndpointStatus

type EndpointStatus string
const (
	EndpointStatusUnknown   EndpointStatus = ""
	EndpointStatusPending   EndpointStatus = "pending"
	EndpointStatusDeploying EndpointStatus = "deploying"
	EndpointStatusDeployed  EndpointStatus = "deployed"
	EndpointStatusFailed    EndpointStatus = "failed"
)

type EndpointVersion

type EndpointVersion struct {
	ID          string         `json:"id"`
	ExecID      string         `json:"execID"`
	HTTPAddress string         `json:"httpAddress"`
	Status      EndpointStatus `json:"status"`
	Primary     bool           `json:"primary"`
	CreatedAt   time.Time      `json:"createdAt"`
}

type EndpointVersionCreateParams

type EndpointVersionCreateParams struct {
	ExecID  string `json:"execID"`
	Promote bool   `json:"promote"`
}

func (*EndpointVersionCreateParams) Bind

type Error

type Error struct {
	Code       int      `json:"code"`
	Message    string   `json:"message"`
	Suggestion string   `json:"suggestion,omitempty"`
	Provider   Provider `json:"provider,omitempty"`
	Err        error    `json:"-"`
}

Error

Errors returned by the API should be as descriptive as possible and directly renderable to the consumer (CLI, web-app etc). Here are some examples:

Provider errors --------------- Short:

LambdaLabs API error: Invalid Public Key

Verbose:

LambdaLabs API error:
	code: 400
	message: Invalid Public Key
 	endpoint: POST /session

Unweave errors -------------- Short:

Unweave API error: Project not found

Verbose:

Unweave API error:
	code: 404
	message: Project not found
 	endpoint: POST /session

It should be possible to automatically generate the short and verbose versions of the error message from the same struct. The error message should not expose in inner workings of the API.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Render

func (e *Error) Render(w http.ResponseWriter, r *http.Request) error

type Eval

type Eval struct {
	ID           string `json:"id"`
	ExecID       string `json:"execID"`
	HTTPEndpoint string `json:"httpEndpoint"`
}

type EvalCreate

type EvalCreate struct {
	ExecID string `json:"execID"`
}

type EvalList

type EvalList struct {
	Evals []Eval `json:"evals"`
}

type EvalManifest

type EvalManifest struct {
	DatasetURL string `json:"datasetURL,omitempty"`
	AssertURL  string `json:"assertURL,omitempty"`
	RunURL     string `json:"runURL,omitempty"`
}

func DefaultEvalManifest

func DefaultEvalManifest() EvalManifest

type Exec

type Exec struct {
	ID        string       `json:"id"`
	Name      string       `json:"name"`
	CreatedAt time.Time    `json:"createdAt,omitempty"`
	ExitedAt  *time.Time   `json:"exitedAt,omitempty"`
	CreatedBy string       `json:"createdBy,omitempty"`
	Image     string       `json:"image,omitempty"`
	BuildID   *string      `json:"buildID,omitempty"`
	Status    Status       `json:"status"`
	Command   []string     `json:"command"`
	Keys      []SSHKey     `json:"keys"`
	Volumes   []ExecVolume `json:"volumes"`
	Network   ExecNetwork  `json:"network"`
	Spec      HardwareSpec `json:"spec"`
	CommitID  *string      `json:"commitID,omitempty"`
	GitURL    *string      `json:"gitURL,omitempty"`
	Region    string       `json:"region"`
	Provider  Provider     `json:"provider"`
}

type ExecConfig

type ExecConfig struct {
	Image   string         `json:"image"`
	Command []string       `json:"command"`
	Keys    []SSHKey       `json:"keys"`
	Volumes []Volume       `json:"volumes"`
	Src     *SourceContext `json:"src,omitempty"`
}

type ExecCreateParams

type ExecCreateParams struct {
	Name         string               `json:"name,omitempty"`
	Provider     Provider             `json:"provider"`
	Spec         HardwareSpec         `json:"hardwareSpec,omitempty"`
	SSHKeyName   string               `json:"sshKeyName"`
	SSHPublicKey string               `json:"sshPublicKey"`
	Region       *string              `json:"region,omitempty"`
	Image        *string              `json:"image"`
	Command      []string             `json:"command"`
	CommitID     *string              `json:"commitID,omitempty"`
	GitURL       *string              `json:"gitURL,omitempty"`
	Source       *SourceContext       `json:"source,omitempty"`
	Volumes      []VolumeAttachParams `json:"volumes,omitempty"`
	InternalPort int32                `json:"internal_port"`
}

func (*ExecCreateParams) Bind

func (s *ExecCreateParams) Bind(r *http.Request) error

type ExecGetResponse

type ExecGetResponse struct {
	Exec Exec `json:"session"`
}

type ExecNetwork

type ExecNetwork struct {
	Host        string       `json:"host"`
	Port        int          `json:"port"`
	User        string       `json:"user"`
	HTTPService *HTTPService `json:"httpService,omitempty"`
}

type ExecTerminateResponse

type ExecTerminateResponse struct {
	Success bool `json:"success"`
}

type ExecVolume

type ExecVolume struct {
	VolumeID  string `json:"volumeID"`
	MountPath string `json:"mountPath"`
}

type ExecsListResponse

type ExecsListResponse struct {
	Execs []Exec `json:"sessions"`
}

type GPU

type GPU struct {
	Type  string               `json:"type,omitempty"`
	Count HardwareRequestRange `json:"count"`
	RAM   HardwareRequestRange `json:"ram,omitempty"`
}

type GitConfig

type GitConfig struct {
	CommitID *string `json:"commitID"`
	GitURL   *string `json:"gitURL"`
}

type GithubIntegrationConnectRequest

type GithubIntegrationConnectRequest struct {
	Code        string `json:"code"`
	AccessToken string `json:"accessToken"`
}

func (*GithubIntegrationConnectRequest) Bind

type GithubIntegrationGetResponse

type GithubIntegrationGetResponse struct {
	Repositories   []Repository `json:"repositories,omitempty"`
	IsAppInstalled bool         `json:"isAppInstalled"`
	InstallURL     string       `json:"installURL,omitempty"`
}

GithubIntegrationGetResponse lists all repositories authenticated to Unweave, whether the GitHub application is installed, and the installation URL if applicable.

type HTTPService

type HTTPService struct {
	InternalPort int32 `json:"internalPort"`
}

type HardwareRequestRange

type HardwareRequestRange struct {
	Min int `json:"min,omitempty"`
	Max int `json:"max,omitempty"`
}

type HardwareSpec

type HardwareSpec struct {
	GPU GPU                  `json:"gpu"`
	CPU CPU                  `json:"cpu"`
	RAM HardwareRequestRange `json:"ram"`
	HDD HardwareRequestRange `json:"hdd"`
}

func HardwareSpecFromJSON

func HardwareSpecFromJSON(data []byte) (*HardwareSpec, error)

func SetSpecDefaultValues

func SetSpecDefaultValues(spec HardwareSpec) HardwareSpec

type LogEntry

type LogEntry struct {
	TimeStamp time.Time `json:"timestamp"`
	Message   string    `json:"message"`
	Level     string    `json:"level"`
}

func (LogEntry) String

func (l LogEntry) String() string

type NoOpLogHook

type NoOpLogHook struct{}

func (NoOpLogHook) Run

func (d NoOpLogHook) Run(e *zerolog.Event, level zerolog.Level, msg string)

type Node

type Node struct {
	ID       string       `json:"id"`
	TypeID   string       `json:"typeID"`
	OwnerID  string       `json:"ownerID"`
	Price    int          `json:"price"`
	Region   string       `json:"region"`
	KeyPair  SSHKey       `json:"sshKeyPair"`
	Status   Status       `json:"status"`
	Provider Provider     `json:"provider"`
	Specs    HardwareSpec `json:"specs"`
	Host     string       `json:"host"`
	User     string       `json:"user"`
	Port     int          `json:"port"`
}

type NodeMetadataV1

type NodeMetadataV1 struct {
	VCPUs          int              `json:"vcpus"`
	Memory         int              `json:"memory"`
	HDD            int              `json:"hdd"`
	GpuType        string           `json:"gpuType"`
	CpuType        string           `json:"cpuType"`
	GPUCount       int              `json:"gpuCount"`
	GPUMemory      int              `json:"gpuMemory"`
	ConnectionInfo ConnectionInfoV1 `json:"connection_info"`
	HTTPService    *HTTPService     `json:"http_service,omitempty"`
}

func DBNodeMetadataFromNode

func DBNodeMetadataFromNode(node Node) NodeMetadataV1

func NodeMetadataFromJSON

func NodeMetadataFromJSON(data []byte) (*NodeMetadataV1, error)

func (*NodeMetadataV1) GetExecNetwork

func (m *NodeMetadataV1) GetExecNetwork() ExecNetwork

func (*NodeMetadataV1) GetHardwareSpec

func (m *NodeMetadataV1) GetHardwareSpec() HardwareSpec

type NodeType

type NodeType struct {
	Type     string       `json:"type"`
	ID       string       `json:"id"`
	Name     *string      `json:"name"`
	Price    *int         `json:"price"`
	Regions  []string     `json:"regions"`
	Provider Provider     `json:"provider"`
	Specs    HardwareSpec `json:"specs"`
}

type NodeTypesListResponse

type NodeTypesListResponse struct {
	NodeTypes []NodeType `json:"nodeTypes"`
}

type PairingTokenCreateResponse

type PairingTokenCreateResponse struct {
	Code string `json:"code"`
}

type PairingTokenExchangeResponse

type PairingTokenExchangeResponse struct {
	Token   string  `json:"token"`
	Account Account `json:"account"`
}

type Project

type Project struct {
	ID         string    `json:"id"`
	Owner      string    `json:"owner"`
	Name       string    `json:"name"`
	Icon       string    `json:"icon"`
	CreatedAt  time.Time `json:"createdAt"`
	Visibility string    `json:"visibility"`
	GithubURL  *string   `json:"githubURL"`
}

type ProjectCreateRequestParams

type ProjectCreateRequestParams struct {
	Name       string   `json:"name"`
	Tags       []string `json:"tags"`
	Visibility *string  `json:"visibility"`
	// SourceRepoURL must be a HTTPS endpoint to a Git module i.e. https://github.com/unweave/unweave.git
	SourceRepoURL *string `json:"repo"`
}

func (*ProjectCreateRequestParams) Bind

type ProjectCreateResponse

type ProjectCreateResponse struct {
	Project Project `json:"project"`
}

type ProjectGetResponse

type ProjectGetResponse struct {
	Project Project `json:"project"`
}

type ProjectListResponse

type ProjectListResponse struct {
	Projects []Project `json:"projects"`
}

type Provider

type Provider string

Provider is the platform that the node is spawned on. This is where the user code runs

const (
	LambdaLabsProvider Provider = "lambdalabs"
	UnweaveProvider    Provider = "unweave"
	AWSProvider        Provider = "aws"
)

func (Provider) DisplayName

func (r Provider) DisplayName() string

func (Provider) String

func (r Provider) String() string

type ProviderConnectParams

type ProviderConnectParams struct {
	Provider      Provider `json:"provider"`
	ProviderToken string   `json:"providerToken,omitempty"`
}

func (*ProviderConnectParams) Bind

type ProvidersListResponse

type ProvidersListResponse struct {
	Providers []Provider `json:"providers"`
}

type Repository

type Repository struct {
	Name     string `json:"name"`
	FullName string `json:"fullName"`
	// URL must be cloneable by Git
	URL string `json:"url,omitempty"`
}

type SSHKey

type SSHKey struct {
	Name       string     `json:"name"`
	PublicKey  *string    `json:"publicKey,omitempty"`
	PrivateKey *string    `json:"privateKey,omitempty"`
	CreatedAt  *time.Time `json:"createdAt,omitempty"`
}

type SSHKeyAddParams

type SSHKeyAddParams struct {
	Name      *string `json:"name"`
	PublicKey string  `json:"publicKey"`
}

func (*SSHKeyAddParams) Bind

func (s *SSHKeyAddParams) Bind(r *http.Request) error

type SSHKeyGenerateParams

type SSHKeyGenerateParams struct {
	Name *string `json:"name"`
}

func (*SSHKeyGenerateParams) Bind

func (s *SSHKeyGenerateParams) Bind(r *http.Request) error

type SSHKeyListResponse

type SSHKeyListResponse struct {
	Keys []SSHKey `json:"keys"`
}

type SSHKeyResponse

type SSHKeyResponse struct {
	Name       string `json:"name"`
	PublicKey  string `json:"publicKey"`
	PrivateKey string `json:"privateKey"`
}

type SourceContext

type SourceContext struct {
	MountPath string        `json:"mountPath"`
	Context   io.ReadCloser `json:"-"`
}

type Status

type Status string
const (
	StatusPending      Status = "pending"
	StatusInitializing Status = "initializing"
	StatusRunning      Status = "running"
	StatusTerminated   Status = "terminated"
	StatusError        Status = "error"
	StatusFailed       Status = "failed"
	StatusSuccess      Status = "success"
	StatusUnknown      Status = "unknown"
)

func DBSessionStatusToAPIStatus

func DBSessionStatusToAPIStatus(status db.UnweaveExecStatus) Status

func (Status) IsTerminal

func (s Status) IsTerminal() bool

type UserAccessToken

type UserAccessToken struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	DisplayText string    `json:"displayText"`
	ExpiresAt   time.Time `json:"expiresAt"`
	UserID      string    `json:"userId"`
}

UserAccessToken is an internal type to safely pass user tokens, never exposes token or hash

func NewUserAccessToken

func NewUserAccessToken(userID, tokenID, tokenName, displayText string, expiresAt time.Time) UserAccessToken

type UwError

type UwError interface {
	Short() string
	Verbose() string
}

type Volume

type Volume struct {
	ID        string      `json:"id"`
	Name      string      `json:"name"`
	Size      int         `json:"size"`
	State     VolumeState `json:"state"`
	Provider  Provider    `json:"provider"`
	ProjectID string      `json:"projectID"`
}

type VolumeAttachParams

type VolumeAttachParams struct {
	VolumeRef string `json:"volumeRef"`
	MountPath string `json:"mountPath"`
}

type VolumeCreateRequest

type VolumeCreateRequest struct {
	Size     int      `json:"size"`
	Name     string   `json:"name"`
	Provider Provider `json:"provider"`
}

func (*VolumeCreateRequest) Bind

func (p *VolumeCreateRequest) Bind(r *http.Request) error

type VolumeResizeRequest

type VolumeResizeRequest struct {
	IDOrName string `json:"idOrName"`
	Size     int    `json:"size"`
}

func (*VolumeResizeRequest) Bind

func (p *VolumeResizeRequest) Bind(r *http.Request) error

type VolumeState

type VolumeState struct {
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

type VolumesListResponse

type VolumesListResponse struct {
	Volumes []Volume `json:"volumes"`
}

Jump to

Keyboard shortcuts

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