api

package
v1.0.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProcessStopCommand    = "command"
	ProcessStopSignal     = "signal"
	ProcessStopNativeStop = "stop"
)

Variables

This section is empty.

Functions

func IsInvalidCredentialsError

func IsInvalidCredentialsError(err error) bool

func IsRequestError

func IsRequestError(err error) bool

Types

type BackupRequest

type BackupRequest struct {
	Checksum     string `json:"checksum"`
	ChecksumType string `json:"checksum_type"`
	Size         int64  `json:"size"`
	Successful   bool   `json:"successful"`
}

type InstallationScript

type InstallationScript struct {
	ContainerImage string `json:"container_image"`
	Entrypoint     string `json:"entrypoint"`
	Script         string `json:"script"`
}

Defines installation script information for a server process. This is used when a server is installed for the first time, and when a server is marked for re-installation.

type OutputLineMatcher

type OutputLineMatcher struct {
	// contains filtered or unexported fields
}

func (*OutputLineMatcher) Matches

func (olm *OutputLineMatcher) Matches(s string) bool

Determine if a given string "s" matches the given line.

func (*OutputLineMatcher) String

func (olm *OutputLineMatcher) String() string

Return the matcher's raw comparison string.

func (*OutputLineMatcher) UnmarshalJSON

func (olm *OutputLineMatcher) UnmarshalJSON(data []byte) error

Unmarshal the startup lines into individual structs for easier matching abilities.

type PanelRequest

type PanelRequest struct {
	Response *http.Response
}

func NewRequester

func NewRequester() *PanelRequest

Initializes the requester instance.

func (*PanelRequest) Error

func (r *PanelRequest) Error() *RequestError

Returns the error message from the API call as a string. The error message will be formatted similar to the below example:

HttpNotFoundException: The requested resource does not exist. (HTTP/404)

func (*PanelRequest) Get

func (r *PanelRequest) Get(url string) (*http.Response, error)

func (*PanelRequest) GetAllServerConfigurations

func (r *PanelRequest) GetAllServerConfigurations() (map[string]*ServerConfigurationResponse, *RequestError, error)

GetAllServerConfigurations fetches configurations for all servers assigned to this node.

func (*PanelRequest) GetClient

func (r *PanelRequest) GetClient() *http.Client

Builds the base request instance that can be used with the HTTP client.

func (*PanelRequest) GetEndpoint

func (r *PanelRequest) GetEndpoint(endpoint string) string

func (*PanelRequest) GetInstallationScript

func (r *PanelRequest) GetInstallationScript(uuid string) (InstallationScript, *RequestError, error)

Fetches installation information for the server process.

func (*PanelRequest) GetServerConfiguration

func (r *PanelRequest) GetServerConfiguration(uuid string) (*ServerConfigurationResponse, *RequestError, error)

Fetches the server configuration and returns the struct for it.

func (*PanelRequest) HasError

func (r *PanelRequest) HasError() bool

Determines if the API call encountered an error. If no request has been made the response will be false.

func (*PanelRequest) HttpResponseCode

func (r *PanelRequest) HttpResponseCode() int

func (*PanelRequest) Post

func (r *PanelRequest) Post(url string, data []byte) (*http.Response, error)

func (*PanelRequest) ReadBody

func (r *PanelRequest) ReadBody() ([]byte, error)

Reads the body from the response and returns it, then replaces it on the response so that it can be read again later.

func (*PanelRequest) SendArchiveStatus

func (r *PanelRequest) SendArchiveStatus(uuid string, successful bool) (*RequestError, error)

func (*PanelRequest) SendBackupStatus

func (r *PanelRequest) SendBackupStatus(backup string, data BackupRequest) (*RequestError, error)

Notifies the panel that a specific backup has been completed and is now available for a user to view and download.

func (*PanelRequest) SendInstallationStatus

func (r *PanelRequest) SendInstallationStatus(uuid string, successful bool) (*RequestError, error)

Marks a server as being installed successfully or unsuccessfully on the panel.

func (*PanelRequest) SendTransferFailure

func (r *PanelRequest) SendTransferFailure(uuid string) (*RequestError, error)

func (*PanelRequest) SendTransferSuccess

func (r *PanelRequest) SendTransferSuccess(uuid string) (*RequestError, error)

func (*PanelRequest) SetHeaders

func (r *PanelRequest) SetHeaders(req *http.Request) *http.Request

func (*PanelRequest) ValidateSftpCredentials

func (r *PanelRequest) ValidateSftpCredentials(request SftpAuthRequest) (*SftpAuthResponse, error)

type ProcessConfiguration

type ProcessConfiguration struct {
	Startup struct {
		Done            []*OutputLineMatcher `json:"done"`
		UserInteraction []string             `json:"user_interaction"`
		StripAnsi       bool                 `json:"strip_ansi"`
	} `json:"startup"`

	Stop ProcessStopConfiguration `json:"stop"`

	ConfigurationFiles []parser.ConfigurationFile `json:"configs"`
}

Defines the process configuration for a given server instance. This sets what the daemon is looking for to mark a server as done starting, what to do when stopping, and what changes to make to the configuration file for a server.

type ProcessStopConfiguration

type ProcessStopConfiguration struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

type RequestError

type RequestError struct {
	Code   string `json:"code"`
	Status string `json:"status"`
	Detail string `json:"detail"`
}

func (*RequestError) Error

func (re *RequestError) Error() string

Returns the error response in a string form that can be more easily consumed.

func (*RequestError) String

func (re *RequestError) String() string

type RequestErrorBag

type RequestErrorBag struct {
	Errors []RequestError `json:"errors"`
}

type ServerConfigurationResponse

type ServerConfigurationResponse struct {
	Settings             json.RawMessage       `json:"settings"`
	ProcessConfiguration *ProcessConfiguration `json:"process_configuration"`
}

Holds the server configuration data returned from the Panel. When a server process is started, Wings communicates with the Panel to fetch the latest build information as well as get all of the details needed to parse the given Egg.

This means we do not need to hit Wings each time part of the server is updated, and the Panel serves as the source of truth at all times. This also means if a configuration is accidentally wiped on Wings we can self-recover without too much hassle, so long as Wings is aware of what servers should exist on it.

type SftpAuthRequest

type SftpAuthRequest struct {
	User          string `json:"username"`
	Pass          string `json:"password"`
	IP            string `json:"ip"`
	SessionID     []byte `json:"session_id"`
	ClientVersion []byte `json:"client_version"`
}

type SftpAuthResponse

type SftpAuthResponse struct {
	Server      string   `json:"server"`
	Token       string   `json:"token"`
	Permissions []string `json:"permissions"`
}

Jump to

Keyboard shortcuts

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