api

package
v0.2.11 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppStatusPending   AppStatus = "pending"
	AppStatusRunning             = "running"
	AppStatusPreparing           = "preparing"
	AppStatusAssigned            = "assigned"
	AppStatusRejected            = "rejected"
	AppStatusAccepted            = "accepted"
	AppStatusReady               = "ready"
	AppStatusStarting            = "starting"
	AppStatusComplete            = "complete"
	AppStatusShutdown            = "shutdown"
	AppStatusRemoved             = "removed"
)
View Source
const (
	DeploymentStatusReady    DeploymentStatus = "ready"
	DeploymentStatusPending                   = "pending"
	DeploymentStatusBuilding                  = "building"
	DeploymentStatusStarting                  = "starting"
	DeploymentStatusFinished                  = "finished"
	DeploymentStatusShutdown                  = "shutdown"
	DeploymentStatusCancel                    = "cancel"
	DeploymentStatusFailed                    = "failed"
)

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
)

Functions

func CheckResponse

func CheckResponse(r *Response) error

Types

type AccountLoginOptions

type AccountLoginOptions struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type AccountRegisterOptions

type AccountRegisterOptions struct {
	Name     string `json:"name"`
	Email    string `json:"email"`
	Password string `json:"password"`
	Phone    string `json:"phone"`
}

type App

type App struct {
	ID            int64        `json:"id"`
	Name          string       `json:"name"`
	Label         string       `json:"label"`
	Platform      string       `json:"platform"`
	Image         string       `json:"image"`
	Status        AppStatus    `json:"status"`
	Port          int          `json:"port"`
	Region        string       `json:"region"`
	DomainEnabled bool         `json:"domain_enabled"`
	Env           []EnvItem    `json:"env"`
	Resource      *AppResource `json:"resource"`
	CreatedAt     *time.Time   `json:"created_at"`
}

type AppConfig

type AppConfig struct {
	App      string `mapstructure:"app" json:"app"`
	Port     int    `mapstructure:"port" json:"port"`
	Platform string `mapstructure:"platform" json:"platform"`
}

type AppLog

type AppLog struct {
	Stream    string `json:"stream"`
	Message   string `json:"message"`
	Timestamp int64  `json:"timestamp"`
}

type AppLogsOptions

type AppLogsOptions struct {
	Since int64 `json:"since"`
}

type AppResource

type AppResource struct {
	CPU     float32 `json:"cpu"`
	Memory  float32 `json:"memory"`
	Storage float32 `json:"storage"`
}

type AppStatus added in v0.2.0

type AppStatus string

type Auth

type Auth struct {
	Token string `json:"token"`
	User  User   `json:"user"`
}

type BuildLog

type BuildLog struct {
	ID        int64     `json:"id"`
	Level     string    `json:"level"`
	Message   string    `json:"message"`
	CreatedAt time.Time `json:"created_at"`
}

type BuildLogs

type BuildLogs struct {
	Deployment *Deployment `json:"deployment"`
	Logs       []*BuildLog `json:"logs"`
}

type CliSession added in v0.2.4

type CliSession struct {
	Code string `json:"code"`
	Link string `json:"link"`
}

type Client

type Client struct {
	BaseURL *url.URL
	// contains filtered or unexported fields
}

func NewClient

func NewClient(token string, options ...Option) *Client

func (*Client) AccountCheckCliSession added in v0.2.4

func (c *Client) AccountCheckCliSession(code string) (*Auth, error)

func (*Client) AccountCreateCliSession added in v0.2.4

func (c *Client) AccountCreateCliSession() (*CliSession, error)

func (*Client) AccountLogin

func (c *Client) AccountLogin(opts *AccountLoginOptions) (*Auth, error)

func (*Client) AccountRegister

func (c *Client) AccountRegister(opts *AccountRegisterOptions) (*Auth, error)

func (*Client) AppLogs

func (c *Client) AppLogs(app string, opts *AppLogsOptions) ([]*AppLog, error)

func (*Client) AppsCreate

func (c *Client) AppsCreate(opts *CreateAppOptions) (*App, error)

func (*Client) AppsGet added in v0.2.0

func (c *Client) AppsGet(opts *GetAppOptions) (*App, error)

func (*Client) AppsList

func (c *Client) AppsList(opts *ListAppsOptions) ([]*App, error)

func (*Client) AppsRemove added in v0.2.0

func (c *Client) AppsRemove(opts *RemoveAppOptions) error

func (*Client) AppsRestart added in v0.2.0

func (c *Client) AppsRestart(opts *RestartAppOptions) error

func (*Client) AppsShutdown added in v0.2.0

func (c *Client) AppsShutdown(opts *ShutdownAppOptions) error

func (*Client) AppsStart added in v0.2.0

func (c *Client) AppsStart(opts *StartAppOptions) error

func (*Client) AppsUploadFiles

func (c *Client) AppsUploadFiles(app string, tarfile io.Reader, reporter *ProgressReader) error

func (*Client) DeployemntCreate

func (c *Client) DeployemntCreate(app string, opts *CreateDeploymentOptions) (*Deployment, []*FileInfo, error)

func (*Client) DeploymentBuildLogs

func (c *Client) DeploymentBuildLogs(app string, deploymentId int64, opts *LogsOptions) (*BuildLogs, error)

func (*Client) DeploymentCancel

func (c *Client) DeploymentCancel(app string, deploymentId int64) error

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*Response, error)

func (*Client) NewRequest

func (c *Client) NewRequest(method, path string, body interface{}) (*http.Request, error)

func (*Client) PlansList added in v0.2.0

func (c *Client) PlansList() ([]*Plan, error)

func (*Client) PlatformList added in v0.2.4

func (c *Client) PlatformList() ([]*Platform, error)

type CreateAppOptions

type CreateAppOptions struct {
	Label    string `json:"label"`
	Platform string `json:"platform"`
	PlanID   int64  `json:"plan_id"`
	Region   string `json:"region"`
}

type CreateDeploymentOptions

type CreateDeploymentOptions struct {
	Files  []*FileInfo `json:"files"`
	Config *AppConfig  `json:"config"`
}

type Deployment

type Deployment struct {
	ID        int64            `json:"id"`
	Platform  string           `json:"platform"`
	Image     string           `json:"image"`
	Port      int              `json:"port"`
	Status    DeploymentStatus `json:"status"`
	URL       string           `json:"url"`
	CreatedAt *time.Time       `json:"created_at"`
}

type DeploymentStatus

type DeploymentStatus string

type EnvItem

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

type FileInfo

type FileInfo struct {
	Path     string      `json:"path"`
	Checksum string      `json:"checksum"`
	Size     int64       `json:"size"`
	Dir      bool        `json:"dir"`
	Mode     fs.FileMode `json:"mode"`
}

type GetAppOptions added in v0.2.0

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

type ListAppsOptions

type ListAppsOptions struct {
}

type LogsOptions

type LogsOptions struct {
	From int64 `json:"from"`
}

type Option

type Option func(*Client)

func WithBaseURL

func WithBaseURL(baseURL string) Option

func WithHttpClient

func WithHttpClient(client *http.Client) Option

func WithUserAgent added in v0.2.7

func WithUserAgent(userAgent string) Option

type Plan added in v0.2.0

type Plan struct {
	ID           int64   `json:"id"`
	Name         string  `json:"name"`
	CPU          float64 `json:"cpu"`
	Memory       float64 `json:"memory"`
	Storage      float64 `json:"storage"`
	Available    bool    `json:"available"`
	Sort         int     `json:"sort"`
	HourlyPrice  int     `json:"hourly_price"`
	MonthlyPrice int     `json:"monthly_price"`
}

type Platform added in v0.2.4

type Platform struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type ProgressReader

type ProgressReader struct {
	io.Reader
	Max    int64
	Add    func(int64)
	SetMax func(int64)
}

func (*ProgressReader) Read

func (r *ProgressReader) Read(p []byte) (n int, err error)

type RemoveAppOptions added in v0.2.0

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

type Response

type Response struct {
	*http.Response
	Files   []*FileInfo `json:"files"`
	Err     string      `json:"error"`
	Message string      `json:"message"`
}

func (*Response) Error

func (r *Response) Error() string

func (*Response) IsUploadChangesErr

func (r *Response) IsUploadChangesErr() bool

type RestartAppOptions added in v0.2.0

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

type ShutdownAppOptions added in v0.2.0

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

type StartAppOptions added in v0.2.0

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

type User

type User struct {
	Email string `json:"email"`
}

Jump to

Keyboard shortcuts

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