Documentation ¶
Index ¶
- func CheckResponse(r *http.Response) error
- type Client
- type Config
- type ErrorResponse
- type Events
- type MachineOptions
- type Machines
- type MachinesRequest
- type MachinesService
- func (s *MachinesService) Availability(opt *MachineOptions) (*Machines, *Response, error)
- func (s *MachinesService) Create(mr *MachinesRequest) (*Machines, *Response, error)
- func (s *MachinesService) Destroy(machineID string) (*Response, error)
- func (s *MachinesService) List() ([]*Machines, *Response, error)
- func (s *MachinesService) Restart(machineID string) (*Response, error)
- func (s *MachinesService) Show(opt *MachineOptions) (*Machines, *Response, error)
- func (s *MachinesService) Start(machineID string) (*Response, error)
- func (s *MachinesService) Stop(machineID string) (*Response, error)
- func (s *MachinesService) Update(m *Machines) (*Response, error)
- type Network
- type NetworksService
- type Response
- type Scripts
- type ScriptsRequest
- type ScriptsService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse checks the Paperpspace API response for a non-2xx status code.
Types ¶
type Client ¶
type Client struct { // Base URL for API requests. BaseURL *url.URL // UserAgent for client. UserAgent string // Config for client. Config *Config // Services used for talking to different parts of the Paperspace API. Scripts *ScriptsService Machines *MachinesService Networks *NetworksService // contains filtered or unexported fields }
Client manages communication with Paperspace API.
func (*Client) Do ¶
Do sends an API request and returns the API response. 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.
func (*Client) NewRequest ¶
NewRequest creates a new Paperspace API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the baseURL of the Client. If specified, the value pointed to by body is JSON encoded and included as the request body.
type Config ¶
type Config struct { // API Key for client authorization. APIKey string }
Config manages Authorization with Paperspace API.
type ErrorResponse ¶
type ErrorResponse struct { // HTTP response that caused this error Response *http.Response // Error message Message string `json:"message"` }
ErrorResponse reports the error caused by an API request.
type Events ¶
type Events struct { Name string `json:"name,omitempty"` State string `json:"state,omitempty"` ErrorMsg string `json:"errorMsg,omitempty"` Handle string `json:"handle,omitempty"` DtModified string `json:"dtModified,omitempty"` DtFinished string `json:"dtFinished,omitempty"` DtCreated string `json:"dtCreated,omitempty"` }
Events represents a Paperspace machine event.
type MachineOptions ¶
type MachineOptions struct { MachineID string `url:"machineId,omitempty"` Region string `url:"region,omitempty"` MachineType string `url:"machineType,omitempty"` }
MachineOptions specifies the optional parameters to the MachinesService.Availability & MachinesService.Show methods.
type Machines ¶
type Machines struct { ID string `json:"id,omitempty"` MachineID string `json:"machineId,omityempty"` Name string `json:"name,omitempty"` OS string `json:"os,omitempty"` RAM string `json:"ram,omitempty"` GPU string `json:"gpu,omitempty"` Cpus int `json:"cpus,omitempty"` StorageTotal string `json:"storageTotal,omitempty"` StorageUsed string `json:"storageUsed,omitempty"` UsageRate string `json:"usageRate,omitempty"` ShutdownTimeoutInHours int `json:"shutdownTimeoutInHours,omitempty"` ShutdownTimeoutForces bool `json:"shutdownTimeoutForces,omitempty"` PerformAutoSnapshot bool `json:"performAutoSnapshot,omitempty"` AutoSnapshotFrequency int `json:"autoSnapshotFrequency,omitempty"` AutoSnapshotSaveCount int `json:"autoSnapshotSaveCount,omitempty"` AgentType string `json:"agentType,omitempty"` State string `json:"state,omitempty"` UpdatesPending bool `json:"updatesPending,omitempty"` NetworkID string `json:"networkId,omitempty"` PrivateIPAddress string `json:"privateIpAddress,omitempty"` PublicIPAddress string `json:"publicIpAddress,omitempty"` DynamicPublicIP bool `json:"dynamicPublicIp,omitempty"` Region string `json:"region,omitempty"` UserID string `json:"userId,omitempty"` TeamID string `json:"teamId,omitempty"` ScriptID string `json:"scriptId,omitempty"` DtCreated string `json:"dtCreated,omitempty"` DtLastRun string `json:"dtLastRun,omitempty"` Available bool `json:"available,omitempty"` Events []Events }
Machines represents a Paperspace Machine.
type MachinesRequest ¶
type MachinesRequest struct { Region string `json:"region,omitempty"` MachineType string `json:"machineType,omitempty"` Size int `json:"size,omitempty"` BillingType string `json:"billingType,omitempty"` MachineName string `json:"machineName,omitempty"` TemplateID string `json:"templateId,omitempty"` AssignPublicID bool `json:"assignPublicIp,omitempty"` DynamicPublicID bool `json:"dynamicPublicIp,omitempty"` NetworkID string `json:"networkId,omitempty"` TeamID string `json:"teamId,omitempty"` UserID string `json:"userId,omitempty"` Email string `json:"email,omitempty"` Password string `json:"password,omitempty"` FirstName string `json:"firstName,omitempty"` LastName string `json:"lastName,omitempty"` NotificationEmail string `json:"notificationEmail,omitempty"` ScriptID string `json:"scriptId,omitempty"` }
MachinesRequest represents a request to create a Paperspace Machine.
type MachinesService ¶
type MachinesService struct {
// contains filtered or unexported fields
}
MachinesService manages Machines for the Paperspace API. Paperspace API docs: https://paperspace.github.io/paperspace-node/machines.html
func (*MachinesService) Availability ¶
func (s *MachinesService) Availability(opt *MachineOptions) (*Machines, *Response, error)
Availability gets machine availability for the given region and machine type. https://paperspace.github.io/paperspace-node/machines.html#.availability
func (*MachinesService) Create ¶
func (s *MachinesService) Create(mr *MachinesRequest) (*Machines, *Response, error)
Create creates new a virtual machine. https://paperspace.github.io/paperspace-node/machines.html#.create
func (*MachinesService) Destroy ¶
func (s *MachinesService) Destroy(machineID string) (*Response, error)
Destroy destroys an existing virtual machine. https://paperspace.github.io/paperspace-node/machines.html#.destroy
func (*MachinesService) List ¶
func (s *MachinesService) List() ([]*Machines, *Response, error)
List lists information about all machines available to the authenticated user or team. https://paperspace.github.io/paperspace-node/machines.html#.list
func (*MachinesService) Restart ¶
func (s *MachinesService) Restart(machineID string) (*Response, error)
Restart restarts an existing virtual machine. https://paperspace.github.io/paperspace-node/machines.html#.restart
func (*MachinesService) Show ¶
func (s *MachinesService) Show(opt *MachineOptions) (*Machines, *Response, error)
Show shows machine information. https://paperspace.github.io/paperspace-node/machines.html#.show
func (*MachinesService) Start ¶
func (s *MachinesService) Start(machineID string) (*Response, error)
Start starts an existing virtual machine. https://paperspace.github.io/paperspace-node/machines.html#.start
func (*MachinesService) Stop ¶
func (s *MachinesService) Stop(machineID string) (*Response, error)
Stop stops an existing virtual machine. https://paperspace.github.io/paperspace-node/machines.html#.stop
func (*MachinesService) Update ¶
func (s *MachinesService) Update(m *Machines) (*Response, error)
Update updates attributes of a virtual machine. https://paperspace.github.io/paperspace-node/machines.html#.update
type Network ¶
type Network struct { ID string `json:"id"` Name string `json:"name"` Region string `json:"region"` DtCreated time.Time `json:"dtCreated"` Network string `json:"network"` Netmask string `json:"netmask"` TeamID string `json:"teamId"` }
Network represents a Paperspace Network.
type NetworksService ¶
type NetworksService struct {
// contains filtered or unexported fields
}
NetworksService manages Networks for the Paperspace API. https://paperspace.github.io/paperspace-node/networks.html
func (*NetworksService) List ¶
func (s *NetworksService) List() ([]*Network, *Response, error)
List lists information about all machines available to the authenticated user or team. https://paperspace.github.io/paperspace-node/machines.html#.list
type Response ¶
Response is a Paperspace response. This wraps the standard http.Response returned from Paperspace.
type Scripts ¶
type Scripts struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` OwnerType string `json:"ownerType,omitempty"` OwnerID string `json:"ownerId,omitempty"` Description string `json:"description,omitempty"` DtCreated time.Time `json:"dtCreated,omitempty"` IsEnabled bool `json:"isEnabled,omitempty"` RunOnce bool `json:"runOnce,omitempty"` }
Scripts represents a Paperspace Script.
type ScriptsRequest ¶
type ScriptsRequest struct { MachineID string `json:"machineId,omitempty"` ScriptName string `json:"scriptName,omitempty"` ScriptFile string `json:"scriptFile,omitempty"` ScriptText string `json:"scriptText,omitempty"` ScriptDescription string `json:"scriptDescription,omitempty"` IsEnabled bool `json:"isEnabled,omitempty"` RunOnce bool `json:"runOnce,omitempty"` }
ScriptsRequest represents a request to create a Paperspace Script.
type ScriptsService ¶
type ScriptsService struct {
// contains filtered or unexported fields
}
ScriptsService manages Scripts for the Paperspace API. Paperspace API docs: https://paperspace.github.io/paperspace-node/scripts.html
func (*ScriptsService) Create ¶
func (s *ScriptsService) Create(options *ScriptsRequest) (*Scripts, *Response, error)
Create creates a new Paperspace Script based on given parameters. https://paperspace.github.io/paperspace-node/scripts.html#.create
func (*ScriptsService) List ¶
func (s *ScriptsService) List() (*Scripts, *Response, error)
List lists all scripts from Paperspace. https://paperspace.github.io/paperspace-node/scripts.html#.list