inertia: github.com/ubclaunchpad/inertia/api Index | Files

package api

import "github.com/ubclaunchpad/inertia/api"

Package api contains definitions for Inertia API requests and responses

Index

Package Files

api.go doc.go response.go

Constants

const (
    // MsgDaemonOK is the OK response upon successfully reaching daemon
    MsgDaemonOK = "I'm a little Webhook, short and stout!"

    // MsgTokenExpired indicates authentication method is expired
    MsgTokenExpired = "token expired"

    // Container is a constant used in HTTP GET query strings
    Container = "container"

    // Stream is a constant used in HTTP GET query strings
    Stream = "stream"

    // Entries is a constant used in HTTP GET query strings
    Entries = "entries"
)

type BaseResponse Uses

type BaseResponse struct {
    // Basic metadata
    HTTPStatusCode int    `json:"code"`
    RequestID      string `json:"request_id,omitempty"`

    // Message is included in all responses, and is a summary of the server's response
    Message string `json:"message"`

    // Err contains additional context in the event of an error
    Err string `json:"error,omitempty"`

    // Data contains information the server wants to return
    Data interface{} `json:"data,omitempty"`
}

BaseResponse is the underlying response structure to all responses.

func Unmarshal Uses

func Unmarshal(r io.Reader, kvs ...KV) (*BaseResponse, error)

Unmarshal reads the response and unmarshalls the BaseResponse as well any requested key-value pairs.

For example:

var totpResp api.TotpResponse
api.Unmarshal(resp.Body, api.KV{Key: "totp", Value: &totpResp})

Values provided in KV.Value MUST be explicit pointers, even if the value is a pointer type, ie maps and slices.

func (*BaseResponse) Error Uses

func (b *BaseResponse) Error() error

Error returns a summary of an encountered error. For more details, you may want to interrogate Data. Returns nil if StatusCode is not an HTTP error code, ie if the code is in 1xx, 2xx, or 3xx

type DeploymentStatus Uses

type DeploymentStatus struct {
    Branch               string   `json:"branch"`
    CommitHash           string   `json:"commit_hash"`
    CommitMessage        string   `json:"commit_message"`
    BuildType            string   `json:"build_type"`
    Containers           []string `json:"containers"`
    BuildContainerActive bool     `json:"build_active"`
}

DeploymentStatus lists details about the deployed project

type DeploymentStatusWithVersions Uses

type DeploymentStatusWithVersions struct {
    DeploymentStatus

    // current version
    InertiaVersion string `json:"version"`

    // returns tag of latest version on dockerhub
    NewVersionAvailable *string `json:"new_version_available"`
}

DeploymentStatusWithVersions extends DeploymentStatus with a field that denotes whether a new version is available

type EnvRequest Uses

type EnvRequest struct {
    Name    string `json:"name,omitempty"`
    Value   string `json:"value,omitempty"`
    Encrypt bool   `json:"encrypt,omitempty"`

    Remove bool `json:"remove,omitempty"`
}

EnvRequest represents a request to manage environment variables

type GitOptions Uses

type GitOptions struct {
    RemoteURL string `json:"remote"`
    Branch    string `json:"branch"`
}

GitOptions represents GitHub-related deployment options

type KV Uses

type KV struct {
    Key   string
    Value interface{}
}

KV is used for defining specific values to be unmarshalled from BaseResponse data

type TotpResponse Uses

type TotpResponse struct {
    TotpSecret  string   `json:"secret"`
    BackupCodes []string `json:"backup_codes"`
}

TotpResponse is used for sending users their Totp secret and backup codes

type UpRequest Uses

type UpRequest struct {
    Stream                 bool       `json:"stream"`
    Project                string     `json:"project"`
    BuildType              string     `json:"build_type"`
    BuildFilePath          string     `json:"build_file_path"`
    GitOptions             GitOptions `json:"git_options"`
    WebHookSecret          string     `json:"webhook_secret"`
    IntermediaryContainers []string   `json:"intermediary_containers"`
    SlackNotificationURL   string     `json:"slack_notification_url"`
}

UpRequest is the configurable body of a UP request to the daemon. TODO: unify with configuration definitions

type UserRequest Uses

type UserRequest struct {
    Username string `json:"username"`
    Password string `json:"password"`
    Email    string `json:"email"`
    Admin    bool   `json:"admin"`
    Totp     string `json:"totp"`
}

UserRequest is used for logging in or modifying users

Package api imports 6 packages (graph) and is imported by 8 packages. Updated 2020-12-31. Refresh now. Tools for package owners.