nitrado

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	sync.Mutex

	UserAgent string

	// Base URL for API requests. Defaults to the public Nitrado API. BaseURL should
	// always be specified with a trailing slash.
	BaseURI *url.URL

	// Services used for talking to different parts of the Nitrado API.
	FileServerService   *FileServerService
	GameServers         *GameServersService
	GameServersSettings *GSSettingsService
	GameServerStats     *GameServerStatsService
	PlayerListService   *PlayerListService
	Services            *ServicesService
	// contains filtered or unexported fields
}

Client represents the config of the Nitrado.net Client

func NewClient

func NewClient(apiToken string) *Client

NewClient creates a new instance of a NitradoAPI

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

Do sends an API request to the Nitrado API and returns a response object. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURI of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.

type File

type File struct {
	Owner      string `json:"owner,omitempty"`
	CreatedAt  int    `json:"created_at,omitempty"`
	Path       string `json:"path,omitempty"`
	Size       int    `json:"size,omitempty"`
	AccessedAt int    `json:"accessed_at,omitempty"`
	ModifiedAt int    `json:"modified_at,omitempty"`
	Type       string `json:"type,omitempty"`
	Chmod      string `json:"chmod,omitempty"`
	Group      string `json:"group,omitempty"`
	Name       string `json:"name,omitempty"`
}

File contains the details of a file

type FileBookmarks

type FileBookmarks struct {
	Status string `json:"status"`
	Data   struct {
		Bookmarks []string `json:"bookmarks"`
	} `json:"data"`
}

FileBookmarks contains the list of file locations on a game server

type FileDownloadResp added in v0.12.0

type FileDownloadResp struct {
	Status string `json:"status,omitempty"`
	Data   struct {
		Token struct {
			URL   string `json:"url,omitempty"`
			Token string `json:"token,omitempty"`
		} `json:"token,omitempty"`
	} `json:"data,omitempty"`
}

FileDownloadResp contains the response object from the download method on a fileserver

type FileLink struct {
	Status string `json:"status"`
	Data   struct {
		Token struct {
			URL   string `json:"url"`
			Token string `json:"token"`
		} `json:"token"`
	} `json:"data"`
}

FileLink contains a download link to a file

type FileListResp

type FileListResp struct {
	Status string `json:"status,omitempty"`
	Data   struct {
		Entries []File `json:"entries,omitempty"`
	} `json:"data,omitempty"`
}

FileListResp contains a listing of the files at a location

type FileServerDownloadOptions added in v0.15.0

type FileServerDownloadOptions struct {
	File string `url:"file,omitempty"`
}

FileServerDownloadOptions controls the query string settings that a download request can take.

type FileServerListOptions added in v0.15.0

type FileServerListOptions struct {
	Dir    string `url:"dir,omitempty"`
	Search string `url:"search,omitempty"`
}

FileServerListOptions controls the query string settings that a list request can take.

type FileServerService

type FileServerService apiService

FileServerService provides access to the service related functions in the Nitrado API.

Nitrado API docs: https://doc.nitrado.net/

func (*FileServerService) Download added in v0.12.0

Download a given file on a GameServer.

Nitrado API docs: https://doc.nitrado.net/#api-Gameserver-GameserverFilesDownload

func (*FileServerService) List

List files on a GameServer.

Nitrado API docs: https://doc.nitrado.net/#api-Gameserver-GameserverFilesList

func (*FileServerService) Upload added in v0.18.0

Upload a given file on a GameServer.

Nitrado API docs: https://doc.nitrado.net/#api-Gameserver-GameserverFilesUpload

type FileServerUploadOptions added in v0.18.0

type FileServerUploadOptions struct {
	Path string `url:"path,omitempty"`
	File string `url:"file,omitempty"`
}

FileServerUploadOptions controls the query string settings that an upload request can take.

type GSSettingsResp added in v0.15.0

type GSSettingsResp struct {
	Status string `json:"status,omitempty"`
}

GSSettingsResp contains the response object from the download method on a fileserver

type GSSettingsService added in v0.15.0

type GSSettingsService apiService

GSSettingsService provides access to the service related functions in the Nitrado API.

Nitrado API docs: https://doc.nitrado.net/

func (*GSSettingsService) Update added in v0.15.0

func (s *GSSettingsService) Update(serviceID int, opts GSSettingsUpdateOptions) error

Update a setting on a GameServer by service ID.

Nitrado API docs: https://doc.nitrado.net/#api-Gameserver-Details Requires a settings category as well as a key and value for the setting.

type GSSettingsUpdateOptions added in v0.15.0

type GSSettingsUpdateOptions struct {
	Category string `url:"category,omitempty"`
	Key      string `url:"key,omitempty"`
	Value    string `url:"value"`
}

GSSettingsUpdateOptions controls the query string settings that a settings request can take.

type GSStats added in v0.19.0

type GSStats struct {
	CPUUsage       [][]float32 `json:"cpuUsage"`
	CurrentPlayers [][]float32 `json:"currentPlayers"`
	MaxPlayers     [][]float32 `json:"maxPlayers"`
	MemoryUsage    [][]float32 `json:"memoryUsage"`
}

GSStats contains a stats object for a game server

type GSStatsResp added in v0.19.0

type GSStatsResp struct {
	Status string `json:"status"`
	Data   struct {
		Stats GSStats `json:"stats"`
	} `json:"data"`
}

GSStatsResp contains the response object from the stats method on a gameserver

type GameServer

type GameServer struct {
	Status           string `json:"status,omitempty"`
	LastStatusChange int    `json:"last_status_change,omitempty"`
	MustBeStarted    bool   `json:"must_be_started,omitempty"`
	Username         string `json:"username,omitempty"`
	UserID           int    `json:"user_id,omitempty"`
	ServiceID        int    `json:"service_id,omitempty"`
	IP               string `json:"ip,omitempty"`
	Port             int    `json:"port,omitempty"`
	QueryPort        int    `json:"query_port,omitempty"`
	RconPort         int    `json:"rcon_port,omitempty"`
	Type             string `json:"type,omitempty"`
	Memory           string `json:"memory,omitempty"`
	MemoryMb         int    `json:"memory_mb,omitempty"`
	Game             string `json:"game,omitempty"`
	GameHuman        string `json:"game_human,omitempty"`
	GameSpecific     struct {
		Path         string   `json:"path,omitempty"`
		UpdateStatus string   `json:"update_status,omitempty"`
		LastUpdate   string   `json:"last_update,omitempty"`
		LogFiles     []string `json:"log_files,omitempty"`
		ConfigFiles  []string `json:"config_files,omitempty"`
	} `json:"game_specific,omitempty"`
	Slots       int    `json:"slots,omitempty"`
	Location    string `json:"location,omitempty"`
	Credentials struct {
		Ftp struct {
			Hostname string `json:"hostname,omitempty"`
			Port     int    `json:"port,omitempty"`
			Username string `json:"username,omitempty"`
			Password string `json:"password,omitempty"`
		} `json:"ftp,omitempty"`
		Mysql struct {
			Hostname string `json:"hostname,omitempty"`
			Port     int    `json:"port,omitempty"`
			Username string `json:"username,omitempty"`
			Password string `json:"password,omitempty"`
			Database string `json:"database,omitempty"`
		} `json:"mysql,omitempty"`
	} `json:"credentials,omitempty"`
	Settings struct {
		Config struct {
			Hostname                    string `json:"hostname,omitempty"`
			VonCodecQuality             string `json:"vonCodecQuality,omitempty"`
			DisableVoN                  string `json:"disableVoN,omitempty"`
			Password                    string `json:"password,omitempty"`
			ServerTimeAcceleration      string `json:"serverTimeAcceleration,omitempty"`
			ServerNightTimeAcceleration string `json:"serverNightTimeAcceleration,omitempty"`
			ServerTimePersistent        string `json:"serverTimePersistent,omitempty"`
			Disable3RdPerson            string `json:"disable3rdPerson,omitempty"`
			DisableCrosshair            string `json:"disableCrosshair,omitempty"`
			UseServerTime               string `json:"useServerTime,omitempty"`
			CustomServerTime            string `json:"customServerTime,omitempty"`
			EnableMouseAndKeyboard      string `json:"enableMouseAndKeyboard,omitempty"`
			EnableWhitelist             string `json:"enableWhitelist,omitempty"`
			Mission                     string `json:"mission,omitempty"`
			AdminLogPlayerHitsOnly      string `json:"adminLogPlayerHitsOnly,omitempty"`
			AdminLogPlacement           string `json:"adminLogPlacement,omitempty"`
			AdminLogBuildActions        string `json:"adminLogBuildActions,omitempty"`
			AdminLogPlayerList          string `json:"adminLogPlayerList,omitempty"`
			LightingConfig              string `json:"lightingConfig,omitempty"`
			DisablePersonalLight        string `json:"disablePersonalLight,omitempty"`
			DisableBaseDamage           string `json:"disableBaseDamage,omitempty"`
			DisableContainerDamage      string `json:"disableContainerDamage,omitempty"`
			EnableCFGGameplayFile       string `json:"enableCfgGameplayFile,omitempty"`
		} `json:"config,omitempty"`
		General struct {
			ExpertMode     string `json:"expertMode,omitempty"`
			AdminPassword  string `json:"admin-password,omitempty"`
			Nolog          string `json:"nolog,omitempty"`
			RconPassword   string `json:"rcon-password,omitempty"`
			AdditionalMods string `json:"additionalMods,omitempty"`
			Bans           string `json:"bans,omitempty"`
			Whitelist      string `json:"whitelist,omitempty"`
			Resetmission   string `json:"resetmission,omitempty"`
			Priority       string `json:"priority,omitempty"`
		} `json:"general,omitempty"`
	} `json:"settings,omitempty"`
	Quota interface{} `json:"quota,omitempty"`
	Query struct {
		ServerName    string `json:"server_name,omitempty"`
		ConnectIP     string `json:"connect_ip,omitempty"`
		Map           string `json:"map,omitempty"`
		Version       string `json:"version,omitempty"`
		PlayerCurrent int    `json:"player_current,omitempty"`
		PlayerMax     int    `json:"player_max,omitempty"`
	} `json:"query,omitempty"`
}

GameServer contains a Game Server details

type GameServerDetailResp

type GameServerDetailResp struct {
	Status string `json:"status,omitempty"`
	Data   struct {
		GameServer GameServer `json:"gameserver,omitempty"`
	} `json:"data,omitempty"`
}

GameServerDetailResp contains the query response from the Nitrado API for the GameServer operation

type GameServerRestartResp added in v0.13.0

type GameServerRestartResp struct {
	Status  string `json:"status,omitempty"`
	Message string `json:"message,omitempty"`
}

GameServerRestartResp contains the query response from the Nitrado API for the GameServer operation

type GameServerStatsService added in v0.19.0

type GameServerStatsService apiService

GameServerStatsService provides access to the service related functions in the Nitrado API.

Nitrado API docs: https://doc.nitrado.net/

func (*GameServerStatsService) Get added in v0.19.0

func (s *GameServerStatsService) Get(serviceID int) (*GSStats, *http.Response, error)

Get stats from a GameServer by service ID.

Nitrado API docs: https://doc.nitrado.net/#api-Gameserver-Stats

type GameServersService

type GameServersService apiService

GameServersService provides access to the service related functions in the Nitrado API.

Nitrado API docs: https://doc.nitrado.net/

func (*GameServersService) Get

func (s *GameServersService) Get(serviceID int) (*GameServer, *http.Response, error)

Get a GameServer by service ID.

Nitrado API docs: https://doc.nitrado.net/#api-Gameserver-Details

func (*GameServersService) Restart added in v0.13.0

func (s *GameServersService) Restart(serviceID int) error

Restart a GameServer by service ID.

Nitrado API docs: https://doc.nitrado.net/#api-Gameserver-Details

type Player added in v0.21.0

type Player struct {
	Name    string   `json:"name,omitempty"`
	ID      string   `json:"id,omitempty"`
	IDType  string   `json:"id_type,omitempty"`
	Online  string   `json:"online,omitempty"`
	Actions []string `json:"actions,omitempty"`
}

Player contains the details of a player

type PlayerListResp added in v0.21.0

type PlayerListResp struct {
	Status string `json:"status,omitempty"`
	Data   struct {
		Players []Player `json:"players,omitempty"`
	} `json:"data,omitempty"`
}

PlayerListResp contains a listing of the players for a gameserver

type PlayerListService added in v0.21.0

type PlayerListService apiService

PlayerListService provides access to the player list related functions in the Nitrado API.

Nitrado API docs: https://doc.nitrado.net/#api-Player_Management-ListPlayers

func (*PlayerListService) List added in v0.21.0

func (s *PlayerListService) List(svc Service) ([]Player, *http.Response, error)

List players on a GameServer.

Nitrado API docs: https://doc.nitrado.net/#api-Gameserver-GameserverFilesList

type Service

type Service struct {
	ID                    int         `json:"id,omitempty"`
	LocationID            int         `json:"location_id,omitempty"`
	Status                string      `json:"status,omitempty"`
	WebsocketToken        string      `json:"websocket_token,omitempty"`
	UserID                int         `json:"user_id,omitempty"`
	Comment               interface{} `json:"comment,omitempty"`
	AutoExtension         bool        `json:"auto_extension,omitempty"`
	AutoExtensionDuration int         `json:"auto_extension_duration,omitempty"`
	Type                  string      `json:"type,omitempty"`
	TypeHuman             string      `json:"type_human,omitempty"`
	Details               struct {
		Address       string `json:"address,omitempty"`
		Name          string `json:"name,omitempty"`
		Game          string `json:"game,omitempty"`
		PortlistShort string `json:"portlist_short,omitempty"`
		FolderShort   string `json:"folder_short,omitempty"`
		Slots         int    `json:"slots,omitempty"`
	} `json:"details,omitempty"`
	StartDate    string   `json:"start_date,omitempty"`
	SuspendDate  string   `json:"suspend_date,omitempty"`
	DeleteDate   string   `json:"delete_date,omitempty"`
	SuspendingIn int      `json:"suspending_in,omitempty"`
	DeletingIn   int      `json:"deleting_in,omitempty"`
	Username     string   `json:"username,omitempty"`
	Roles        []string `json:"roles,omitempty"`
}

Service contains the structure of a service object

type ServiceDetailResp

type ServiceDetailResp struct {
	Status string `json:"status,omitempty"`
	Data   struct {
		Service Service `json:"service,omitempty"`
	} `json:"data,omitempty"`
}

ServiceDetailResp contains a list of services

type ServiceListResp

type ServiceListResp struct {
	Status string `json:"status,omitempty"`
	Data   struct {
		Services []Service `json:"services,omitempty"`
	} `json:"data,omitempty"`
}

ServiceListResp contains a list of services

type ServicesService

type ServicesService apiService

ServicesService provides access to the service related functions in the Nitrado API.

Nitrado API docs: https://doc.nitrado.net/

func (*ServicesService) Get

func (s *ServicesService) Get(ID int) (*Service, *http.Response, error)

Get a Service by ID.

Nitrado API docs: https://doc.nitrado.net/#api-Service-Details

func (*ServicesService) List

func (s *ServicesService) List() (*[]Service, *http.Response, error)

List all services.

Nitrado API docs: https://doc.nitrado.net/#api-Service-List

Jump to

Keyboard shortcuts

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