api

package
v1.0.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 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

This section is empty.

Types

type BackupRequest

type BackupRequest struct {
	Successful bool   `json:"successful"`
	Sha256Hash string `json:"sha256_hash"`
	FileSize   int64  `json:"file_size"`
}

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 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(uuid string, backup string, data BackupRequest) (*RequestError, error)

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 sftp_server.AuthenticationRequest) (*sftp_server.AuthenticationResponse, error)

type ProcessConfiguration

type ProcessConfiguration struct {
	Startup struct {
		Done            string   `json:"done"`
		UserInteraction []string `json:"userInteraction"`
	} `json:"startup"`
	Stop struct {
		Type  string `json:"type"`
		Value string `json:"value"`
	} `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 RequestError

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

func (*RequestError) String

func (re *RequestError) String() string

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

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.

Jump to

Keyboard shortcuts

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