api

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DeploymentStatusReady    = "ready"
	DeploymentStatusPending  = "pending"
	DeploymentStatusBuilding = "building"
	DeploymentStatusStarting = "starting"
	DeploymentStatusRunning  = "running"
	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"`
	Platform      string       `json:"platform"`
	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 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 Client

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

func NewClient

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

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) AppsList

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

func (*Client) AppsUploadFiles

func (c *Client) AppsUploadFiles(app string, tarfile io.Reader, reporter ProgressReporterFunc) 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)

type CreateAppOptions

type CreateAppOptions struct {
	Name     string `json:"name"`
	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 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

type ProgressReader

type ProgressReader struct {
	io.Reader

	Reporter ProgressReporterFunc
	// contains filtered or unexported fields
}

func (*ProgressReader) Read

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

type ProgressReporterFunc

type ProgressReporterFunc func(int64, int64)

type Response

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

func (*Response) Error

func (r *Response) Error() string

func (*Response) IsUploadChangesErr

func (r *Response) IsUploadChangesErr() bool

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