service

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const MaxRetryCount = 15

Variables

This section is empty.

Functions

func ActivateImage

func ActivateImage(wsID uint64, networkID string, imageId uint64) error

func DeactivateImage

func DeactivateImage(wsID uint64, networkID string, imageId uint64) error

func DeleteImage

func DeleteImage(wsID uint64, networkID string, imageId uint64) error

func DeleteNetworkSpecs

func DeleteNetworkSpecs(wsID uint64, networkID string) error

func ExpandNodeStorage

func ExpandNodeStorage(wsID uint64, nodeID uint64, size string) error

func GetSupportedNodeTypes

func GetSupportedNodeTypes(protocolKey string) ([]models.NodeType, error)

func Init

func Init(accessKey, secretKey string, baseURL string)

func InsertSessionKey

func InsertSessionKey(url string, key *SessionKey) error

func InviteMember

func InviteMember(wsID uint64, data *InviteMemberPayload) error

func ListImageVersions

func ListImageVersions(image string) ([]string, error)

func RestartNode

func RestartNode(wsID uint64, nodeID uint64) error

func ResumeNode

func ResumeNode(wsID uint64, nodeID uint64) error

func StopNode

func StopNode(wsID uint64, nodeID uint64) error

func TerminateNode

func TerminateNode(wsID uint64, nodeID uint64) error

func TransformConfig

func TransformConfig(wsID uint64, payload *payload.ConfigPayload, argumentSections *ArgumentSections) *models.Config

func UpdateImage

func UpdateImage(wsID uint64, nodeID uint64, data *UpdateNodeImagePayload) error

func UpdateNetworkSpec

func UpdateNetworkSpec(wsID uint64, networkID string, payload *UpdateNetworkSpecPayload) error

func UpdateNode

func UpdateNode(wsID uint64, nodeID uint64, data *UpdateNodePayload) error

func UpsertImage

func UpsertImage(wsID uint64, networkID string, payload *ImagePayload) error

Types

type ArgPayloadWrap

type ArgPayloadWrap struct {
	Key     *string
	Value   []*string
	File    *string
	Section *int
	Action  *models.Action
}

type ArgSectionItem

type ArgSectionItem struct {
	Title       *string `json:"title"`
	ExtraArgKey *string `json:"extraArgKey"`
	Index       *int    `json:"index"`
}

type ArgSectionItems

type ArgSectionItems []*ArgSectionItem

func (ArgSectionItems) GetItem

func (ast ArgSectionItems) GetItem(key string) *ArgSectionItem

type ArgumentSections

type ArgumentSections struct {
	Sections  ArgSectionItems `json:"sections"`
	Delimiter *string         `json:"delimiter"`
}

func GetArgumentSectionsByProtocol

func GetArgumentSectionsByProtocol(protocolKey string) (*ArgumentSections, error)

type Backups

type Backups struct {
	Id          string `json:"id"`
	NetworkSpec string `json:"networkSpec"`
	Protocol    string `json:"protocol"`
	ClusterHash string `json:"clusterHash"`
	StorageSize uint   `json:"storageSize"`
	PruningMode string `json:"pruningMode"`
}

func GetBackups

func GetBackups() ([]Backups, error)

func (Backups) GetNodeTypeFromPruningMode

func (b Backups) GetNodeTypeFromPruningMode() []string

func (Backups) GetNodeTypeFromPruningModeAndProtocol

func (b Backups) GetNodeTypeFromPruningModeAndProtocol() []string

type BootNode

type BootNode struct {
	NodeID  *string `json:"nodeId,omitempty"`
	Address *string `json:"address,omitempty"`
}

type BootstrapChainSpecMetadata

type BootstrapChainSpecMetadata struct {
}

type BootstrapChainSpecNode

type BootstrapChainSpecNode struct {
	Cluster  string                     `json:"cluster"`
	NodeName string                     `json:"nodeName"`
	Metadata BootstrapChainSpecMetadata `json:"metadata"`
}

type BootstrapChainSpecPayload

type BootstrapChainSpecPayload struct {
	Bootnode     BootstrapChainSpecNode `json:"bootnode"`
	Storage      string                 `json:"storage"`
	NodeSpecKey  string                 `json:"nodeSpecKey"`
	UseAPIKey    bool                   `json:"useApiKey"`
	ImageVersion string                 `json:"imageVersion"`
}

type CheckStatus

type CheckStatus struct {
	Step   string `json:"step"`
	Reason string `json:"reason"`
}

type Clusters

type Clusters struct {
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
	Name      string    `json:"name" header:"name"`
	Hash      string    `json:"hash" header:"hash"`
	Cloud     string    `json:"cloud" header:"cloud"`
	Region    string    `json:"region" header:"region"`
	Index     int       `json:"index" header:"index"`
	Active    bool      `json:"active" header:"active"`
}

type Config

type Config struct {
	Cmd            string          `json:"cmd"`
	CheckStatus    CheckStatus     `json:"checkStatus"`
	ClientFeatures map[string]bool `json:"clientFeatures"`
}

type CreateNetworkSpecModel

type CreateNetworkSpecModel struct {
	Name            string               `json:"name"`
	DisplayName     string               `json:"displayName"`
	Protocol        string               `json:"protocol"`
	ImageRepository string               `json:"imageRepository"`
	Metadata        *NetworkSpecMetadata `json:"metadata"`
	Config          *models.Config       `json:"config"`
}

type CreateNetworkSpecPayload

type CreateNetworkSpecPayload struct {
	Name            string  `json:"name"`
	DisplayName     string  `json:"displayName"`
	Protocol        string  `json:"protocol"`
	ImageRepository string  `json:"imageRepository"`
	ImageVersion    *string `json:"imageVersion,omitempty"`
	//Metadata        *NetworkSpecMetadata     `json:"metadata"`
	Config *payload.ConfigPayload `json:"config"`
}

type CreateNodePayload

type CreateNodePayload struct {
	NetworkSpecKey string            `json:"networkSpecKey"`
	NodeSpecKey    *string           `json:"nodeSpecKey"`
	NodeSpec       *NodeSpec         `json:"nodeSpec"`
	NodeType       models.NodeType   `json:"nodeType"`
	NodeName       string            `json:"nodeName"`
	ClusterHash    string            `json:"clusterKey"`
	Storage        *string           `json:"storage"`
	InitFromBackup bool              `json:"initFromBackup"`
	UseApiKey      bool              `json:"useApiKey"`
	ImageVersion   *string           `json:"imageVersion"`
	Client         *string           `json:"client"`
	PublicPort     bool              `json:"publicPort"`
	Metadata       *NodeMetadata     `json:"metadata"`
	Config         *NodeLaunchConfig `json:"config"`
}

type Endpoints

type Endpoints struct {
	RPC         string `json:"rpc"`
	WS          string `json:"ws"`
	P2pInternal string `json:"p2p-internal"`
	P2p         string `json:"p2p"`
	Metrics     string `json:"metrics"`
}

type ExtraArgs

type ExtraArgs map[string]*[]string

type ExtraEnvs

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

type GenerateChainSpecPayload

type GenerateChainSpecPayload struct {
	ImageVersion string   `json:"imageVersion" `
	CliArgs      []string `json:"cliArgs" `
}

type GenerateChainSpecResult

type GenerateChainSpecResult struct {
	TaskId     string `json:"taskId"`
	StatusCode int    `json:"statusCode"`
	Message    string `json:"message"`
	Error      string `json:"error"`
}

type ImageCheckStatus

type ImageCheckStatus string
const (
	Pending ImageCheckStatus = "pending"
	Success ImageCheckStatus = "success"
	Fail    ImageCheckStatus = "fail"
	Timeout ImageCheckStatus = "timeout"
)

type ImagePayload

type ImagePayload struct {
	ImageRepository string   `json:"imageRepository" header:"imageRepository"`
	Version         *string  `json:"version" header:"version"`
	Tags            []string `json:"tags"`
}

type ImageResult

type ImageResult struct {
	CreatedAt       time.Time        `json:"createdAt"`
	UpdatedAt       time.Time        `json:"updatedAt"`
	ID              uint64           `json:"id" header:"Id"`
	ProtocolKey     string           `json:"protocolKey"`
	ImageRepository string           `json:"imageRepository" header:"ImageRepository"`
	Version         string           `json:"version" header:"Version"`
	Client          string           `json:"client"`
	Active          bool             `json:"active" header:"Active"`
	Config          Config           `json:"config"`
	Status          ImageCheckStatus `json:"status"`
	Image           string           `json:"image"`
}

func CheckImage

func CheckImage(payload *ImagePayload) (*ImageResult, error)

func GetImage

func GetImage(wsID uint64, networkID string) ([]*ImageResult, error)

type Info

type Info struct {
	Clusters  []Clusters  `json:"clusters" header:"clusters"`
	NodeSpecs []NodeSpecs `json:"nodeSpecs" header:"nodeSpecs"`
	Protocols []Protocols `json:"protocols" header:"protocols"`
}

func GetInfo

func GetInfo() (Info, error)

type InviteLog

type InviteLog struct {
	ID     uint64 `json:"id,string"`
	Email  string `json:"email"`
	Role   string `json:"role"`
	IsDone bool   `json:"isDone"`
}

func GetInvitations

func GetInvitations(wsID uint64) ([]InviteLog, error)

type InviteMemberPayload

type InviteMemberPayload struct {
	Email string `json:"email"`
	Role  string `json:"role"`
}

type Member

type Member struct {
	ID    uint64 `json:"id,string"`
	Name  string `json:"name"`
	Email string `json:"email"`
	Role  string `json:"role"`
}

func GetMembers

func GetMembers(wsID uint64) ([]Member, error)

type Metadata

type Metadata struct {
	Rules            map[models.NodeType]interface{} `json:"rules" header:"rules"`
	ArgumentSections *ArgumentSections               `json:"argumentSections" `
}

type NetworkSpec

type NetworkSpec struct {
	Key             string              `json:"key" header:"Key"`
	Name            string              `json:"name" `
	DisplayName     string              `json:"displayName" header:"Name"`
	ProtocolKey     string              `json:"protocolKey" header:"Protocol"`
	IsPublic        bool                `json:"isPublic" header:"Public"`
	ImageRepository string              `json:"imageRepository" header:"Image"`
	WorkspaceID     uint64              `json:"workspaceId,string"`
	Status          string              `json:"status"`
	Metadata        NetworkSpecMetadata `json:"metadata"  header:"Status"`
	CreatedAt       time.Time           `json:"createdAt" `
	UpdatedAt       time.Time           `json:"updatedAt" `
	Recommend       *Recommend          `json:"recommend,omitempty"`
	NodeTypes       []SpecNodeType      `json:"nodeTypes,omitempty"`
	Config          *models.Config      `json:"config"`
}

func CreateNetworkSpecs

func CreateNetworkSpecs(wsID uint64, payload *CreateNetworkSpecPayload) (*NetworkSpec, error)

func GetNetworkSpec

func GetNetworkSpec(wsID uint64, networkID string) (*NetworkSpec, error)

func GetNetworkSpecs

func GetNetworkSpecs(wsID uint64) ([]NetworkSpec, error)

func (*NetworkSpec) MergeConfig

func (c *NetworkSpec) MergeConfig(config *models.Config)

type NetworkSpecBackups

type NetworkSpecBackups struct {
	Key              string `json:"key" header:"Network Spec Key"`
	Name             string `json:"name"`
	DisplayName      string `json:"displayName" header:"Name"`
	ProtocolKey      string `json:"protocolKey"`
	AvailNodeTypes   string `json:"availNodeTypes" header:"Node Type"`
	MinStorageSize   uint   `json:"minStorageSize" header:"Min Storage Size (Gb)"`
	AvailCloudRegion string `json:"availCloudRegion" header:"Cloud & Region"`
	ClusterKey       string `json:"cluserKey" header:"Cluster Key"`
}

func GetBackupNetworkSpecs

func GetBackupNetworkSpecs() ([]NetworkSpecBackups, error)

type NetworkSpecMetadata

type NetworkSpecMetadata struct {
	Recommend        *Recommend `json:"recommend,omitempty"`
	ChainSpec        *string    `json:"chainspec,omitempty"`
	ImageVersion     *string    `json:"imageVersion,omitempty"`
	Command          *string    `json:"command,omitempty"`
	VersionList      []string   `json:"versionList,omitempty"`
	BootNodes        []string   `json:"bootnodes,omitempty"`
	FetchRcChainspec *string    `json:"fetchRcChainspec,omitempty"`
	RcChainspec      *string    `json:"rcChainspec,omitempty"`
	RcExtraArgs      []string   `json:"rcExtraArgs,omitempty"`
	ExtraArgs        []string   `json:"extraArgs,omitempty"`
	ParachainId      *int       `json:"parachainId,omitempty"`
	Cluster          *string    `json:"cluster,omitempty"`
}

type Node

type Node struct {
	ID                 uint64       `json:"id,string" header:"ID"`
	Name               string       `json:"name" header:"Name"`
	NetworkSpecKey     string       `json:"networkSpecKey" header:"Network"`
	WorkspaceID        uint64       `json:"workspaceId,string"`
	OwnerID            uint64       `json:"ownerId,string"`
	NodeType           string       `json:"type"`
	NodeSpec           string       `json:"nodeSpec"`
	CPU                string       `json:"cpu"`
	Ram                string       `json:"ram"`
	NodeSpecMultiplier float32      `json:"nodeSpecMultiplier"`
	Storage            string       `json:"storage"`
	StorageType        string       `json:"storageType"`
	Image              string       `json:"image"`
	ClusterHash        string       `json:"clusterHash" header:"Cluster"`
	Status             string       `json:"status" header:"Status"`
	Metadata           NodeMetadata `json:"metadata"`
	NetworkSpec        *NetworkSpec `json:"networkSpec"`
	Endpoints          *Endpoints   `json:"endpoints"`
	AvailableVersions  []string     `json:"availableVersions"`
	HasUpgrade         bool         `json:"hasUpgrade"`
}

func CreateNode

func CreateNode(wsID uint64, data *CreateNodePayload) (*Node, error)

func GetNodeDetail

func GetNodeDetail(wsID uint64, nodeID uint64, extrasFlag ...int) (*Node, error)

type NodeItem

type NodeItem struct {
	ID             uint64 `json:"id,string" header:"ID"`
	Name           string `json:"name" header:"Name"`
	NetworkSpecKey string `json:"networkSpecKey" header:"Network"`
	ClusterHash    string `json:"clusterHash" header:"Cluster"`
	Status         string `json:"status" header:"Status"`
	Image          string `json:"image" header:"image"`
}

func GetNodeList

func GetNodeList(wsID uint64) ([]NodeItem, error)

type NodeLaunchConfig

type NodeLaunchConfig struct {
	Vars      []*Vars      `json:"vars"`
	ExtraArgs *ExtraArgs   `json:"extraArgs"`
	ExtraEnvs []*ExtraEnvs `json:"extraEnvs"`
}

type NodeMetadata

type NodeMetadata struct {
	NodeKey    *string           `json:"nodeKey,omitempty"`
	SkipName   bool              `json:"skipName"`
	ExtraArgs  []string          `json:"extraArgs,omitempty"`
	Client     *string           `json:"client,omitempty"`
	RpcMethods *string           `json:"rpcMethods,omitempty"`
	Labels     map[string]string `json:"labels,omitempty"`
}

type NodeRecommendation

type NodeRecommendation struct {
	Network            string `json:"network" header:"network"`
	NodeSpec           string `json:"nodeSpec" header:"nodeSpec"`
	NodeSpecMultiplier int    `json:"nodeSpecMultiplier" header:"nodeSpecMultiplier"`
	StorageSize        int    `json:"storageSize" header:"storageSize"`
	ImageVersion       string `json:"imageVersion" header:"imageVersion"`
	Client             string `json:"client" header:"client"`
}

func NodeRecommends

func NodeRecommends(network string) (NodeRecommendation, error)

type NodeSpec

type NodeSpec struct {
	Key        string `json:"key"`
	Multiplier int    `json:"multiplier"`
}

type NodeSpecPrice

type NodeSpecPrice struct {
	Available bool   `json:"available" header:"available"`
	Price     string `json:"price" header:"price"`
}

type NodeSpecs

type NodeSpecs struct {
	CreatedAt     time.Time     `json:"createdAt"`
	UpdatedAt     time.Time     `json:"updatedAt"`
	Key           string        `json:"key" header:"key"`
	Name          string        `json:"name" header:"name"`
	CPU           string        `json:"cpu" header:"cpu"`
	Memory        string        `json:"memory" header:"memory"`
	Active        bool          `json:"active" header:"active"`
	Priority      int           `json:"priority" header:"priority"`
	Protocol      string        `json:"protocol" header:"protocol"`
	Network       string        `json:"network" header:"network"`
	Price         NodeSpecPrice `json:"price" header:"price"`
	MaxMultiplier int           `json:"maxMultiplier" header:"maxMultiplier"`
}

type NodeStatus

type NodeStatus struct {
	Status string `json:"status"`
}

func GetNodeStatus

func GetNodeStatus(wsID uint64, nodeID uint64) (*NodeStatus, error)

type Protocols

type Protocols struct {
	CreatedAt         time.Time `json:"createdAt"`
	UpdatedAt         time.Time `json:"updatedAt"`
	Key               string    `json:"key" header:"key"`
	Name              string    `json:"name" header:"name"`
	Derivable         bool      `json:"derivable" header:"derivable"`
	ImageRepositories []string  `json:"imageRepositories" header:"images"`
	Metadata          *Metadata `json:"metadata" header:"metadata"`
}

type Recommend

type Recommend struct {
	ImageVersion string `json:"imageVersion"`
	NodeSpec     string `json:"nodeSpec"`
	StorageSize  uint   `json:"storageSize"`
}

type SessionKey

type SessionKey struct {
	Scheme    string `json:"scheme"`
	Phrase    string `json:"phrase"`
	PublicKey string `json:"publicKey"`
}

type SpecNodeType

type SpecNodeType struct {
	Key       string     `json:"key"`
	Recommend *Recommend `json:"recommend,omitempty"`
}

type UpdateNetworkSpecModel

type UpdateNetworkSpecModel struct {
	DisplayName *string        `json:"displayName"`
	Config      *models.Config `json:"config"`
}

type UpdateNetworkSpecPayload

type UpdateNetworkSpecPayload struct {
	DisplayName *string                `json:"displayName"`
	Config      *payload.ConfigPayload `json:"config"`
}

type UpdateNodeImagePayload

type UpdateNodeImagePayload struct {
	ImageVersion *string `json:"imageVersion"`
}

type UpdateNodePayload

type UpdateNodePayload struct {
	NodeSpecKey  *string           `json:"nodeSpecKey"`
	NodeSpec     *NodeSpec         `json:"nodeSpec"`
	NodeType     *string           `json:"nodeType"`
	NodeName     *string           `json:"nodeName"`
	ImageVersion *string           `json:"imageVersion"`
	Metadata     *NodeMetadata     `json:"metadata"`
	Config       *NodeLaunchConfig `json:"config"`
}

type UploadResult

type UploadResult struct {
	Key *string `json:"key"`
}

func UploadPrivateFile

func UploadPrivateFile(wsID uint64, files []string) (*UploadResult, error)

type Value

type Value struct {
	ValueType models.VarValueType `json:"valueType"`
	Payload   interface{}         `json:"payload"`
}

type Vars

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

type Workspace

type Workspace struct {
	ID              uint64     `json:"id,string" header:"ID"`
	Name            string     `json:"name" header:"Name"`
	Plan            string     `json:"plan" header:"Plan"`
	OwnerID         uint64     `json:"ownerId,string"`
	BillingType     string     `json:"billingType"`
	PaymentMethodID string     `json:"paymentMethodId"`
	Active          bool       `json:"active"`
	SuspendAt       *time.Time `json:"suspendAt"`
	CreateAt        *time.Time `json:"createdAt"`
	UpdateAt        *time.Time `json:"updateAt"`
}

func GetWorkspaceList

func GetWorkspaceList() ([]Workspace, error)

Jump to

Keyboard shortcuts

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