Documentation ¶
Index ¶
- Constants
- Variables
- func ErrHTTPBadRequest(err error, fallbackMessage string) render.Renderer
- func ErrHTTPError(err error, fallbackMessage string) render.Renderer
- func ErrInternalServer(err error, msg string) render.Renderer
- type AccessTokenCreateParams
- type AccessTokenCreateResponse
- type AccessTokensDeleteResponse
- type Account
- type AccountGetResponse
- type Build
- type BuildsCreateParams
- type BuildsCreateResponse
- type BuildsGetResponse
- type CPU
- type CheckConclusion
- type CheckStatus
- type ConnectionInfo
- type ConnectionInfoV1
- type Endpoint
- type EndpointCheck
- type EndpointCheckRun
- type EndpointCheckStep
- type EndpointCreateParams
- type EndpointEvalAttach
- type EndpointGetResponse
- type EndpointList
- type EndpointListItem
- type EndpointStatus
- type EndpointVersion
- type EndpointVersionCreateParams
- type Error
- type Eval
- type EvalCreate
- type EvalList
- type EvalManifest
- type Exec
- type ExecConfig
- type ExecCreateParams
- type ExecGetResponse
- type ExecNetwork
- type ExecTerminateResponse
- type ExecVolume
- type ExecsListResponse
- type GPU
- type GitConfig
- type GithubIntegrationConnectRequest
- type GithubIntegrationGetResponse
- type HTTPService
- type HardwareRequestRange
- type HardwareSpec
- type LogEntry
- type NoOpLogHook
- type Node
- type NodeMetadataV1
- type NodeType
- type NodeTypesListResponse
- type PairingTokenCreateResponse
- type PairingTokenExchangeResponse
- type Project
- type ProjectCreateRequestParams
- type ProjectCreateResponse
- type ProjectGetResponse
- type ProjectListResponse
- type Provider
- type ProviderConnectParams
- type ProvidersListResponse
- type Repository
- type SSHKey
- type SSHKeyAddParams
- type SSHKeyGenerateParams
- type SSHKeyListResponse
- type SSHKeyResponse
- type SourceContext
- type Status
- type UserAccessToken
- type UwError
- type Volume
- type VolumeAttachParams
- type VolumeCreateRequest
- type VolumeResizeRequest
- type VolumeState
- type VolumesListResponse
Constants ¶
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 ¶
var NewErrLogHook = func() zerolog.Hook { return NoOpLogHook{} }
Functions ¶
Types ¶
type AccessTokenCreateParams ¶
type AccessTokenCreateParams struct {
Name string `json:"name"`
}
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:"-"` }
type BuildsCreateResponse ¶
type BuildsCreateResponse struct {
BuildID string `json:"buildID"`
}
type BuildsGetResponse ¶
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 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 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 EndpointStatus ¶
type EndpointStatus string
const ( EndpointStatusUnknown EndpointStatus = "" EndpointStatusPending EndpointStatus = "pending" EndpointStatusDeploying EndpointStatus = "deploying" EndpointStatusDeployed EndpointStatus = "deployed" EndpointStatusFailed EndpointStatus = "failed" )
type EndpointVersion ¶
type EndpointVersionCreateParams ¶
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.
type EvalCreate ¶
type EvalCreate struct {
ExecID string `json:"execID"`
}
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"` }
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 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 GithubIntegrationConnectRequest ¶
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 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 NoOpLogHook ¶
type NoOpLogHook struct{}
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 NodeTypesListResponse ¶
type NodeTypesListResponse struct {
NodeTypes []NodeType `json:"nodeTypes"`
}
type PairingTokenCreateResponse ¶
type PairingTokenCreateResponse struct {
Code string `json:"code"`
}
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"` }
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
func (Provider) DisplayName ¶
type ProviderConnectParams ¶
type ProvidersListResponse ¶
type ProvidersListResponse struct {
Providers []Provider `json:"providers"`
}
type Repository ¶
type SSHKeyAddParams ¶
type SSHKeyGenerateParams ¶
type SSHKeyGenerateParams struct {
Name *string `json:"name"`
}
type SSHKeyListResponse ¶
type SSHKeyListResponse struct {
Keys []SSHKey `json:"keys"`
}
type SSHKeyResponse ¶
type SourceContext ¶
type SourceContext struct { MountPath string `json:"mountPath"` Context io.ReadCloser `json:"-"` }
type Status ¶
type Status string
func DBSessionStatusToAPIStatus ¶
func DBSessionStatusToAPIStatus(status db.UnweaveExecStatus) Status
func (Status) IsTerminal ¶
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 VolumeAttachParams ¶
type VolumeCreateRequest ¶
type VolumeResizeRequest ¶
type VolumeState ¶
type VolumesListResponse ¶
type VolumesListResponse struct {
Volumes []Volume `json:"volumes"`
}