Documentation ¶
Index ¶
- Variables
- func CacheExpires(r *http.Response) time.Time
- type APIClient
- type APIKey
- type APIResponse
- type AddRandomPortResponse
- type BasicAuth
- type Config
- type ConfigApiService
- func (a *ConfigApiService) Create(ctx _context.Context, username string, initRequest InitRequest) (Webspace, *_nethttp.Response, error)
- func (a *ConfigApiService) Delete(ctx _context.Context, username string) (*_nethttp.Response, error)
- func (a *ConfigApiService) Get(ctx _context.Context, username string) (Webspace, *_nethttp.Response, error)
- func (a *ConfigApiService) GetConfig(ctx _context.Context, username string) (Config, *_nethttp.Response, error)
- func (a *ConfigApiService) UpdateConfig(ctx _context.Context, username string, config Config) (Config, *_nethttp.Response, error)
- type Configuration
- type ConsoleApiService
- func (a *ConsoleApiService) ClearLog(ctx _context.Context, username string) (*_nethttp.Response, error)
- func (a *ConsoleApiService) Console(ctx _context.Context, username string) (*_nethttp.Response, error)
- func (a *ConsoleApiService) Exec(ctx _context.Context, username string, execRequest ExecRequest) (ExecResponse, *_nethttp.Response, error)
- func (a *ConsoleApiService) ExecInteractive(ctx _context.Context, username string) (*_nethttp.Response, error)
- func (a *ConsoleApiService) GetLog(ctx _context.Context, username string) (string, *_nethttp.Response, error)
- type DomainsApiService
- func (a *DomainsApiService) AddDomain(ctx _context.Context, username string, domain string) (*_nethttp.Response, error)
- func (a *DomainsApiService) GetDomains(ctx _context.Context, username string) ([]string, *_nethttp.Response, error)
- func (a *DomainsApiService) RemoveDomain(ctx _context.Context, username string, domain string) (*_nethttp.Response, error)
- type Error
- type ExecInteractiveControl
- type ExecInteractiveRequest
- type ExecRequest
- type ExecResponse
- type GenericOpenAPIError
- type Image
- type ImageAlias
- type ImagesApiService
- type InitRequest
- type InterfaceAddress
- type InterfaceCounters
- type NetworkInterface
- type PortsApiService
- func (a *PortsApiService) AddPort(ctx _context.Context, username string, ePort int32, iPort int32) (*_nethttp.Response, error)
- func (a *PortsApiService) AddRandomPort(ctx _context.Context, username string, iPort int32) (AddRandomPortResponse, *_nethttp.Response, error)
- func (a *PortsApiService) GetPorts(ctx _context.Context, username string) (map[string]int32, *_nethttp.Response, error)
- func (a *PortsApiService) RemovePort(ctx _context.Context, username string, ePort int32) (*_nethttp.Response, error)
- type ResizeRequest
- type ServerConfiguration
- type ServerVariable
- type State
- type StateApiService
- func (a *StateApiService) GetState(ctx _context.Context, username string) (State, *_nethttp.Response, error)
- func (a *StateApiService) Reboot(ctx _context.Context, username string) (*_nethttp.Response, error)
- func (a *StateApiService) Shutdown(ctx _context.Context, username string) (*_nethttp.Response, error)
- func (a *StateApiService) Start(ctx _context.Context, username string) (*_nethttp.Response, error)
- func (a *StateApiService) Sync(ctx _context.Context, username string) (*_nethttp.Response, error)
- type Usage
- type Webspace
Constants ¶
This section is empty.
Variables ¶
var ( // ContextOAuth2 takes an oauth2.TokenSource as authentication for the request. ContextOAuth2 = contextKey("token") // ContextBasicAuth takes BasicAuth as authentication for the request. ContextBasicAuth = contextKey("basic") // ContextAccessToken takes a string oauth2 access token as authentication for the request. ContextAccessToken = contextKey("accesstoken") // ContextAPIKey takes an APIKey as authentication for the request ContextAPIKey = contextKey("apikey") )
Functions ¶
Types ¶
type APIClient ¶
type APIClient struct { ConfigApi *ConfigApiService ConsoleApi *ConsoleApiService DomainsApi *DomainsApiService ImagesApi *ImagesApiService PortsApi *PortsApiService StateApi *StateApiService // contains filtered or unexported fields }
APIClient manages communication with the Netsoc webspaced API v1.2.0 In most cases there should be only one, shared, APIClient.
func NewAPIClient ¶
func NewAPIClient(cfg *Configuration) *APIClient
NewAPIClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.
func (*APIClient) ChangeBasePath ¶
ChangeBasePath changes base path to allow switching to mocks
func (*APIClient) GetConfig ¶
func (c *APIClient) GetConfig() *Configuration
Allow modification of underlying config for alternate implementations and testing Caution: modifying the configuration while live can cause data races and potentially unwanted behavior
type APIKey ¶
APIKey provides API key based authentication to a request passed via context using ContextAPIKey
type APIResponse ¶
type APIResponse struct { *http.Response `json:"-"` Message string `json:"message,omitempty"` // Operation is the name of the OpenAPI operation. Operation string `json:"operation,omitempty"` // RequestURL is the request URL. This value is always available, even if the // embedded *http.Response is nil. RequestURL string `json:"url,omitempty"` // Method is the HTTP method used for the request. This value is always // available, even if the embedded *http.Response is nil. Method string `json:"method,omitempty"` // Payload holds the contents of the response body (which may be nil or empty). // This is provided here as the raw response.Body() reader will have already // been drained. Payload []byte `json:"-"` }
APIResponse stores the API response returned by the server.
func NewAPIResponse ¶
func NewAPIResponse(r *http.Response) *APIResponse
NewAPIResponse returns a new APIResonse object.
func NewAPIResponseWithError ¶
func NewAPIResponseWithError(errorMessage string) *APIResponse
NewAPIResponseWithError returns a new APIResponse object with the provided error message.
type AddRandomPortResponse ¶
type AddRandomPortResponse struct { // Network port EPort int32 `json:"ePort"` }
AddRandomPortResponse struct for AddRandomPortResponse
type BasicAuth ¶
type BasicAuth struct { UserName string `json:"userName,omitempty"` Password string `json:"password,omitempty"` }
BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
type Config ¶
type Config struct { // How many seconds to delay incoming connections to a webspace while starting the container StartupDelay float64 `json:"startupDelay,omitempty"` // Incoming SSL-terminated HTTP requests (and SNI passthrough HTTPS connections) will be forwarded to this port HttpPort int32 `json:"httpPort,omitempty"` // If true, SSL termination will be disabled and HTTPS connections will forwarded directly SniPassthrough bool `json:"sniPassthrough,omitempty"` }
Config Webspace configuration
type ConfigApiService ¶
type ConfigApiService service
ConfigApiService ConfigApi service
func (*ConfigApiService) Create ¶
func (a *ConfigApiService) Create(ctx _context.Context, username string, initRequest InitRequest) (Webspace, *_nethttp.Response, error)
Create Initialize webspace
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
- @param initRequest
@return Webspace
func (*ConfigApiService) Delete ¶
func (a *ConfigApiService) Delete(ctx _context.Context, username string) (*_nethttp.Response, error)
Delete Destroy webspace
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
func (*ConfigApiService) Get ¶
func (a *ConfigApiService) Get(ctx _context.Context, username string) (Webspace, *_nethttp.Response, error)
Get Retrieve all webspace information Retrieve all information about a webspace (except for its current state)
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
@return Webspace
func (*ConfigApiService) GetConfig ¶
func (a *ConfigApiService) GetConfig(ctx _context.Context, username string) (Config, *_nethttp.Response, error)
GetConfig Retrieve webspace configuration
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
@return Config
func (*ConfigApiService) UpdateConfig ¶
func (a *ConfigApiService) UpdateConfig(ctx _context.Context, username string, config Config) (Config, *_nethttp.Response, error)
UpdateConfig Change webspace config options
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
- @param config
@return Config
type Configuration ¶
type Configuration struct { BasePath string `json:"basePath,omitempty"` Host string `json:"host,omitempty"` Scheme string `json:"scheme,omitempty"` DefaultHeader map[string]string `json:"defaultHeader,omitempty"` UserAgent string `json:"userAgent,omitempty"` Debug bool `json:"debug,omitempty"` Servers []ServerConfiguration HTTPClient *http.Client }
Configuration stores the configuration of the API client
func NewConfiguration ¶
func NewConfiguration() *Configuration
NewConfiguration returns a new Configuration object
func (*Configuration) AddDefaultHeader ¶
func (c *Configuration) AddDefaultHeader(key string, value string)
AddDefaultHeader adds a new HTTP header to the default header in the request
type ConsoleApiService ¶
type ConsoleApiService service
ConsoleApiService ConsoleApi service
func (*ConsoleApiService) ClearLog ¶ added in v1.0.4
func (a *ConsoleApiService) ClearLog(ctx _context.Context, username string) (*_nethttp.Response, error)
ClearLog Clear webspace console log
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
func (*ConsoleApiService) Console ¶ added in v1.1.0
func (a *ConsoleApiService) Console(ctx _context.Context, username string) (*_nethttp.Response, error)
Console Attach to webspace console _IMPORTANT_: This endpoint uses a websocket. On connection, a single text message should be sent with integers for terminal `width` and `height` (as JSON, see `ResizeRequest` e.g. `{\"width\": 80, \"height\": 24}`). Following this, binary messages to and from the socket will be routed to the console TTY. Any other text messages will also be treated as resize events (same format).
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
func (*ConsoleApiService) Exec ¶ added in v1.1.2
func (a *ConsoleApiService) Exec(ctx _context.Context, username string, execRequest ExecRequest) (ExecResponse, *_nethttp.Response, error)
Exec Execute command non-interactively Runs a command non-interactively (no TTY, waits for completion and returns complete stdout and stderr).
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
- @param execRequest
@return ExecResponse
func (*ConsoleApiService) ExecInteractive ¶ added in v1.1.2
func (a *ConsoleApiService) ExecInteractive(ctx _context.Context, username string) (*_nethttp.Response, error)
ExecInteractive Execute a command interactively _IMPORTANT_: This endpoint uses a websocket. On connection, a single text message should be sent (as JSON), this message is of the form `ExecInteractiveRequest`. Following this, binary messages to and from the socket will be routed to the process PTY. Any other text messages will be treated as `ExecInteractiveControl` messages. Pass a signal number to send a signal to the process, and non-zero values for `width` and `height` to resize. Upon command completion, the close message will be the exit code of the process.
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
func (*ConsoleApiService) GetLog ¶
func (a *ConsoleApiService) GetLog(ctx _context.Context, username string) (string, *_nethttp.Response, error)
GetLog Retrieve webspace console log
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
@return string
type DomainsApiService ¶
type DomainsApiService service
DomainsApiService DomainsApi service
func (*DomainsApiService) AddDomain ¶
func (a *DomainsApiService) AddDomain(ctx _context.Context, username string, domain string) (*_nethttp.Response, error)
AddDomain Add custom domain Domain will be verified by looking for a `TXT` record of the format `webspace:id:<user id>`
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
- @param domain
func (*DomainsApiService) GetDomains ¶
func (a *DomainsApiService) GetDomains(ctx _context.Context, username string) ([]string, *_nethttp.Response, error)
GetDomains Retrieve webspace domains
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
@return []string
func (*DomainsApiService) RemoveDomain ¶
func (a *DomainsApiService) RemoveDomain(ctx _context.Context, username string, domain string) (*_nethttp.Response, error)
RemoveDomain Delete custom domain
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
- @param domain
type Error ¶
type Error struct { // Message explaining the error Message string `json:"message"` }
Error struct for Error
type ExecInteractiveControl ¶ added in v1.1.2
type ExecInteractiveControl struct { Resize ResizeRequest `json:"resize,omitempty"` // Signal to send to process Signal int32 `json:"signal,omitempty"` }
ExecInteractiveControl struct for ExecInteractiveControl
type ExecInteractiveRequest ¶ added in v1.1.2
type ExecInteractiveRequest struct { Command []string `json:"command"` // User ID to run as User int32 `json:"user,omitempty"` // Group ID to run as Group int32 `json:"group,omitempty"` // Additional environment variables to pass to process Environment map[string]string `json:"environment,omitempty"` // Width of terminal (columns) Width int32 `json:"width"` // Height of terminal (rows) Height int32 `json:"height"` WorkingDirectory string `json:"workingDirectory,omitempty"` }
ExecInteractiveRequest struct for ExecInteractiveRequest
type ExecRequest ¶ added in v1.1.2
type ExecRequest struct {
Command string `json:"command"`
}
ExecRequest struct for ExecRequest
type ExecResponse ¶ added in v1.1.2
type ExecResponse struct { // Process stdout Stdout string `json:"stdout"` // Process stderr Stderr string `json:"stderr"` // Process exit code ExitCode int32 `json:"exitCode"` }
ExecResponse struct for ExecResponse
type GenericOpenAPIError ¶
type GenericOpenAPIError struct {
// contains filtered or unexported fields
}
GenericOpenAPIError Provides access to the body, error and model on returned errors.
func (GenericOpenAPIError) Body ¶
func (e GenericOpenAPIError) Body() []byte
Body returns the raw bytes of the response
func (GenericOpenAPIError) Error ¶
func (e GenericOpenAPIError) Error() string
Error returns non-empty string if there was an error.
func (GenericOpenAPIError) Model ¶
func (e GenericOpenAPIError) Model() interface{}
Model returns the unpacked model of the error
type Image ¶
type Image struct { Aliases []ImageAlias `json:"aliases"` // SHA-256 hash of the image Fingerprint string `json:"fingerprint"` // Arbitrary properties Properties map[string]string `json:"properties"` // Size in bytes Size int64 `json:"size"` }
Image LXD image (summarised version of https://linuxcontainers.org/lxd/docs/master/rest-api#10imagesfingerprint)
type ImageAlias ¶
type ImageAlias struct { Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` }
ImageAlias LXD image alias
type ImagesApiService ¶
type ImagesApiService service
ImagesApiService ImagesApi service
type InitRequest ¶
type InitRequest struct { // Image alias or fingerprint Image string `json:"image"` // Password for root user Password string `json:"password,omitempty"` // Whether or not to install an SSH server (and create a port forward for it). Requires the user to have an SSH key on their account. Ssh bool `json:"ssh,omitempty"` }
InitRequest struct for InitRequest
type InterfaceAddress ¶
type InterfaceAddress struct { Family string `json:"family"` Address string `json:"address"` Netmask string `json:"netmask"` Scope string `json:"scope,omitempty"` }
InterfaceAddress Network interface address
type InterfaceCounters ¶
type InterfaceCounters struct { BytesReceived int64 `json:"bytesReceived"` BytesSent int64 `json:"bytesSent"` PacketsReceived int64 `json:"packetsReceived"` PacketsSent int64 `json:"packetsSent"` }
InterfaceCounters Counters for a network interface
type NetworkInterface ¶
type NetworkInterface struct { // MAC address Mac string `json:"mac"` Mtu int32 `json:"mtu"` State string `json:"state"` Counters InterfaceCounters `json:"counters"` Addresses []InterfaceAddress `json:"addresses"` }
NetworkInterface Webspace network interface status
type PortsApiService ¶
type PortsApiService service
PortsApiService PortsApi service
func (*PortsApiService) AddPort ¶
func (a *PortsApiService) AddPort(ctx _context.Context, username string, ePort int32, iPort int32) (*_nethttp.Response, error)
AddPort Add port forward
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
- @param ePort
- @param iPort
func (*PortsApiService) AddRandomPort ¶
func (a *PortsApiService) AddRandomPort(ctx _context.Context, username string, iPort int32) (AddRandomPortResponse, *_nethttp.Response, error)
AddRandomPort Add random port forward Add port forward from random free port to internal port
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
- @param iPort
@return AddRandomPortResponse
func (*PortsApiService) GetPorts ¶
func (a *PortsApiService) GetPorts(ctx _context.Context, username string) (map[string]int32, *_nethttp.Response, error)
GetPorts Retrieve webspace port forwards
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
@return map[string]int32
func (*PortsApiService) RemovePort ¶
func (a *PortsApiService) RemovePort(ctx _context.Context, username string, ePort int32) (*_nethttp.Response, error)
RemovePort Delete port forward
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
- @param ePort
type ResizeRequest ¶ added in v1.1.2
type ResizeRequest struct { // Width of terminal (columns) Width int32 `json:"width"` // Height of terminal (rows) Height int32 `json:"height"` }
ResizeRequest struct for ResizeRequest
type ServerConfiguration ¶
type ServerConfiguration struct { Url string Description string Variables map[string]ServerVariable }
ServerConfiguration stores the information about a server
type ServerVariable ¶
ServerVariable stores the information about a server variable
type State ¶
type State struct { Running bool `json:"running"` // Length of time for which container has been running (seconds) Uptime float64 `json:"uptime"` Usage Usage `json:"usage"` NetworkInterfaces map[string]NetworkInterface `json:"networkInterfaces"` }
State Webspace state
type StateApiService ¶
type StateApiService service
StateApiService StateApi service
func (*StateApiService) GetState ¶
func (a *StateApiService) GetState(ctx _context.Context, username string) (State, *_nethttp.Response, error)
GetState Retrieve webspace state Retrieve webspace state
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
@return State
func (*StateApiService) Reboot ¶
Reboot Reboot webspace container
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
func (*StateApiService) Shutdown ¶
func (a *StateApiService) Shutdown(ctx _context.Context, username string) (*_nethttp.Response, error)
Shutdown Shut down webspace container
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
func (*StateApiService) Start ¶
Start Start webspace container
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
func (*StateApiService) Sync ¶ added in v1.0.1
Sync Re-generate webspace backend config Forces a reload of reverse proxy and port forwarding configuration
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param username User's username. Can be `self` to indicate the currently authenticated user.
type Usage ¶
type Usage struct { // CPU time (nanoseconds) Cpu int64 `json:"cpu"` Disks map[string]int64 `json:"disks"` // Memory usage in bytes Memory int64 `json:"memory"` // Number of processes Processes int64 `json:"processes"` }
Usage Website resource usage
type Webspace ¶
type Webspace struct { // Unique database identifier, not modifiable. User int32 `json:"user,omitempty"` Config Config `json:"config,omitempty"` // List of webspace custom domains Domains []string `json:"domains,omitempty"` // Mapping of external ports to internal container ports (port forwarding) Ports map[string]int32 `json:"ports,omitempty"` }
Webspace Netsoc webspace object
Source Files ¶
- api_config.go
- api_console.go
- api_domains.go
- api_images.go
- api_ports.go
- api_state.go
- client.go
- configuration.go
- model_add_random_port_response.go
- model_config.go
- model_error.go
- model_exec_interactive_control.go
- model_exec_interactive_request.go
- model_exec_request.go
- model_exec_response.go
- model_image.go
- model_image_alias.go
- model_init_request.go
- model_interface_address.go
- model_interface_counters.go
- model_network_interface.go
- model_resize_request.go
- model_state.go
- model_usage.go
- model_webspace.go
- response.go