api

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: Apache-2.0 Imports: 23 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

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() (string, 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 "", errors.New("2-factor auth code should be numerical")
		}
		return strconv.Itoa(code), nil
	}
)

Functions

func DeleteEnvironment added in v1.2.0

func DeleteEnvironment(appID string, group string, env string) error

func DeleteFromRepoStorage added in v0.20.0

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

func DeployAppFromFile

func DeployAppFromFile(appID string, group string, env string, 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, env string, 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, env string, 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

URL for LeanStorage API, not dashboard API

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
	AccessToken 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) GetAuthHeaders added in v0.26.0

func (client *Client) GetAuthHeaders() map[string]string

func (*Client) GetBaseURL added in v0.18.0

func (client *Client) GetBaseURL() string

type DeployOptions added in v0.19.1

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

type DomainBinding added in v1.2.0

type DomainBinding struct {
	Type                  Type       `json:"type"`
	AppId                 string     `json:"appId"`
	GroupName             string     `json:"groupName"`
	Domain                string     `json:"domain"`
	CnameTarget           *string    `json:"cnameTarget"`
	IcpLicense            string     `json:"icpLicense"`
	State                 State      `json:"state"`
	FailedReason          *string    `json:"failedReason"`
	SslType               SSLType    `json:"sslType"`
	SslExpiredAt          *time.Time `json:"sslExpiredAt"`
	CreatedAt             time.Time  `json:"createdAt"`
	UpdatedAt             time.Time  `json:"updatedAt"`
	MultiAppsOnThisDomain bool       `json:"multiAppsOnThisDomain"`
	SharedDomain          bool       `json:"sharedDomain"`
	DedicatedIPs          []string   `json:"dedicatedIPs"`
	ForceHttps            int        `json:"forceHttps"`
}

func GetDomainBindings added in v1.2.0

func GetDomainBindings(appID string, domainType Type, groupName string) ([]DomainBinding, error)

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 GetAppInfoResult

type GetAppInfoResult struct {
	AppDomain string `json:"appDomain"`
	AppID     string `json:"appId"`
	AppKey    string `json:"appKey"`
	AppName   string `json:"appName"`
	HookKey   string `json:"hookKey"`
	MasterKey string `json:"masterKey"`
}

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:"appId"`
	AppKey    string `json:"appKey"`
	AppName   string `json:"appName"`
	MasterKey string `json:"masterKey"`
	AppDomain string `json:"appDomain"`
}

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

func LoginWithAccessToken added in v0.25.0

func LoginWithAccessToken(accessToken string, region regions.Region) (*GetUserInfoResult, error)

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 LeanDBCluster added in v0.26.0

type LeanDBCluster struct {
	ID           int    `json:"id"`
	AppID        string `json:"appId"`
	Name         string `json:"name"`
	Runtime      string `json:"runtime"`
	NodeQuota    string `json:"nodeQuota"`
	Status       string `json:"status"`
	AuthUser     string `json:"authUser"`
	AuthPassword string `json:"authPassword"`
}

type LeanDBClusterSlice added in v0.26.0

type LeanDBClusterSlice []*LeanDBCluster

func GetLeanDBClusterList added in v0.26.0

func GetLeanDBClusterList(appID string) (LeanDBClusterSlice, error)

func (LeanDBClusterSlice) Len added in v0.26.0

func (x LeanDBClusterSlice) Len() int

func (LeanDBClusterSlice) Less added in v0.26.0

func (x LeanDBClusterSlice) Less(i, j int) bool

NodeQuota: es-512 es-1024 mongo-512 redis-128 udb-500 compare: runtime -> quota -> id

func (LeanDBClusterSlice) Swap added in v0.26.0

func (x LeanDBClusterSlice) Swap(i, j int)

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 SSLType added in v1.2.0

type SSLType string
const (
	None      SSLType = "none"
	Automatic SSLType = "automatic"
	Uploaded  SSLType = "uploaded"
)

type State added in v1.2.0

type State string
const (
	VerifyingIcp   State = "verifyingIcp"
	VerifyingCname State = "verifyingCname"
	IssuingCert    State = "issuingCert"
	Normal         State = "normal"
	Suspended      State = "suspended"
	Failed         State = "failed"
)

type Type added in v1.2.0

type Type string
const (
	Platform      Type = "platform"
	File          Type = "file"
	Engine        Type = "engine"
	EngineCdn     Type = "engine-cdn"
	EnginePreview Type = "engine-preview"
	Billboard     Type = "billboard"
)

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