api

package
v0.24.2 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2020 License: Apache-2.0 Imports: 24 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoEnoughData = errors.New("Insufficient data")
)
View Source
var (
	// ErrNotLogined means user was not logined
	ErrNotLogined = errors.New("not logined")
)
View Source
var (
	// Get2FACode is the function to get the user's two-factor-authentication code.
	// You can override it with your custom function.
	Get2FACode = func() (int, error) {
		result := new(string)
		wizard.Ask([]wizard.Question{
			{
				Content: "Please input 2-factor auth code",
				Input: &wizard.Input{
					Result: result,
					Hidden: false,
				},
			},
		})
		code, err := strconv.Atoi(*result)
		if err != nil {
			return 0, errors.New("2-factor auth code should be numerical")
		}
		return code, nil
	}
)

Functions

func DeleteFromRepoStorage added in v0.20.0

func DeleteFromRepoStorage(region regions.Region, objectID string) error

func DeployAppFromFile

func DeployAppFromFile(appID string, group string, prod int, fileURL string, opts *DeployOptions) (string, error)

DeployAppFromFile will deploy applications with specific file returns the event token for polling deploy log

func DeployAppFromGit

func DeployAppFromGit(appID string, group string, prod int, revision string, opts *DeployOptions) (string, error)

DeployAppFromGit will deploy applications with user's git repo returns the event token for polling deploy log

func DeployImage

func DeployImage(appID string, group string, prod int, imageTag string, opts *DeployOptions) (string, error)

DeployImage will deploy the engine group with specify image tag

func GetAppAPIURL added in v0.18.0

func GetAppAPIURL(region regions.Region, appID string) string

func GetVersion added in v0.23.0

func GetVersion(appID string) (int, error)

GetVersion returns current app use LeanDB or LeanCache

func NewErrorFromBody

func NewErrorFromBody(body string) error

NewErrorFromBody build an error value from JSON string

func NewErrorFromResponse

func NewErrorFromResponse(resp *grequests.Response) error

NewErrorFromResponse build an error value from *grequest.Response

func PollEvents

func PollEvents(appID string, tok string) (bool, error)

PollEvents will poll the server's event logs and print the result to the given io.Writer

func PutEnvironments

func PutEnvironments(appID string, group string, envs map[string]string) error

func ReceiveLogsByLimit added in v0.8.0

func ReceiveLogsByLimit(printer LogReceiver, appID string, masterKey string, isProd bool, group string, limit int, follow bool) error

ReceiveLogsByLimit will poll the leanengine's log and print it to the giver io.Writer

func ReceiveLogsByRange added in v0.8.0

func ReceiveLogsByRange(printer LogReceiver, appID string, masterKey string, isProd bool, group string, from time.Time, to time.Time) error

ReceiveLogsByRange will poll the leanengine's log and print it to the giver io.Writer

func UploadFile

func UploadFile(appID string, filePath string) (*upload.File, error)

UploadFile upload specific file to LeanCloud

func UploadFileEx added in v0.15.0

func UploadFileEx(appID string, appKey string, region regions.Region, filePath string) (*upload.File, error)

UploadFileEx upload specific file to LeanCloud

func UploadToRepoStorage added in v0.20.0

func UploadToRepoStorage(region regions.Region, filePath string) (*upload.File, error)

upload code zip package to a concentrated app in specific region

Types

type Client

type Client struct {
	CookieJar *cookiejar.Jar
	Region    regions.Region
	AppID     string
}

func NewClientByApp added in v0.18.0

func NewClientByApp(appID string) *Client

func NewClientByRegion added in v0.18.0

func NewClientByRegion(region regions.Region) *Client

func (*Client) GetBaseURL added in v0.18.0

func (client *Client) GetBaseURL() string

type DeployOptions added in v0.19.1

type DeployOptions struct {
	Message        string
	NoDepsCache    bool
	OverwriteFuncs bool
	Options        string // Additional options in urlencode format
}

type EngineInfo added in v0.21.0

type EngineInfo struct {
	AppID string `json:"appId"`
}

func GetEngineInfo

func GetEngineInfo(appID string) (*EngineInfo, error)

type Error

type Error struct {
	Code         int    `json:"code"`
	Content      string `json:"error"`
	ErrorEventID string `json:"errorEventID"`
}

Error is the LeanCloud API Server API common error format

func (Error) Error

func (err Error) Error() string

type ExecuteCQLResult

type ExecuteCQLResult struct {
	ClassName string                   `json:"className"`
	Results   []map[string]interface{} `json:"results"`
	Count     int                      `json:"count"`
}

ExecuteCQLResult is ExecuteCQL's result type

func ExecuteCQL

func ExecuteCQL(appID string, masterKey string, cql string) (*ExecuteCQLResult, error)

ExecuteCQL will execute the cql, and returns' the result

type ExecuteCacheCommandResult

type ExecuteCacheCommandResult struct {
	Result interface{} `json:"result"`
}

ExecuteCacheCommandResult is ExecuteCacheCommand's result type

func ExecuteCacheCommand

func ExecuteCacheCommand(appID string, instance string, db int, command string) (*ExecuteCacheCommandResult, error)

ExecuteCacheCommand will send command to LeanCache and excute it

func ExecuteClusterCommand added in v0.23.0

func ExecuteClusterCommand(appID string, instance string, db int, command string) (*ExecuteCacheCommandResult, error)

ExecuteClusterCommand will send command to LeanCache and excute it

type GetAppInfoResult

type GetAppInfoResult struct {
	AppDomain string `json:"app_domain"`
	AppID     string `json:"app_id"`
	AppKey    string `json:"app_key"`
	AppName   string `json:"app_name"`
	HookKey   string `json:"hook_key"`
	MasterKey string `json:"master_key"`
}

GetAppInfoResult is GetAppInfo function's result type

func GetAppInfo

func GetAppInfo(appID string) (*GetAppInfoResult, error)

GetAppInfo returns the application's detail info

type GetAppListResult

type GetAppListResult struct {
	AppID     string `json:"app_id"`
	AppKey    string `json:"app_key"`
	AppName   string `json:"app_name"`
	MasterKey string `json:"master_key"`
	AppDomain string `json:"app_domain"`
}

GetAppListResult is GetAppList function's result type

func GetAppList

func GetAppList(region regions.Region) ([]*GetAppListResult, error)

GetAppList returns the current user's all LeanCloud application this will also update the app router cache

type GetCacheListResult

type GetCacheListResult struct {
	Instance   string `json:"instance"`
	MaxMemory  int    `json:"max_memory"`
	InstanceID string `json:"instance_id"`
	Info       struct {
		UsedMemoryHuman string `json:"used_memory_human"`
	} `json:"info"`
}

GetCacheListResult is GetCacheList's return structure type

func GetCacheList

func GetCacheList(appID string) ([]*GetCacheListResult, error)

GetCacheList returns current app's LeanCache instance list

type GetGroupsResult

type GetGroupsResult struct {
	GroupName    string            `json:"groupName"`
	Repository   string            `json:"repository"`
	Domain       string            `json:"domain"`
	Instances    []InstanceInfo    `json:"instances"`
	Staging      GroupDeployInfo   `json:"staging"`
	Production   GroupDeployInfo   `json:"production"`
	Environments map[string]string `json:"environments"`
}

func GetGroup added in v0.7.0

func GetGroup(appID string, groupName string) (*GetGroupsResult, error)

GetGroup will fetch all groups from API and return the current group info

func GetGroups

func GetGroups(appID string) ([]*GetGroupsResult, error)

GetGroups returns the application's engine groups

type GetUserInfoResult

type GetUserInfoResult struct {
	Email    string `json:"email"`
	UserName string `json:"username"`
}

GetUserInfoResult is the return type of GetUserInfo

func GetUserInfo

func GetUserInfo(region regions.Region) (*GetUserInfoResult, error)

GetUserInfo returns the current logined user info

func Login

func Login(email string, password string, region regions.Region) (*GetUserInfoResult, error)

Login LeanCloud account

type GroupDeployInfo added in v0.21.0

type GroupDeployInfo struct {
	Deployable bool        `json:"deployable"`
	Version    VersionInfo `json:"version"`
}

type InstanceInfo added in v0.21.0

type InstanceInfo struct {
	Name string `json:"name"`
	Prod int    `json:"prod"`
}

type LeanCacheCluster added in v0.23.0

type LeanCacheCluster struct {
	ID        int    `json:"id"`
	Name      string `json:"name"`
	Runtime   string `json:"runtime"`
	NodeQuota string `json:"nodeQuota"`
}

LeanCacheCluster is structure of LeanCache DB instannce

func GetClusterList added in v0.23.0

func GetClusterList(appID string) ([]*LeanCacheCluster, error)

GetClusterList returns current app's LeanCache instances (NEW)

type Log

type Log struct {
	InstanceName string `json:"instanceName"`
	Content      string `json:"content"`
	Type         string `json:"type"`
	Time         string `json:"time"`
	GroupName    string `json:"groupName"`
	Production   int    `json:"prod"`
	Stream       string `json:"stream"`
	ID           string `json:"id"`
}

Log is EngineLogs's type structure

type LogReceiver added in v0.8.0

type LogReceiver func(*Log) error

LogReceiver is print func interface to PrintLogs

type ReqStat added in v0.13.0

type ReqStat struct {
	Date             string `json:"date"`
	ExceedTimes      int    `json:"exceed_times"`
	MaxDurationTime  int    `json:"max_duration_ms"`
	MeanQPS          int    `json:"meanQPS"`
	P95DurationTime  int    `json:"p95_duration_ms"`
	P90DurationTime  int    `json:"p90_duration_ms"`
	MaxConcurrent    int    `json:"max_concurrent"`
	MeanDurationTime int    `json:"mean_duration_ms"`
	// ExceptionPercentage string `json:"exception_percentage"`
	MeanConcurrent  int    `json:"mean_concurrent"`
	MaxQPS          int    `json:"max_qps"`
	P80DurationTime int    `json:"p80_duration_ms"`
	Error           string `json:"error,omitempty"`
	ApiReqCount     int    `json:"apiReqCount"`
}

type RouterResponse added in v0.18.0

type RouterResponse struct {
	TTL             int    `json:"ttl"`
	StatsServer     string `json:"stats_server"`
	RTMRouterServer string `json:"rtm_router_server"`
	PushServer      string `json:"push_server"`
	EngineServer    string `json:"engine_server"`
	APIServer       string `json:"api_server"`
}

func QueryAppRouter added in v0.18.0

func QueryAppRouter(appID string) (result RouterResponse, err error)

Not applicable for US

type Status added in v0.13.0

type Status []ReqStat

func FetchReqStat added in v0.13.0

func FetchReqStat(appID string, from time.Time, to time.Time) (Status, error)

func (Status) Len added in v0.13.0

func (S Status) Len() int

func (Status) Less added in v0.13.0

func (S Status) Less(i, j int) bool

func (Status) Swap added in v0.13.0

func (S Status) Swap(i, j int)

type VersionInfo added in v0.21.0

type VersionInfo struct {
	VersionTag string `json:"versionTag"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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